
lukdk
Novice
Jun 19, 2012, 4:05 AM
Post #1 of 9
(784 views)
|
|
can't # out code or the script fails to run
|
Can't Post
|
|
Hello, I was wondering how it is possible adding a #-sign can break this script? working code: foreach my $computer (MOlib::read_file("input.txt")){ $computer=MOlib::trim($computer); } Not working code: foreach my $computer (MOlib::read_file("input.txt")){ $computer=MOlib::trim($computer); # } This is the error i get: Missing right curly or square bracket at test.pl line 1, at end of line syntax error at test.pl line 1, at EOF Execution of test.pl aborted due to compilation errors. This is the code for the MOlib: sub read_file{ my $read_file=shift; open (FILE, "<$read_file") or die "Can't open $read_file: $!\n"; my @file = <FILE>; close FILE; return @file; } sub trim{ my $str=shift; return "" if !defined $str; $str=~s/^\s+//; $str=~s/\s+$//; return ($str); }
(This post was edited by lukdk on Jun 19, 2012, 7:16 AM)
|