It worked like charm, but a quick question, why the print is misbehaving under 
the loop, but once out how it print right result.

Regards.../om

On 14-Mar-2012, at 16:54, timothy adigun <2teezp...@gmail.com> wrote:

> OR use:
>   #!/usr/bin/perl -w
>   use strict;
> 
>  my @column;
> while (<DATA>) {
>        push @column, (split)[0];  
> }
>  print join " ",@column;
> 
> __DATA__
> 1 a b c
> 2 d e f
> 3 g h i
> 
> On Wed, Mar 14, 2012 at 12:19 PM, timothy adigun <2teezp...@gmail.com> wrote:
> Hi Torqued,
> 
> On Wed, Mar 14, 2012 at 11:51 AM, Torqued <torque.in...@gmail.com> wrote:
> I have a code which goes like this
> 
> #!/usr/bin/perl -w
> use strict;
> 
> my @column;
>     my $k; 
> while (<DATA>) {
>        push @column, (split)[0];
>        #print join (' ', @column);
>           $k=join (' ', @column);
> }
>      print $k; 
> ***OUTPUT**
>      1 2 3
>  
> __DATA__
> 1 a b c
> 2 d e f
> 3 g h i
> 
> But when running this i get the output as : 11 21 2 3
> Whereas i am trying to get the output as : 1 2 3
> 
> could you please suggest what i am doing wrong here?
> 
> Regards.../om
> 
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 
> 
> 
> 
> -- 
> Tim
> 
> 
> 
> 
> -- 
> Tim
> 

Reply via email to