在 2010-01-19二的 00:09 -0500,Perl Noob写道: > I have a data file with thousands of records. The problem is that the > records in the data file span two lines for each record. I want to > write a perl script that makes each record a single line. The file > looks like this: >
HI, If you are using a regex, then may want to try the /m option. see perldoc perlre for details. I give the code below, it could work for me. use strict; local $/="RECORD1FIELD5\n"; while(<DATA>) { my @fields = /\w+/gm; print "@fields\n"; } __DATA__ RECORD1FIELD1 RECORD1FIELD2 RECORD1FIELD3 RECORD1FIELD3 RECORD1FIELD4 RECORD1FIELD5 RECORD2FIELD1 RECORD2FIELD2 RECORD2FIELD3 RECORD2FIELD3 RECORD2FIELD4 RECORD2FIELD5 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/