mr_ego
09-03-2002, 12:56 PM
how would i open a text file and replace anything beginning with a dollar sign - $ - (to signal a variable) to the variable related subroutine.
EG: (with a variable)
script.pl --
$page = "hello";
#open the page, store to an array, close file
foreach (@array) {
@data = split(/\ /, $_);
foreach $data (@data) {
if (substr($data, 0, 1) eq "$") {
print eval($data);
} else {
print "$_ ";
}
}
}
how would i change this so that it runs subroutines instead of return variables
EG: (with a variable)
script.pl --
$page = "hello";
#open the page, store to an array, close file
foreach (@array) {
@data = split(/\ /, $_);
foreach $data (@data) {
if (substr($data, 0, 1) eq "$") {
print eval($data);
} else {
print "$_ ";
}
}
}
how would i change this so that it runs subroutines instead of return variables