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

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -