drodinthe559 has asked for the wisdom of the Perl Monks concerning the following question:
open TESTFILE, "Y:/Perl Projects/TEST" or die "Couldn't open Test Repo +rt file: $!"; my ($variable1, $variable2); my @return_details, while (my $test = <TESTFILE>) { #if i delcare the variable here it will re-inialize it next tim +e it loops through to an undef. next if ($returns =~ m/^(\s)*$/); print $returns; if (substr($test , 80, 26) =~ m/1ST VARIABLE/) { $variable1 = substr($returns, 113, 18); next; }; if (substr($test , 80, 25) =~ m/2ND VARIABLE/) { $variable2 = substr($test, 113, 18); $rt_flg = 1; }; if ($rt_flg eq 1) { push @return_details, { variable1 => $variable1, variable2 => $variable2 }; $rt_flg = 0; }; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Declare Variable in Loop
by ikegami (Patriarch) on Mar 26, 2010 at 22:22 UTC | |
by drodinthe559 (Monk) on Mar 26, 2010 at 22:27 UTC | |
by ikegami (Patriarch) on Mar 26, 2010 at 22:31 UTC | |
by drodinthe559 (Monk) on Mar 26, 2010 at 22:39 UTC | |
by ikegami (Patriarch) on Mar 26, 2010 at 22:45 UTC | |
by Anonymous Monk on Mar 26, 2010 at 22:41 UTC | |
|
Re: Declare Variable in Loop
by ikegami (Patriarch) on Mar 26, 2010 at 22:29 UTC | |
|
Re: Declare Variable in Loop
by Anonymous Monk on Mar 26, 2010 at 21:59 UTC |