Re: OT: use problem (need interpolation)
On Thu, 28 Sep 2000, Jerrad Pierce wrote: Is there anyway to fool perl into letting you do a: use Foo ($bar, 'baz', 'quux'); ?? Foo is only getting 'baz' and 'quux', the value of $bar is lost in the ether. I have tried many ways of trying to sneak it past but none seems to work... use is syntactically equiavalent to BEGIN { require Foo; Foo-import(@argarray); } so $baz will need to be defined at compile time, ie. within its own BEGIN block. MBM -- Matthew Byng-Maddick Home: [EMAIL PROTECTED] +44 20 8981 8633 (Home) http://colondot.net/ Work: [EMAIL PROTECTED] +44 7956 613942 (Mobile) Genius may have its limitations, but stupidity is not thus handicapped. -- Elbert Hubbard
Re: OT: use problem (need interpolation)
From: Jerrad Pierce [EMAIL PROTECTED] Is there anyway to fool perl into letting you do a: use Foo ($bar, 'baz', 'quux'); 'use' lines are executed very early on during script loading: use Foo x y z is roughly equivalent to BEGIN { require Foo; import Foo x y z } so $bar is likely to be undefined unless you also set it in a BEGIN section, eg BEGIN { $bar = } use Foo ($bar, 'baz', 'quux'); or use 'require' instead of 'use' if you can tolerate the module being loaded late, eg $bar = ; require Foo; import Foo ($bar, 'baz', 'quux'); * Dave Mitchell, Operations Manager, * Fretwell-Downing Facilities Ltd, UK. [EMAIL PROTECTED] * Tel: +44 114 281 6113.The usual disclaimers * * Standards (n). Battle insignia or tribal totems
RE: OT: use problem (need interpolation)
Thanks... as It turns out I had to use both a BEGIN{} to set the variables and an eval{} around the use (don't ask, it's some rather ugly stuff...). autouse wasn't quite whta I needed (the module I'm using contains no functions, just a big hash) -Original Message- From: David Mitchell [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 28, 2000 10:53 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: OT: use problem (need interpolation) From: Jerrad Pierce [EMAIL PROTECTED] Is there anyway to fool perl into letting you do a: use Foo ($bar, 'baz', 'quux'); 'use' lines are executed very early on during script loading: use Foo x y z is roughly equivalent to BEGIN { require Foo; import Foo x y z } so $bar is likely to be undefined unless you also set it in a BEGIN section, eg BEGIN { $bar = } use Foo ($bar, 'baz', 'quux'); or use 'require' instead of 'use' if you can tolerate the module being loaded late, eg $bar = ; require Foo; import Foo ($bar, 'baz', 'quux'); * Dave Mitchell, Operations Manager, * Fretwell-Downing Facilities Ltd, UK. [EMAIL PROTECTED] * Tel: +44 114 281 6113.The usual disclaimers * * Standards (n). Battle insignia or tribal totems