dvergin has asked for the wisdom of the Perl Monks concerning the following question:
Each file (except the bottom ones) contains a 'use LayerX.pm' (or whatever) line near the top. The development files of course each say 'use LayerX2.pm'.MainProg.pl LayerA.pm LayerB.pm LayerC.pm MainProg2.pl LayerA2.pm LayerB2.pm LayerC2.pm
When I shift the development version of a file or two over to the production set, I just drop the '2' from the file name and adjust the 'use ...' line. This works fine. But it's a nuisance and occasionally I flub it.
So I'd like to read the name of the current file, check for a '2' in the filename and then 'use ...' the appropriate next lower module.
'use' requires a bareword, so I can't say 'use LayerB$version'. What are the implications of:
Is there any downside to this? Seems like there are likely some compile-time vs. run-time issues.if ($version == 2) { use LayerB2; } else { use LayerB; }
Is there some other recommended method?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conditional use of 'use'
by bikeNomad (Priest) on Jun 12, 2001 at 09:04 UTC | |
by dvergin (Monsignor) on Jun 12, 2001 at 09:08 UTC | |
by chromatic (Archbishop) on Jun 12, 2001 at 20:05 UTC | |
by tye (Sage) on Jun 12, 2001 at 22:41 UTC | |
|
Re: Conditional use of 'use'
by pmas (Hermit) on Jun 12, 2001 at 09:13 UTC | |
|
Re: Conditional use of 'use'
by busunsl (Vicar) on Jun 12, 2001 at 10:33 UTC | |
|
(tye)Re: Conditional use of 'use'
by tye (Sage) on Jun 12, 2001 at 19:53 UTC | |
|
Re: Conditional use of 'use'
by jepri (Parson) on Jun 12, 2001 at 10:11 UTC |