On Feb 17, 2010, at 1:07 PM, Rob Dixon wrote:

> Erik Lewis wrote:
>> 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
> 
>  use strict;
> 
> and
> 
>  my $stamp = substr($_,0,19);
>  my ($itemlocation) = $_ =~ m/\^UT(.*?)\^/;
> 
> Rob
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/

Thanks Rob, that changed the result 

D20010102093000111R,1
D20010102093000111R,1


Which I guess is the true value of the match, any idea on how to make it return 
the contents of the match?
> 


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to