Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: About $/

by kcott (Chancellor)
on May 25, 2013 at 07:12 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1035234]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-02-24 12:50 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.