Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Inserting an element into an array after a certain element

by tlm (Prior)
on Apr 01, 2005 at 10:36 UTC ( [id://444140]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Inserting an element into an array after a certain element
in thread Inserting an element into an array after a certain element

Oh, it breaks if any of the elements consists of more than one character:

% perl -le 'print"@{[split//,join q(x),split/(?<=c)/,join(q(),qw(a b c + d c e foo f)),2]}"' a b c x d c e f o o f
but single spaces are fine:
% perl -le 'print"@{[split//,join q(x),split/(?<=c)/,join(q(),qw(a b c + d c e),q( ),q(f)),2]}"' a b c x d c e f
To fix this, I guess one could do something like
perl -le 'print"@{[split/\0/,join qq(\0x),split/(?<=c)/,join(qq(0),qw( +a b c d c e foo f)),2]}"' a b c x d c e foo f

the lowliest monk

Log In?
Username:
Password:

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

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

      No recent polls found