Changes

File I/O in Perl

684 bytes added, 17:49, 24 November 2010
Reverted edits by [[Special:Contributions/Atekysepiko|Atekysepiko]] ([[User_talk:Atekysepiko|Talk]]); changed back to last version by [[User:Admin|Admin]]
The following lines were added (+) and removed (-):
  open (GUEST,">$guestbk") || die "Can't Open $guestbookreal: $!\n";Writing to a file overwrites what was in the file previously and writes the new information over it.  print GUEST "<H1>New Guestbook Entry</H1>\n";   print GUEST "$FORM{'realname'}</a></b>";  <nowiki>open (GUEST,">$guestbk") || die "Can't Open $guestbookreal: $!\n";</nowiki>  print GUEST "<b>Time:&nbsp;</b>$date<br>\n";  <nowiki>print GUEST "<H1>New Guestbook Entry</H1>\n";</nowiki>  print GUEST "<b>Comments:&nbsp;</b>$txtComments<br>\n";  <nowiki>print GUEST "$FORM{'realname'}</a></b>";</nowiki>  <nowiki>print GUEST "<b>Time:&nbsp;</b>$date<br>\n";</nowiki>  <nowiki>print GUEST "<b>Comments:&nbsp;</b>$txtComments<br>\n";</nowiki>Read from one file and write its contents into another file. my $infile = 'bobsbills.txt'; my $outfile = 'bobsexpenses.txt'; open IN, "< $infile" or die "Can't open $infile : $!"; open OUT, "> $outfile" or die "Can't open $outfile : $!"; print OUT <IN>; close IN; close OUT;== Other Methods of File Access ==Here's a quick way to write to a file without using a filehandle. print `echo "Write this line" > filename.txt"`;Read without filehandle $strLines = `cat filename.txt`;
Bureaucrat, administrator
16,192
edits