Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that it finds the lines in question but it only removes the second line found and not the first. What is wrong with my code? Here is the output:open(SNMPFILE,"+< $local_dir\/cpsnmpagent.cfg"); @ARRAY = <SNMPFILE>; foreach $element (@ARRAY) { if ($element=~/^PABPT.ROW/) { print "$element matches\n"; $element =~ s/$element//; print "element is now $element\n"; } } seek(SNMPFILE,0,0); print SNMPFILE @ARRAY; truncate(SNMPFILE,tell(SNMPFILE)); print SNMPFILE "$conf_chg0\n"; close(SNMPFILE);
Thanks in advancebash-2.03# PABPT.ROW.0= 1000 marks_pabs * 4211 pabd 1 1 5 password matches element is now PABPT.ROW.0= 1000 marks_pabs * 4211 pabd 1 1 5 password PABPT.ROW.0= 34567 pabs_works 10.41.0.70 4211 pabd 1 1 5 password matches element is now
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: bewildering array element problem
by gaal (Parson) on Jul 02, 2004 at 09:57 UTC | |
by Anonymous Monk on Jul 02, 2004 at 10:13 UTC | |
|
Re: bewildering array element problem
by BrowserUk (Patriarch) on Jul 02, 2004 at 10:26 UTC |