On May 5, 2004, at 12:26 PM, Madhu Reddy wrote:
following is my main script, to simulate that i assigned to $_. Thanks for your solution
if (!(open(FH_SRC_SCRIPT, "$src_script"))) { close(FH_SRC_SCRIPT); return 0; }
Yuck. What does that say? If we can't open() some file, close the file (huh?), and return. How about we simplify and pretty that up:
open FH_SRC_SCRIPT, $src_script or return 0;
That should do the exact same thing. Note I didn't quote the variable, as we don't need to.
if (!(open(FH_TARGET_SCRIPT, ">$target_script"))) { close(FH_TARGET_SCRIPT); return 0; }
See above.
while (<FH_SRC_SCRIPT>) { $replace_count += s/<EXPORT_IFILE>/$in_out_file_path/ if (m/<EXPORT_IFILE>/);
if (m/.../) still isn't doing anything, as I've mentioned before. Drop it. s/.../.../ only replaces IF it finds a match.
$replace_count += s/<([A-Z_]+)_IFILE>/$repl/ if (m/<([A-Z_]+)_IFILE>/);
Again, drop the if m/.../.
print FH_TARGET_SCRIPT "$_";
No need to quote a variable here.
print FH_TARGET_SCRIPT $_;
}
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>