corrumpu
01-18-2001, 02:37 AM
trying to pass in a search string for matching purposes and the references
to two arrays that will be used to store the results.. and + the array i want to search
ok...maybe this is crazy looking and there is a one line solution. new to perl, coming from a c background. any help is greatly appreciated. my main problem is that the arrays are are filled with nothing as if my assignment statements using push() do not work right.. thanx in advance
email or post
please no RTFM or general flaming cuz my code sux. i've alot of books/man pages, and i'm not a coding guru.
#i call it like this
&split($ext,\@ext_acc,\@ext_blo,@ipf_log);
#this is how i'm trying to use it
sub split {
my ($pattern,$temp1,$temp2) = shift(@_);
my $found;
print (@_);
foreach $_ (@_) {
if ($found =~ /$pattern/) {
push(@{$temp1},$_);
print "found $pattern\n";
}
else {
push(@{$temp2},$_);
print "didn't find $pattern\n";
}
}
for (my $j = 0; $j < 10; $j++) {
print $temp1->[$j];
}
}
EDIT: i can't get the indentions to take.. sorry.. my code isn't always LEFT justified : (
[This message has been edited by corrumpu (edited 18 January 2001).]
to two arrays that will be used to store the results.. and + the array i want to search
ok...maybe this is crazy looking and there is a one line solution. new to perl, coming from a c background. any help is greatly appreciated. my main problem is that the arrays are are filled with nothing as if my assignment statements using push() do not work right.. thanx in advance
email or post
please no RTFM or general flaming cuz my code sux. i've alot of books/man pages, and i'm not a coding guru.
#i call it like this
&split($ext,\@ext_acc,\@ext_blo,@ipf_log);
#this is how i'm trying to use it
sub split {
my ($pattern,$temp1,$temp2) = shift(@_);
my $found;
print (@_);
foreach $_ (@_) {
if ($found =~ /$pattern/) {
push(@{$temp1},$_);
print "found $pattern\n";
}
else {
push(@{$temp2},$_);
print "didn't find $pattern\n";
}
}
for (my $j = 0; $j < 10; $j++) {
print $temp1->[$j];
}
}
EDIT: i can't get the indentions to take.. sorry.. my code isn't always LEFT justified : (
[This message has been edited by corrumpu (edited 18 January 2001).]