Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Split using multiple conditions

by dws (Chancellor)
on Jun 11, 2005 at 21:29 UTC ( [id://465851]=note: print w/replies, xml ) Need Help??


in reply to Split using multiple conditions

Nother alternative is to remove the brackets first, then split.

my ($nobrackets = $_) =~ s/(\[|\])//g; my @feeder_line = split ' ', $nobrackets;

Replies are listed 'Best First'.
Re^2: Split using multiple conditions
by kaif (Friar) on Jun 13, 2005 at 01:56 UTC

    Unfortunately, this doesn't do quite what the original poster asked for. Consider [id://bart]'s code snippet above and plug it into yours:

    $_ = 'FDR [62.10060.051-F] [62.10051.381] [this includes spaces!] 0 1 +0'; ($nobrackets = $_) =~ s/(\[|\])//g; @feeder_line = split ' ', $nobrackets; $\ = "\n"; print for @feeder_line; __END__ FDR 62.10060.051-F 62.10051.381 this includes spaces! 0 1 0

    N.B.: I have removed the mys because my ($nobrackets = $_) ... results in the error message Can't use global $_ in "my" at - line 1, near "= $_" (the correct syntax is (my $nobrackets = $_) ...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-29 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found