Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^7: Splitting a long row with multiple delimiters.

by poj (Abbot)
on Jan 19, 2018 at 16:50 UTC ( [id://1207543]=note: print w/replies, xml ) Need Help??


in reply to Re^6: Splitting a long row with multiple delimiters.
in thread Splitting a long row with multiple delimiters.

OK try

#!perl use strict; use Data::Dumper; my $str = 'eab12345 a b c id=00000 x= pgrp=abc=defgh groups=abcdefgh a +nd more roles='; my @f = split / (\w+=)/,$str; my @array = (); while (@f){ my $k = shift @f; if ($k =~ /=$/){ my $v = shift @f; push @array,"$k$v"; } else { # key no equal push @array,"$_=" for split /\s+/,$k; } } print Dumper \@array;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found