skyler has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, I want to concatenate "@" symbol at the end of the 10th field. If I put a comma (,), I get a pipe since it is the join symbol. The way it is written now, it gives me the 10th field and remain concatenation string in the output file. I would like to have all the fields join with the pipe except the last strings join by "@". Is there any way to rewrite this piece of code?? Thanks in advance.
my $out = join '|', @fields[0..9] . "@" . $staticdir .$newfile; print OUT "$out\n";

Replies are listed 'Best First'.
Re: How to concatenate in a "join"
by djantzen (Priest) on Jun 06, 2003 at 04:00 UTC

    You just have to tell join where its own argument list ends using parentheses:

    my $out = join('|', @fields[0..9]) . "@" . $staticdir .$newfile;


    "The dead do not recognize context" -- Kai, Lexx
Re: How to concatenate in a "join"
by chromatic (Archbishop) on Jun 06, 2003 at 03:47 UTC

    I really have no idea what you're asking. Can you give an example of what's in @fields and what you expect to produce at the end?

    Perhaps it would be simpler to make two joins, or one join and one concatenation in separate steps?