davidov0009 has asked for the wisdom of the Perl Monks concerning the following question:
Program that calls on the subsub ReadFile { #Declare Variables # my ($game, $file) = @_; my $dir = "$ENV{HOME}/settings/$game/$file"; #End if dir not exist # return unless -d $dir; #Read the file and create the array # open(FILE, $dir)||die("Cannot open file : $!"); my @contents = <FILE>; close(FILE); #Cut trailing \n # chomp (@contents); #Return the array # return @contents; }
Here are the Errors when I don't quote the strings...#!/usr/bin/perl5 use strict; use warnings; use HLDS; my @games = HLDS::ReadFile(HL1, HL1.txt); foreach my $game (@games) { print "$game\n"; }
Any thoughts...Bareword "HL1" not allowed while "strict subs" in use at ./games.pl li +ne 8. Bareword "HL1" not allowed while "strict subs" in use at ./games.pl li +ne 8. Bareword "txt" not allowed while "strict subs" in use at ./games.pl li +ne 8. Execution of ./games.pl aborted due to compilation errors (#1) Uncaught exception from user code: Bareword "HL1" not allowed while "strict subs" in use at ./gam +es.pl line 8. Bareword "HL1" not allowed while "strict subs" in use at ./games.pl li +ne 8. Bareword "txt" not allowed while "strict subs" in use at ./games.pl li +ne 8. Execution of ./games.pl aborted due to compilation errors.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sub strict refs errors.
by cephas (Pilgrim) on Oct 03, 2006 at 00:33 UTC | |
|
Re: sub strict refs errors.
by grep (Monsignor) on Oct 03, 2006 at 00:34 UTC | |
|
Re: sub strict refs errors.
by GrandFather (Saint) on Oct 03, 2006 at 00:39 UTC | |
by davidov0009 (Scribe) on Oct 03, 2006 at 01:16 UTC |