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

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -