Open File method in Perl -
i tested >>
, >
open destination file in code below, work well. what's different them?
my $sourfile = "ch1.txt"; $destfile = "chapter1.txt"; open (sourfile, $sourfile); open (destfile, ">>$destfile"); #both >> , > work here. #my $fh = \*data; $fh = \*sourfile;
the difference:
> open file writing. >> open file appending.
you might want switch using 3-argument form of open, , using lexical variables file handles:
open(my $handle, '>', "some_file") or die $!;
Comments
Post a Comment