On May 5, 2004, at 12:44 PM, Madhu Reddy wrote:
James, Thanks for correction.. for u r question regarding file open, following is correct code
if (!(open(FH_SRC_SCRIPT, $src_script))) { print "(TERADATA.pl) generate_script:: File $src_script open failed --> $!\n"; return 0; }
Is this inside a subroutine or just out in the open? If we're not in a sub, better is:
open FH_SRC_SCRIPT, $src_script or die "File error: $!\n";
if (!(open(FH_TARGET_SCRIPT,
">$target_script")))
{
print "(TERADATA.pl) generate_script::
File $target_script open failed --> $!\n";
# close previously opened file
close(FH_SRC_SCRIPT);
return 0;
}
Again, if we're not in a sub I prefer die(). The other file would be closed automatically on exit.
here i am closing previously opened file...
if i want to open a file in write mode, we have to specify ">$file" right ?
Yes, you do need quotes to add the mode.
does >$file will work ?
No, it doesn't.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
