Re: sub local variable changes global variable.

2011-10-15 Thread John W. Krahn
JPH wrote: Hi all, Hello, I am passin a two-dimensional array to a sub and when the sub returns, the original array has changed. Eventually I want to pass the array into a recursive sub, so I want to find a way to circumvent this behaviour. Notice how my global is "@a" and the sub local is "

Re: stuck and need some direction

2011-10-15 Thread Chris Stinemetz
Thank you everyone for your suggestions. They were very helpful! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: sub local variable changes global variable.

2011-10-15 Thread Shawn H Corey
On 11-10-15 07:44 PM, Rob Dixon wrote: sub try { my @b; foreach my $row (@_) { push @b, [@$row]; } : } Or you could use dclone() from Storable: use Storable qw( dclone ); sub try { my @b = @{ dclone( \@_ ) }; ... } Storable is a standard modul

Re: sub local variable changes global variable.

2011-10-15 Thread Rob Dixon
On 16/10/2011 00:08, JPH wrote: Hi all, I am passin a two-dimensional array to a sub and when the sub returns, the original array has changed. Eventually I want to pass the array into a recursive sub, so I want to find a way to circumvent this behaviour. Notice how my global is "@a" and the sub

Re: sub local variable changes global variable.

2011-10-15 Thread Paul Johnson
On Sun, Oct 16, 2011 at 01:08:19AM +0200, JPH wrote: > Hi all, > > I am passin a two-dimensional array to a sub and when the sub This is your main problem. Perl doesn't have two-dimensional arrays. What it does have is arrays of array references which, if you squint, can be used as two-dimensio

sub local variable changes global variable.

2011-10-15 Thread JPH
Hi all, I am passin a two-dimensional array to a sub and when the sub returns, the original array has changed. Eventually I want to pass the array into a recursive sub, so I want to find a way to circumvent this behaviour. Notice how my global is "@a" and the sub local is "@b" - Why is this hap

Re: stuck and need some direction

2011-10-15 Thread timothy adigun
Oopss my error! chomp $cell in the code above should be chomp $line. thanks

Re: stuck and need some direction

2011-10-15 Thread timothy adigun
> Hi Chris, > Check this if it helps. > > > #!\usr\bin\perl -w > use strict; > use Carp; > > > my( $Cell,$CBR,$CDM1,$CDM2,$CDM3,$TFU1,$TFU2,$CCU,$EVM,$TXAMP,$CTRM ) > > =('Cell','CBR','CDM1','CDM2','CDM3','TFU1','TFU2','CCU','EVM','TXAMP','CTRM'); > my $header='HR 17-21 HEH Report'; > >croak "

Re: stuck and need some direction

2011-10-15 Thread timothy adigun
Hi Chris, Check this if it helps. #!\usr\bin\perl -w use strict; use Carp; my( $Cell,$CBR,$CDM1,$CDM2,$CDM3,$TFU1,$TFU2,$CCU,$EVM,$TXAMP,$CTRM ) =('Cell','CBR','CDM1','CDM2','CDM3','TFU1','TFU2','CCU','EVM','TXAMP','CTRM'); my $header='HR 17-21 HEH Report'; croak "please, specify input fil

Re: stuck and need some direction

2011-10-15 Thread Leo Susanto
use strict; my %CELL; my %CELL_TYPE_COUNT; while (my $line = ) { if ($line =~ /CELL\s+(\d+)\s+(.+?),.+?HEH/) { # take CELL number into $1 and the information after the number (and before the first comma) into $2 $CELL{$1}{$2}++; $CELL_TYPE_COUNT{$2}++;

Re: stuck and need some direction

2011-10-15 Thread Leo Susanto
use strict; my %CELL; my %CELL_TYPE_COUNT; while (my $line = ) { if ($line =~ /CELL\s+(\d+)\s+(.+?),.+?HEH/) { # take CELL number into $1 and the information after the number (and before the first comma) into $2 $CELL{$1}{$2}++; $CELL_TYPE_COUNT{$2}++;

Re: stuck and need some direction

2011-10-15 Thread timothy adigun
Hi Chris, I really believe people would like to help here, but if no one can make head of what you posted, they may as well ignore your codes and call for help all together. Fine you have showed, what your raw data are, but please can you show how you want your output to look like? Because going by

Re: stuck and need some direction

2011-10-15 Thread Chris Stinemetz
On Sat, Oct 15, 2011 at 1:12 PM, Leo Susanto wrote: > Chris, You need to let us know what do you want the script to do, > believe me, writing the script is the easy part. > Okay I will try to clarify. For right now there is only one type of line that I am interested in from the input file. I wi

Re: stuck and need some direction

2011-10-15 Thread Leo Susanto
Chris, You need to let us know what do you want the script to do, believe me, writing the script is the easy part. > > But really I am probably speaking gibberish until you provide some > sample output. Especially it would be good to have other test cases -- > like what other cells would look like

Re: stuck and need some direction

2011-10-15 Thread Brock
On 2011.10.15.00.08, Chris Stinemetz wrote: > I am trying to create a Perl script that will scan a file using regex > to match certain patterns and return uniq names and the total count of > each match. > > With the sample input data (on the far bottom) the return value should > be CELL 20 in Colu

Re: stuck and need some direction

2011-10-15 Thread Brock
On 2011.10.15.00.08, Chris Stinemetz wrote: > My scripts thus far: > > heh.pl > #!/usr/bin/perl > > use warnings; > use strict; > requuire "heh.lib"; Couple things here -- "require" is spelled wrong. But also you have to say "heh.lib.pl". I will let someone else suggest that you organize this us