s_gaurav1091 has asked for the wisdom of the Perl Monks concerning the following question:
Now I am ryng to read this file and initialize some variables in my code but the variables are not getting initialized.Some problem is there with my logic..plz help me out..I am writting a sample code for your conviniennce$step1 1 $step2 1 $step3 1
the print statement in the if loops are not getting executed and that where my problem lies#!/usr/bin/perl my $step1; my $step2; my $step3; my @array1; my @array; my $i = 0; open(FILE, "assign"); $line = <FILE>; while ($line ne ""){ chomp($line); if($line =~ /^(\S+)\s+(\d+)$/) { print "inside\n"; $hash{$1} = $2; $i++; } $line = <FILE>; } while( ($key, $value) = each %hash) { print "$key +> $value\n"; $key = $value; } if($step1){ print "first\n"; } if($step2) { print "second\n"; } if($step3) { print "thisrd\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: reading from a file and initializing a variable
by davido (Cardinal) on Oct 04, 2005 at 07:01 UTC | |
Re: reading from a file and initializing a variable
by blazar (Canon) on Oct 04, 2005 at 07:58 UTC | |
Re: reading from a file and initializing a variable
by sk (Curate) on Oct 04, 2005 at 06:58 UTC | |
Re: reading from a file and initializing a variable
by gargle (Chaplain) on Oct 04, 2005 at 07:46 UTC |