Hi Will,
Just a couple of comments on the script you sent.
This is your script with some minor changes.
$infile = "zary_necheva_data.txt";
open(INFILE, $infile) or die "Death $!";
while( $line = <INFILE> ){
$lpos = index($line,"|");
# Your line will capture the first five chars, but in the sample data 2 of
the rows had 6 chars before the first . or space and were truncated
#$first = substr($line, 0, 5); # Will's line
# I suggest using the value of $lpos you captured above
$first = substr($line, 0, $lpos); # My line
# This will replace one or more dots with nothing within the substring, not
quite what was requested
#$first =~ s/\.+//; # Will's line
# This will replace everything after the first dot or space in the substring
with nothing
$first =~ s/[\.\s].*//; # My line
$last = substr($line, $lpos);
print $first.$last;
}
You can also replace the while loop with
while(<INFILE>)
s/^(.*?)[\.\s].*?(\|.*)$/$1$2/;
print;
}
I am sure there are many other ways of doing this, many of them probably
shorter, quicker code, but both these appear to work exactly as requested.
Cheers,
Jim
-----Original Message-----
From: William Martell [mailto:[EMAIL PROTECTED]
Sent: 31 December 2003 14:33
To: [EMAIL PROTECTED]; Zary Necheva
Subject: RE:: Help with extracting text
Hi Zary,
I have attached a sample file with the data you offered and a perl script
which can be copied and pasted into the command line on win32.
Let me know if you have any problems.
HTH,
Will Martell
Dallas Texas
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>