Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: About $/

by kcott (Archbishop)
on May 25, 2013 at 07:12 UTC ( [id://1035234]=note: print w/replies, xml ) Need Help??


in reply to About $/

G'day lddzjwwy,

Perhaps something along these lines:

$ perl -Mstrict -Mwarnings -E ' # Create test data use autodie qw{:all}; use File::Temp; my $fh = File::Temp->new(UNLINK => 1); print $fh "qwe\rasd\003zxc\r123"; seek $fh, 0, 0; # Read data splitting on "\r" or "\003" say for split /(?>\r|\003)/ => do { local $/; <$fh> }; ' qwe asd zxc 123

I assume you've picked "\003" purely as an example; I've used the same in the code above. However, using constructs like \o{...}, \x{...}, etc. may save you some interpolation issues down the track (see escape sequences in perlop - Quote and Quote-like Operators).

-- Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-29 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found