[Bangalore-pm] help in scripting

Jagadeesh N. Malakannavar mnjagadeesh at gmail.com
Sat Apr 16 01:04:02 PDT 2011


please find attached files.  if you still have difficulties getting this
code running let me see your code.


Thanks

On Sat, Apr 16, 2011 at 12:13 PM, Gurunath Katagi <gurunath.katagi at gmail.com
> wrote:

> 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
>>>
>>
>>
>


-- 

Thanks,
Jagadeesh N.Malakannavar
9448471968
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/bangalore-pm/attachments/20110416/c92f0638/attachment.html>
-------------- next part --------------
16 50
16 30
16 23
17 88
17 99
18 89
18 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: guru.pl
Type: application/octet-stream
Size: 323 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/bangalore-pm/attachments/20110416/c92f0638/attachment.obj>


More information about the Bangalore-pm mailing list