My thoughts on how to grab all scalers and arrays out of perl file went along the lines of:
open (InFile, "SomeScript.pl");
@InArray = <InFile>;
@OutArray = {};
close (InFile);
$ArrayCount = @InArray;
open (OutFile, ">outfile.txt");
for ($x=0; $x<=$ArrayCount; $x++){
$Testline = @InArray[$x];
if($Testline =~ m/((@|\$)[A-Z]+)/i){
$Outline = "$1\n";
push @OutArray, $Outline;
}
}
print OutFile @OutArray;
close(OutFile);
...and this works fairly well. The problem is that if multiple variable appear on a line it will only grab the first variable. An example might be:
$FirstVar = $SecondVar + $ThirdVar;
The script would only grab $FirstVar and output to a file. This might still work though because $SecondVar and $ThirdVar have to be initialized somewhere else before the proceeding line has any meaning. I guess the exception to the rule would be a line in which multiple variables are initialized at the same time.
Can anyone think of an example in real perl code that would break this script? Also, can anyone show me how to grab multiple items that match my regular expression's criteria from the same line?
Thanks in advance!