in reply to Re^5: Search and Remove
in thread Search and Remove
Ok so here is my next attempt... but I'm having trouble.
here are the errors I get when running the code:#!/usr/bin/perl use strict; use warnings; #use diagnostics; if (@ARGV = 2){ my %delList; open (my $BEEPON, >>, "./beepon.file"); open (my $BEEPOFF, >>, "./beepoff.file"); open (my $DELLIST, <, $ARGV[0]); foreach (<$DELLIST>){ chomp($_); $delList{$_} = 1; } close $DELLIST; open (my $ORGLIST, <, $ARGV[1]); foreach my $entry (<$ORGLIST>){ chomp($entry); print { exists $delList{$entry} ? $BEEPON : $BEEPOFF } $entry +. "\n"; } close $BEEPON; close $BEEPOFF; }
readline() on closed filehandle $DELLIST at ./delete_list_ver3.pl line + 12. Use of uninitialized value $ARGV[1] in concatenation (.) or string at +./delete_list_ver3.pl line 17. readline() on closed filehandle $ORGLIST at ./delete_list_ver3.pl line + 19. syntax error at ./delete_list_ver3.pl line 8, near ", >>" syntax error at ./delete_list_ver3.pl line 9, near ", >>" Unterminated <> operator at ./delete_list_ver3.pl line 10.
...
grrr...
how can a file I just opened be closed?
In Section
Seekers of Perl Wisdom