[Bangalore-pm] help in scripting

Gurunath Katagi gurunath.katagi at gmail.com
Fri Apr 15 23:43:58 PDT 2011


hi ..
how r u reading the a list of values into a scalar ..
when i tried this, its taking only one value ..
please find the input file attached ..
  and kindly reply ..

Thank you
gurunath


On Sat, Apr 16, 2011 at 11:19 AM, Jagadeesh N. Malakannavar <
mnjagadeesh at gmail.com> wrote:

> Here is the sample script . hope this helps you
>
> use strict;
> use warnings;
>
> my $str =<<EOF;
> 16 50
> 16 30
> 16 23
> 17 88
> 17 99
> 18 89
> 18 1
> EOF
>
> my $DATA;
>
> while ($str =~ m/\G((\d+)\s+(\d+)\n)/gc) {
>     push @{$DATA->{$2}}, $3;
> }
>
> foreach my $num (sort keys %$DATA) {
>     print "\n$num ", join (' ', @{$DATA->{$num}});
> }
>
>
> ----
> Thanks
> Jagadeesh N.Malakannavar
> 9448471968
>
> 2011/4/16 Gurunath Katagi <gurunath.katagi at gmail.com>
>
>> hi .. i am new to perl ..
>> i have a input file something pasted as below ..
>>
>> 16 50
>> 16 30
>> 16 23
>> 17 88
>> 17 99
>> 18 89
>> 18 1
>> ..
>> --
>>
>> and i want the output something like this :
>> 16 50 30 23
>> 17 88 99
>> 18 99 1
>>
>> i.e for each values in the first column, i want the elements in the second
>> column to be a one row ..
>>
>> can be anybody give me psuedocode , to how to go about this ..
>> thank you
>>
>> gurunath
>>
>> _______________________________________________
>> Bangalore-pm mailing list
>> Bangalore-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/bangalore-pm
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/bangalore-pm/attachments/20110416/f7fe35cc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tr1.dat
Type: application/x-ns-proxy-autoconfig
Size: 493 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/bangalore-pm/attachments/20110416/f7fe35cc/attachment.bin>


More information about the Bangalore-pm mailing list