Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 ( [id://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 (Archbishop) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1024211]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found