Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Split using multiple conditions

by dws (Chancellor)
on Jun 11, 2005 at 21:29 UTC ( #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 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
Node Status?
node history
Node Type: note [id://465851]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2020-10-26 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (253 votes). Check out past polls.

    Notices?