polka4ever
Technical User
Hello,
I am getting incorrect results and I am a newbie - so if you have any ideas, I would greatly appreciate the help!
here is what I have:
#!/usr/local/bin/perl
for (<suspec*.data>)
{ open(INFO, $_) or die "Can't open input file: $!";
while (<INFO>){
chomp;
my $small_string = substr ($_, 209, 6); # this is the houseNumber field
if ($small_string = '844')
{print "$small_string\n";
}
}
close INFO;
}
Basically - I'm running this on Unix - and in the suspec*.data files (which are just two files) I have a total of 11 rows of data. Only ONE row - actually matches the condition of the house number field is equal to '844' BUT - when I run this script, the # 844 is printed 11 times to my screen! What am i doing wrong?
Also - how can i redirect the output of this to a file (instead of to my screen) and also - i'd like to put the whole ROW in my output (not just the substr part) as well as which file it came from. Can anyone help with this?
Thank you!
~Polka
p.s. Happy mardi gras to everyone! (Fat Tuesday/Paczki Day)
I am getting incorrect results and I am a newbie - so if you have any ideas, I would greatly appreciate the help!
here is what I have:
#!/usr/local/bin/perl
for (<suspec*.data>)
{ open(INFO, $_) or die "Can't open input file: $!";
while (<INFO>){
chomp;
my $small_string = substr ($_, 209, 6); # this is the houseNumber field
if ($small_string = '844')
{print "$small_string\n";
}
}
close INFO;
}
Basically - I'm running this on Unix - and in the suspec*.data files (which are just two files) I have a total of 11 rows of data. Only ONE row - actually matches the condition of the house number field is equal to '844' BUT - when I run this script, the # 844 is printed 11 times to my screen! What am i doing wrong?
Also - how can i redirect the output of this to a file (instead of to my screen) and also - i'd like to put the whole ROW in my output (not just the substr part) as well as which file it came from. Can anyone help with this?
Thank you!
~Polka
p.s. Happy mardi gras to everyone! (Fat Tuesday/Paczki Day)