I've got a large text file that I'm trying to parse some fields from. I'm
using substr to pull the first field and that is working just fine, now I'm
trying to print the values between 2 irregular delimiters in this case a "^UT"
and a "^". I'm matching it with m/ but I don't seem to be able to get it to
print the string that matches. I've been struggling with this for a day and a
half now without success.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
snippet of statsample file
D20010102102708016R
^S87CVFFSTAFF^UZ1933^PGFEMALE^PHCITY^PEADULT^UTBIO^IKMARC^^O00159
D20010102104408016R
^S87CVFFSTAFF^UZ1933^PGMALE^PHCOUNTY^PEADULT^UTEASY^IKMARC^^O00159
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
My perl script
#!/usr/bin/perl
use warnings;
open (IN, 'statsample');
while (<IN>) {
chomp;
$stamp = substr($_,0,19); # extract the time stamp field
$itemlocation = $_ =~ m/^UT(.*?)^/;
print "$stamp,$itemlocation\n";
}
close (IN);
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Result I get
D20010102102708016,
D20010102104408016R,
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Result I want
D20010102102708016,BIO
D20010102104408016R,EASY
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/