Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How to deal with long line

by GrandFather (Saint)
on Sep 27, 2005 at 20:50 UTC ( [id://495551]=note: print w/replies, xml ) Need Help??


in reply to How to deal with long line

If the file is of modest size then read eveything into a string and:

my $str = <DATA>; my @strs = $str =~ /START(.*?)END/g; print join "\n", @strs; __DATA__ somecharSTARTfvENDsomecharSTARTsvENDsomecharSTARTtvENDsomechar
Update: Change to read from a "file"

Monarch has suggested to me that this is likely to get pretty slow with HUGE files, and I agree. For very large files I'd suggest using this technique.


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: How to deal with long line
by gasho (Beadle) on Sep 28, 2005 at 13:09 UTC
    Thanks a lot it worked fine, I updated it to read from a file:
    sub getInfoFromLongLine { #Openning file for reading open(IFH,"$InputFile") || die "Can't open file: $InputFile\n"; my $str = <IFH>; my @wanted_substrings = $str =~ /<A>(.*?)<\/A>/g; return "@wanted_substrings"; }

Log In?
Username:
Password:

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

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

    No recent polls found