J
jake1138
Can anyone explain this to me?
This works:
while(<FILE>) {
chop;
if (/^int config_write\s*\(.*\)\s*[^;]?\s*$/i) {
print "$_\n";
}
if (/^int config_read\s*\(.*\)\s*[^;]?\s*$/i) {
print "$_\n";
}
}
But this doesn't (only matches the first string "int_config_read"):
while(<FILE>) {
chop;
for my $func_def ("int config_read", "int config_write") {
if (/^$func_def\s*\(.*\)\s*[^;]?\s*$/i) {
print "$_\n";
}
}
}
If I reverse the strings...
for my $func_def ("int config_write", "int config_read") {
....it matches "int config_write" and not "int config_read".
I'm really confused because it does indeed process both strings if I
use code like this:
for my $func_def ("int config_read", "int config_write") {
print "$func_def\n";
}
This works:
while(<FILE>) {
chop;
if (/^int config_write\s*\(.*\)\s*[^;]?\s*$/i) {
print "$_\n";
}
if (/^int config_read\s*\(.*\)\s*[^;]?\s*$/i) {
print "$_\n";
}
}
But this doesn't (only matches the first string "int_config_read"):
while(<FILE>) {
chop;
for my $func_def ("int config_read", "int config_write") {
if (/^$func_def\s*\(.*\)\s*[^;]?\s*$/i) {
print "$_\n";
}
}
}
If I reverse the strings...
for my $func_def ("int config_write", "int config_read") {
....it matches "int config_write" and not "int config_read".
I'm really confused because it does indeed process both strings if I
use code like this:
for my $func_def ("int config_read", "int config_write") {
print "$func_def\n";
}