R
Robert Day
Hi
I am using a very basic Perl script to parse a file and extract just
the elements I need but one aspect is causing me trouble and I am sure
the answer is probably quite simple. Below are examples of two of the
lines (watch wrapping) - the value I seek is that between the date on
the left and the "UV Port" on the right.
Enter bookmobile session location code (or NONE) : NONE 06 FEB 2004
March Mobile A UV Port 51
Circulation
06 FEB 2004 Papworth Library
UV Port 50
The section of code dealing with this is currently
if(/UV/) {
$library = $`;
$library =~ s/^\s+\d{2}\s\w{3}\s\d{4}\s+//;
$library =~ s/- CAMBOOK//g;
$library =~ s/(\w+)/\u\L$1/g;
print "$library\n";
}
The 2nd and 3rd pattern matches deal with other lines in the data (not
shown) in which the value I seek is all CAPS or has "- CAMBOOK"
appended. This code works fine on line 2 of the sample data given
above but I don't know how to get rid of "Enter bookmobile session
location code (or NONE) : NONE" when it appears (as it does on a few
entries). i have tried various patterns and I am sure the solution is
simple but it eludes me at present. Can anyone help?
Robert
I am using a very basic Perl script to parse a file and extract just
the elements I need but one aspect is causing me trouble and I am sure
the answer is probably quite simple. Below are examples of two of the
lines (watch wrapping) - the value I seek is that between the date on
the left and the "UV Port" on the right.
Enter bookmobile session location code (or NONE) : NONE 06 FEB 2004
March Mobile A UV Port 51
Circulation
06 FEB 2004 Papworth Library
UV Port 50
The section of code dealing with this is currently
if(/UV/) {
$library = $`;
$library =~ s/^\s+\d{2}\s\w{3}\s\d{4}\s+//;
$library =~ s/- CAMBOOK//g;
$library =~ s/(\w+)/\u\L$1/g;
print "$library\n";
}
The 2nd and 3rd pattern matches deal with other lines in the data (not
shown) in which the value I seek is all CAPS or has "- CAMBOOK"
appended. This code works fine on line 2 of the sample data given
above but I don't know how to get rid of "Enter bookmobile session
location code (or NONE) : NONE" when it appears (as it does on a few
entries). i have tried various patterns and I am sure the solution is
simple but it eludes me at present. Can anyone help?
Robert