CGI-BBS > CGI > Perl > Perlについて処理Aで名前をつけ、生成したファイルに...


カレッヂ
カレッヂ


質問者 mi  投稿日 2005/3/4(金) 21:15:26
別処理Bの内容を書き込みたいのですが。
上手くいきません。
生成ファイルの呼び出し方が悪いのでしょうか?

処理A
sub secwrt {
	open(IN,"$snofile") || &error("OPEN ERROR 数字ファイル"); 	$sno = <IN>; 		close IN;
	$sno++;
	open(OUT,">$snofile") || &error("OPEN ERROR 数字ファイル");	print OUT $sno;		close OUT;

	open(IN,"$menufile") || &error("OPEN ERROR メニューファイル");
	@mnew = <IN>; close IN;
	unshift(@mnew,"$sno<>$in{'scom'}<>\n");
	open(OUT,">$menufile") || &error("OPEN ERROR メニューファイル");
	print OUT @mnew; close OUT;

	$file = "file$sno";
	$detafile = "$dir\/$file\.log";
	open(IN,">$detafile");
	close(IN);
	chmod(0666,"$detafile");
}

で$detafileは上手く生成出来たのですが、
$script?sno=$snoで処理Bのフォームへ飛び、

処理B
sub wrt {
	$file = "file$insno";
	$detafile = "$dir\/$file\.log";
	open(IN,"$detafile") || &error("OPEN ERROR newwrt");
	@new = <IN>;
	close IN;
	push(@new,"$in{'pno'}<>$in{'pcom'}<>\n");
	open(OUT,">$detafile") || &error("OPEN ERROR newwrt");
	print OUT @new;
	close OUT;
}


処理Bの書き込みが上手くいきません。
一応、$insno = "$in{'sno'}";で、

処理Bのフォームタグにはhiddenで$insnoを指定してあります。

ファイルは認証しているのですが書き込まれません。
ここで躓いてしまって、どうにも先に進めません。
よろしければご教授ください。

【習熟度】多少の改造ができる

質問者 mi  [削除]  投稿日 2005/3/8(火) 11:00:48
すいません。自己解決しました。
処理Aでメニューファイルに生成するファイル名を書き込んで、処理Bではそのファイル名を呼び出す形を取ったら出来ました。
変更後の処理を書いておきます。

処理A
sub secwrt {
	open(IN,"$snofile") || &error("OPEN ERROR 数字ファイル"); 	$sno = <IN>; 		close IN;
	$sno++;
	open(OUT,">$snofile") || &error("OPEN ERROR 数字ファイル");	print OUT $sno;		close OUT;

	$file = "file$sno";

	open(IN,"$menufile") || &error("OPEN ERROR メニューファイル");
	@mnew = <IN>; close IN;
	unshift(@mnew,"$sno<>$file<>$in{'scom'}<>\n");
	open(OUT,">$menufile") || &error("OPEN ERROR メニューファイル");
	print OUT @mnew; close OUT;

	$detafile = "$dir\/$file\.log";
	open(IN,">$detafile");
	close(IN);
	chmod(0666,"$detafile");
}

$script?sno=$sno&file=$fileで処理Bのフォームへ飛びます。
フォーム内にhiddenで$in{'sno'}と$in{'file'}を入れておきます。

処理B
sub wrt {
	$detafile = "$dir\/$in{'file'}\.log";
	open(IN,"$detafile") || &error("OPEN ERROR newwrt");
	@new = <IN>;
	close IN;
	push(@new,"$in{'pno'}<>$in{'pcom'}<>\n");
	open(OUT,">$detafile") || &error("OPEN ERROR newwrt");
	print OUT @new;
	close OUT;
}


お騒がせしましたm(__)m

このページは終了したので返信(回答)は書きこめません
 


Web裏技