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

Re: adding ";" to void elements

by johngg (Canon)
on Feb 12, 2008 at 15:24 UTC ( [id://667585]=note: print w/replies, xml ) Need Help??


in reply to adding ";" to void elements

This works for two, one or even zero elements.

use strict; use warnings; print map { qq{@{ [ join q{;}, @{ $_ } == 3 ? ( @{ $_ } ) : ( @{ $_ }, ( q{} ) x ( 3 - @{ $_ } ) ) ] }\n} } map { chomp; [ split m{;} ] } <DATA>; __END__ a;3 b;2;3 c;5;4 d;6 f

The output.

a;3; b;2;3 c;5;4 d;6; ;; f;;

I hope this is useful.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-24 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found