Prev: FAQ 9.9 How do I automate an HTML form submission?
Next: FAQ 6.12 Can I use Perl regular expressions to match balanced text?
From: John on 14 Jan 2010 08:46 Hi I've changed use Socket; to require Socket; in a subroutine since I use it infrequently I'm getting the error message Bareword "AF_INET" not allowed while "strict subs" What have I done? Regards John
From: J�rgen Exner on 14 Jan 2010 09:04 "John" <john1949(a)yahoo.com> wrote: >I've changed >use Socket; >to >require Socket; > >in a subroutine since I use it infrequently > >I'm getting the error message > >Bareword "AF_INET" not allowed while "strict subs" > >What have I done? Isn't that obvious? You changed use Socket; to require Socket; ;-)) Seriously, you are missing the import() part of use(), see perldoc -f use jue
From: John on 14 Jan 2010 09:25 "J�rgen Exner" <jurgenex(a)hotmail.com> wrote in message news:1v8uk51i808hfbe9f7h9atf577fa98eokn(a)4ax.com... > "John" <john1949(a)yahoo.com> wrote: >>I've changed >>use Socket; >>to >>require Socket; >> >>in a subroutine since I use it infrequently >> >>I'm getting the error message >> >>Bareword "AF_INET" not allowed while "strict subs" >> >>What have I done? > > Isn't that obvious? You changed > use Socket; > to > require Socket; > ;-)) > > Seriously, you are missing the import() part of use(), see > perldoc -f use > > jue I've added Socket->import(); but same error - John
From: J�rgen Exner on 14 Jan 2010 09:36 "John" <john1949(a)yahoo.com> wrote: >"J�rgen Exner" <jurgenex(a)hotmail.com> wrote in message >> "John" <john1949(a)yahoo.com> wrote: >>>I've changed >>>use Socket; >>>to >>>require Socket; >>> >>>in a subroutine since I use it infrequently >>> >>>I'm getting the error message >>> >>>Bareword "AF_INET" not allowed while "strict subs" >>> >>>What have I done? >> >> Isn't that obvious? You changed >> use Socket; >> to >> require Socket; >> ;-)) >> >> Seriously, you are missing the import() part of use(), see >> perldoc -f use > >I've added Socket->import(); but same error - John Oh, yeah, of course, sorry. The "Bareword ..." message is a compile time error while the require/import would be done at run time, i.e. way later. Not sure what to do about it, I'm not familiar with Socket or what AF_INET is. I guess maybe you could use a fully qualified name. jue
From: Uri Guttman on 14 Jan 2010 09:42
>>>>> "JE" == J�rgen Exner <jurgenex(a)hotmail.com> writes: JE> "John" <john1949(a)yahoo.com> wrote: >> I've added Socket->import(); but same error - John JE> Oh, yeah, of course, sorry. The "Bareword ..." message is a compile time JE> error while the require/import would be done at run time, i.e. way JE> later. JE> Not sure what to do about it, I'm not familiar with Socket or what JE> AF_INET is. I guess maybe you could use a fully qualified name. AF_INET is a constant that shouldn't be needed in common socket code. he should be using IO::Socket instead which has a better API and less need of obscure constants. the OP should post the whole section of code with the socket stuff. and if he does need it, he can't do require and even import since the import has to be done at compile time for the constant to be declare properly and then parsed that way in his code. putting the import into a BEGIN would only help if the module were also loaded there but that becomes use again. another solution is to move all the code that involves the socket stuff to its own module, call use Socket in there, and load his module on demand. uri -- Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- |