mwill66 has asked for the wisdom of the Perl Monks concerning the following question:
\This code works while ( $line = <$fh>) { ($store, $quarter, $quarteryear, $dcount, $date, $status) = chompspl +it($line); my $key = $quarter . "," . $quarteryear ; $count{$key}++; } ############################### New code example of what i am trying to do, yes passing string in subr +outine $header = 'Total profit Submitted by Quarter'; $string = '$quarter . "," . $quarteryear' submain($header,$string); $header = 'Total loss Submitted by Quarter'; $string = $'quarter . "," . $quarteryear . "," $status' submain($header,$string); trying to use the string sub submain ($head,$str) { my ($head,$str) = @_; open my $fh, '<', $file or die "Could not open '$file' $!"; while ( $line = <$fh>) { ($store, $quarter, $quarteryear, $dcount, $date, $status) = chompspl +it($line); my $key = $str ; is this even possible, i remeber doing it in some + other language $count{$key}++; print $key; return; } Thanks for the help Michael
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: stuck on code
by GrandFather (Saint) on Apr 01, 2014 at 01:51 UTC | |
|
Re: stuck on code
by davido (Cardinal) on Apr 01, 2014 at 07:03 UTC | |
|
Re: stuck on code
by boftx (Deacon) on Apr 01, 2014 at 01:39 UTC |