Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: join using different delimiter for first element of list

by kennethk (Abbot)
on Dec 07, 2010 at 21:10 UTC ( [id://875888]=note: print w/replies, xml ) Need Help??


in reply to join using different delimiter for first element of list

If I'm understanding you correctly, you could do something like this:

use strict; use warnings; my @FieldNames = ( 'One' , 'Two' , 'Three' , 'Four' , 'Five' ) ; print join ':', shift(@FieldNames), join ',', @FieldNames;

or if you want a non-destructive technique, you could use array Slices:

print join ':', $FieldNames[0], join ',', @FieldNames[1..$#FieldNames];

Replies are listed 'Best First'.
Re^2: join using different delimiter for first element of list
by GrandFather (Saint) on Dec 08, 2010 at 01:49 UTC

    I'd go for slices just to avoid the vagaries of evaluation order! Side effects in evaluating parameter lists are a potent source of hard to track bugs.

    True laziness is hard work

Log In?
Username:
Password:

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

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

    No recent polls found