
Stefanik
User
Dec 30, 2012, 7:27 AM
Views: 2375
|
|
Re: [Stefanik] Match string in multi-line file
|
|
|
I've added the strings at the begin, with following error:
Global symbol "$FileToParse" requires explicit package name at BatchParser.pl line 8. Global symbol "$FileParsed" requires explicit package name at BatchParser.pl line 11. Global symbol "$FileToParse" requires explicit package name at BatchParser.pl line 29. .... Execution of C:\Users\ADS\Desktop\Perl_Test\BatchParser.pl aborted due to compil ation errors. So, I expilcit the input file in the same block command of my execution code (I don't have different function, just a serie of line code). In this way I get following errors:
Global symbol "$FileTemp" requires explicit package name at BatchParser_2.pl line 7. Global symbol "$FileTemp" requires explicit package name at BatchParser_2.pl line 8. syntax error at BatchParser_2.pl line 8, near "){" Global symbol "$FileTemp" requires explicit package name at BatchParser_2.pl line 9. Global symbol "$FileTemp" requires explicit package name at BatchParser_2.pl line 10. syntax error at BatchParser_2.pl line 12, near "}" Execution of BatchParser_2.pl aborted due to compilation errors. And I don't understand the reason. Here the code:
use strict; use warnings FATAL => qw(all); my $FileToParse="C:/Users/Me/Desktop/Perl_Test/temp/File.log"; open (PARSEFILE, "<", $FileToParse) or die "No file!!!"; $FileTemp="x" while ($FileTemp = <PARSEFILE>){ $FileTemp =~ s/:/\n/g; my $value1 = (/^STRING,\w+(\w+)/), $FileTemp; print $value1; } close (PARSEFILE);
(This post was edited by Stefanik on Dec 30, 2012, 7:29 AM)
|