develooper Front page | perl.beginners | Postings from August 2009

Re: 'Join' query

Thread Previous | Thread Next
From:
Dermot
Date:
August 7, 2009 08:13
Subject:
Re: 'Join' query
Message ID:
9c7446e70908070813o7557a115o2ede645771b31bf4@mail.gmail.com
2009/8/7 jet speed <speedjet5@googlemail.com>:
> Hi,
>
> I would like to join the $abc with ':'  the final desired output 1:2:3:4:5
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $abc = "1 2 3 4 5";
> my $out = join ':', $abc;
> print "$out";
>

join works on arrays (LIST). You feeding it a scalar.


@abc = qw/1 2 3 4 5/;
print join ':', @abc;

Should work.

See perldoc -f join for more details.
Dp.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About