Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Splitting a file into records

by LanX (Saint)
on May 03, 2013 at 16:11 UTC ( [id://1031921]=note: print w/replies, xml ) Need Help??


in reply to Splitting a file into records

If I were you I would use the input record separator to split between headlines and records:

$/="\n\n"; print my $head=<DATA>; while ( my $store = <DATA>) { my $listing =<DATA>; chomp($store,$listing); print "\n\n<<<$store>>>\n$listing"; } __DATA__ STORE MONITORING REPORT as of 13-05-02 10:05:07 Scanning for FTFIMS STORE002 -rwxr-xr-- 1 admins store 59025 Apr 11 2012 eft100.cbr 16295 58 -rwxr-xr-- 1 admins store 61143 Nov 15 15:47 chk075.cbr 33334 60 yadda yadda ... STORE006 -rwxr-xr-- 1 admins store 59025 Apr 11 2012 eft100.cbr 16295 58 -rwxr-xr-- 1 admins store 61143 Nov 15 15:47 chk075.cbr 33334 60 yadda yadda ...

another approach would be using the flip-flop-operator aka Range Operators.

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1031921]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found