allison has asked for the wisdom of the Perl Monks concerning the following question:
Sample PP: (899040) Jane Smith Output PP: 899040 Jane Smith
my $filename = "filename"; open my $file, '<', $filename; @fileinput=<$file>; close($file); foreach $line(@fileinput) { my $test=($line); if($test=~s/\(|\)//g) { print $test; }
it remove the parenthesis but it also remove the parenthesis of a non digits. when I Tried to use the code
if($test=~s/\([\d.+]|[\d.+]\)//g)How do I get the numeric values without the parenthesis and add that with the tag 'ID:' in the file to display?the output appeared to be PP: 8945, it didn''t get the 6 digits number
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting the number in a file and get the value and output to the other file
by GrandFather (Saint) on Mar 20, 2011 at 21:29 UTC | |
|
Re: Extracting the number in a file and get the value and output to the other file
by toolic (Bishop) on Mar 20, 2011 at 22:48 UTC | |
|
Re: Extracting the number in a file and get the value and output to the other file
by ww (Archbishop) on Mar 20, 2011 at 21:57 UTC | |
|
Re: Extracting the number in a file and get the value and output to the other file
by Marshall (Canon) on Mar 21, 2011 at 00:54 UTC |