Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Can anyone pls tell me how to cleanup this in Perl.

by Anonymous Monk
on Mar 19, 2013 at 06:07 UTC ( #1024211=note: print w/replies, xml ) Need Help??


in reply to Re: Can anyone pls tell me how to cleanup this in Perl.
in thread Can anyone pls tel me how to cleanup this in Perl.

Thanks Athanasius. That was cool. I am not that good with perl. my question may be foolish but pls can you tell me, how the script should be modified if the data is already in a string. means if '$data' contains the whole data and kindly tell me how I should modify this script.

  • Comment on Re^2: Can anyone pls tell me how to cleanup this in Perl.

Replies are listed 'Best First'.
Re^3: Can anyone pls tell me how to cleanup this in Perl.
by Athanasius (Bishop) on Mar 19, 2013 at 06:14 UTC

    If the data has already been read into the variable $data as a single string, then just replace the line:

    if (my ($field) = grep { /^!!./ } split /\|/, do { local $/; <DATA> })

    with:

    if (my ($field) = grep { /^!!./ } split /\|/, $data)

    (The expression do { local $/; <DATA> } slurps the whole of the data in from the __DATA__ block at the foot of the script.)

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Wow, Cool. That works. Thanks a lot Mr. Athanasius :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-12-18 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many stories does it take before you've heard them all?







    Results (83 votes). Check out past polls.

    Notices?