I have a problem with the following code.Can anybody help
The code may be wrong since I am still developing , but the error confuses me.
Here, I get Uninitaialized value in substitution(s///) in the following lines?Anybody Know why?use warnings; use strict; &readfile; sub readfile{ my $input_FL;my @file_row;my @row_text;my $row_data;my $row_text; my $line =0; my $status;my $soc; my $subscriber; my @ar_OR_STA;my @ar_OR_SOC;my @ar_OR_SUB; $input_FL = "C:\\taj.txt"; chomp $input_FL; #remove enter key or any spaces open(IN_FL, $input_FL) || die ("unable to open directory"); while (<IN_FL>){ @file_row=<IN_FL>; print $#file_row; }#while close IN_FL; foreach(@file_row) { while ($line < $#file_row +1){ $row_data =$file_row[$line]; chop ($row_data); next unless /\S/; # only use lines that contain +something else + than spaces #print "$row_data\n"; if ($row_data =~ /^[d]/) { $status = $row_text[0]; $status =~ s/(\W+)/ /gs; #Eliminate all non-+word charac +ters followed by space. #$ar_OR_STA[$i]=$status; #Here $=1, so @ar_STA[0] does no +t have any value. Original Array of Status push (@ar_OR_STA,$status); print "@ar_OR_STA\n"; $soc = $row_text[1]; $soc =~ s/(\W+)/ /; #Eliminate all non-word characters f +ollowed by space. #$ar_OR_SOC[$i-1]=$soc; #Here $=1, so @ar_STA[0] does no +t have any value. Original Array of Status $subscriber = $row_text[3]; $subscriber =~ s/(\D+)/ /; #Eliminate all non-digits foll +owed by space. #$ar_OR_SUB[$i-1]=$subscriber; #Here $=1, so @ar_SUB[0] +does not have any value.Original Array of Subscriber } else { print " File is invalid\n"; } $line++; }#while }#foeach }
and$status =~ s/(\W+)/ /gs; $soc =~ s/(\W+)/ /; $subscriber =~ s/(\D+)/ /;
Any help appreciateduse of initialized value in join or string at print "@ar_OR_STA\n";
In reply to Use of Uninitialized value in substitution (s///) by taj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |