Re: help in scripting

2011-04-17 Thread Shawn H Corey
On 11-04-16 08:30 PM, Uri Guttman wrote: "tx" == tianjun xu writes: tx> my %hash=(); no need to initialize that to (). There is always the need. Not that long ago, mod_perl use to use the same memory as the previous run but it did not zero the memory. You got what every was in there

Re: help in scripting

2011-04-17 Thread Shlomi Fish
Hi John, thanks for your E-mail. See below for my response. On Sunday 17 Apr 2011 04:17:32 John W. Krahn wrote: > Shlomi Fish wrote: > > On Saturday 16 Apr 2011 09:06:02 Gurunath Katagi wrote: > >> hi .. i am new to perl .. > >> i have a input file something pasted as below .. > >> > >> 16 50 >

Re: help in scripting

2011-04-16 Thread John W. Krahn
[ Please do not top-post. TIA ] tianjun xu wrote: This works. #!/usr/bin/perl use strict; use warnings; my %hash=(); while(<>){ chomp(my $line=$_); my($col1, $col2)=split(/\s+/, $line); Or just: while ( <> ) { my ( $col1, $col2 ) = split; push(@{ $hash{$

Re: help in scripting

2011-04-16 Thread John W. Krahn
Shlomi Fish wrote: On Saturday 16 Apr 2011 09:06:02 Gurunath Katagi wrote: 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

Re: help in scripting

2011-04-16 Thread Uri Guttman
> "tx" == tianjun xu writes: tx> my %hash=(); no need to initialize that to (). tx> while(<>){ tx> chomp(my $line=$_); why read the line into $_ and then copy it? while( my $line = <> ) { also please don't quote entire long emails. quote the needed part and put your code

Re: help in scripting

2011-04-16 Thread Shawn H Corey
On 11-04-16 11:06 AM, tianjun xu wrote: print "$key"; for (@{ $hash{$key} }){ print " $_"; } print "\n"; Try: print "$key @{$hash{$key}}\n"; -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding.

Re: help in scripting

2011-04-16 Thread tianjun xu
r (@{ $hash{$key} }){ print " $_"; } print "\n"; } --- On Sat, 4/16/11, Shlomi Fish wrote: > From: Shlomi Fish > Subject: Re: help in scripting > To: beginners@perl.org > Cc: "Gurunath Katagi" > Date: Saturday, April 16, 2011, 2:41

Re: help in scripting

2011-04-16 Thread Uri Guttman
> "AG" == Agnello George writes: AG> On Sat, Apr 16, 2011 at 2:36 PM, Uri Guttman wrote: >> >>  AG> open(INPUT_FILE, $filename)  or die "cannot opnen file $!"; >> >> don't use bareword filehandles. this is said all the time here. use >> lexical handles. >> AG> Could you G

Re: help in scripting

2011-04-16 Thread Agnello George
On Sat, Apr 16, 2011 at 2:36 PM, Uri Guttman wrote: > >  AG> open(INPUT_FILE, $filename)  or die "cannot opnen file $!"; > > don't use bareword filehandles. this is said all the time here. use > lexical handles. > Could you Give me a example for lexical handles or reference me to a website . Th

Re: help in scripting

2011-04-16 Thread Uri Guttman
> "AG" == Agnello George writes: AG> use strict; AG> my $filename = $ARGV[0]; AG> my (%tag,$dkey,$dval); you don't use $dkey or $dval anywhere. AG> open(INPUT_FILE, $filename) or die "cannot opnen file $!"; don't use bareword filehandles. this is said all the time here. use lexi

Re: help in scripting

2011-04-16 Thread Agnello George
On Sat, Apr 16, 2011 at 11:36 AM, Gurunath Katagi wrote: > 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

Re: help in scripting

2011-04-16 Thread Uri Guttman
> "IG" == Ishwor Gurung writes: IG> [isg@tarzan:perl]# cat -n foo.pl don't post code with line numbers. then it can't be cut/pasted by others. IG> 1#!/usr/bin/env perl IG> 2use warnings; IG> 3use strict; IG> 4use Data::Dumper; IG> 5o

Re: help in scripting

2011-04-16 Thread Ishwor Gurung
Hi. On 16 April 2011 16:06, Gurunath Katagi wrote: > 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

Re: help in scripting

2011-04-15 Thread Shlomi Fish
On Saturday 16 Apr 2011 09:06:02 Gurunath Katagi wrote: > 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

help in scripting

2011-04-15 Thread Gurunath Katagi
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 ..