Re: use strict / nostrict

2011-07-14 Thread Paolo Gianrossi
2011/7/14 Shlomi Fish > Hi Marc, > > On Thu, 14 Jul 2011 07:18:55 -0700 > Marc wrote: > > > >> #!/usr/bin/perl > > >> use Text::CSV; > > >> use DBI; > > >> use Data::Dumper; > > > > > > There is no "use strict;" and "use warnings;" at the beginning of the > file: > > > > I see this quite a

Re: Help Parsing a Tab delimited file

2011-07-14 Thread C.DeRykus
On Jul 13, 11:17 pm, jwkr...@shaw.ca ("John W. Krahn") wrote: > C.DeRykus wrote: > >... > > That won't work as the shell will interpolate away the backslash: Not necessarily... it works on Win32's idea of a "shell" for instance :) But it doesn't hurt even there and is a good habit. > > $ echo

Re: help to print a hash with hash

2011-07-14 Thread Mohan L
#!/usr/bin/perl > use strict; > use warnings; > > my %data = ( > > south => { > status => { > open => { count => 3 }, > pws => { count => 3 }, > wip => { count => 0 }, > hold => { count => 1 }, > 're-open' => { count => 0 }, > pwu => { count => 0 }, > openesc => { count => 0 }, >

Re: use strict / nostrict

2011-07-14 Thread Shlomi Fish
Hi Marc, On Thu, 14 Jul 2011 07:18:55 -0700 Marc wrote: > >> #!/usr/bin/perl > >> use Text::CSV; > >> use DBI; > >> use Data::Dumper; > > > > There is no "use strict;" and "use warnings;" at the beginning of the file: > > I see this quite a bit on this list (and elsewhere) and I think it

Re: help to print a hash with hash

2011-07-14 Thread Dr.Ruud
On 2011-07-14 14:09, Mohan L wrote: I am trying some thing like to print : foreach my $line (keys %region_data) { print "$line\n"; foreach my $item (keys %{$region_data {$line}}) { print "$item\n"; } } Output : south status total_count north status total_coun

Re: summarise input data using Perl

2011-07-14 Thread Leo Susanto
On Thu, Jul 14, 2011 at 2:36 AM, Shlomi Fish wrote: > Hi Leo, > > I'm commenting on your code below because it exhibits some bad elements. > > On Wed, 13 Jul 2011 11:00:33 -0700 > Leo Susanto wrote: > >> #!/usr/bin/perl >> use Text::CSV; >> use DBI; >> use Data::Dumper; > > There is no "use stric

Re: use strict / nostrict

2011-07-14 Thread Shawn H Corey
On 11-07-14 10:18 AM, Marc wrote: If these pragmas are as important as they are, why is it that they aren't turned on in Perl by default? How about if we make them the default settings in 5.16 and then add "use nostrict;" and "use nowarnings;" for when someone wants to turn them off? For bac

use strict / nostrict

2011-07-14 Thread Marc
>> #!/usr/bin/perl >> use Text::CSV; >> use DBI; >> use Data::Dumper; > > There is no "use strict;" and "use warnings;" at the beginning of the file: I see this quite a bit on this list (and elsewhere) and I think it's very good advice, so this morning I got to thinking. If these pragma

help to print a hash with hash

2011-07-14 Thread Mohan L
Dear All, I have a hash %region_data which looks like : $VAR1 = { 'south' => { 'status' => { 'open' => { 'count' => 3 },

Re: Help Parsing a Tab delimited file

2011-07-14 Thread Dr.Ruud
On 2011-07-14 08:17, John W. Krahn wrote: You have to quote it: $ echo "one two three four" | perl -F'\t' -lane'print "$_: $F[$_]" for 0 .. $#F' 0: one 1: two 2: three 3: four Or double it: echo -e "a\tb\tc\td" |perl -F\\t -lane'print"$_: $F[$_]"for 0..$#F' 0: a 1: b 2: c 3: d -- Ruud --

Re: summarise input data using Perl

2011-07-14 Thread Shlomi Fish
Hi Leo, I'm commenting on your code below because it exhibits some bad elements. On Wed, 13 Jul 2011 11:00:33 -0700 Leo Susanto wrote: > Mohan, > > I would suggest you learning perl hash: http://perl101.org/hashes.html > Also see: http://perl-begin.org/topics/hashes/ > #!/usr/bin/perl > us

Re: summarise input data using Perl

2011-07-14 Thread Mohan L
> > Sorry, I messed some thing. Can you please explain the code? . You > explanation will give more idea to learn the below hash usage. > >> >> my @regions = ('east','north','south','west'); >> my @statuses_string = ('pws','open','hold','pwu','reopen'); >> my %region_data; >> foreach my $region (@

Re: summarise input data using Perl

2011-07-14 Thread Mohan L
On Wed, Jul 13, 2011 at 11:30 PM, Leo Susanto wrote: > Mohan, > > I would suggest you learning perl hash: http://perl101.org/hashes.html > Yes. I will learn the perl hash. > > #!/usr/bin/perl > use Text::CSV; > use DBI; > use Data::Dumper; > > # CONFIG VARIABLES > ... > # DATA SOURCE NAME > ..