Having trouble opening a file to read and append things to. Do I need to open the file to read, close, and then reopen for appending? I thought I could use >>+ and save some time.. The matching works fine, and output is boo, so it's getting up to that point.
if ($hostUrl =~ m/(org|net|com|co|edu|gov)/ ) { open NAGHOST, "+>>$host_file" or die "can't open the $host_fil +e $!"; print "\nboo\n"; while (my $line = <NAGHOST>) { #check for duplicate file if ($line =~ m/($hostName|$hostUrl)/) { print "Looks like the data you entered is already on f +ile\n"; } #no duplicate, move forward else { print "\nbah\n"; } }
output:
boo
In reply to Openind file for read+append by jaldama
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |