in reply to Re: Substitue!
in thread Substitution of text within a file
In the next code, the -l option takes care of the newlines.
#!/usr/bin/perl -p -i.bak -l BEGIN { @ARGV = 'personel.txt'; $newdigit="+615"; $id="0001"; } if(/^$id\|/o) { my($id, $name, $family, $oldphone) = split /\|/; $newphone = $newdigit .$oldphone; $_ = join ("|", $id, $name, $family, $newphone); }
p.s. You're trying to read from a file opened for append. Jeez.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Substitue!
by Anonymous Monk on Jun 07, 2003 at 07:47 UTC |