Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: How to deal with long line

by GrandFather (Saint)
on Sep 27, 2005 at 20:50 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2023-09-30 10:35 GMT
Find Nodes?
    Voting Booth?

    No recent polls found