jumper
10-11-2005, 01:48 PM
#!/usr/local/bin/perl -w
use strict;
my @fields = ();
my $line = 1;
my $pattern = "259775";
my $index = 0;
while (<>) {
@fields = $_;
# @fields = split/:/, $_;
}
#print @fields;
#print "@fields\n";
#print @fields."";
foreach $index (@fields) {
# print $fields[1], "\n";
print "element number $line is $index\n";
# if (/$pattern/) {
# print $line, " ", $_;
# }
$line = $line + 1;
# print "$_\n";
}
print $line, "\n";
this has gone a bit pete tong...
it was supposed to read a file [via a parameter at the command line] loop through the records, split the record into fields, search field(s) for string and print successful result or error message
I cannot even populate the array properly !
The latest output I have is
#output begin
element number 1 is
2
#output end
Is it overwriting itself ?
Is it just ignoring the array assignment ?
Are the print statements naff ?
tia,
use strict;
my @fields = ();
my $line = 1;
my $pattern = "259775";
my $index = 0;
while (<>) {
@fields = $_;
# @fields = split/:/, $_;
}
#print @fields;
#print "@fields\n";
#print @fields."";
foreach $index (@fields) {
# print $fields[1], "\n";
print "element number $line is $index\n";
# if (/$pattern/) {
# print $line, " ", $_;
# }
$line = $line + 1;
# print "$_\n";
}
print $line, "\n";
this has gone a bit pete tong...
it was supposed to read a file [via a parameter at the command line] loop through the records, split the record into fields, search field(s) for string and print successful result or error message
I cannot even populate the array properly !
The latest output I have is
#output begin
element number 1 is
2
#output end
Is it overwriting itself ?
Is it just ignoring the array assignment ?
Are the print statements naff ?
tia,