--- Pete Emerson <[EMAIL PROTECTED]> wrote:

There is a hackish tendancy when referring to the 'use' keyword
to use the form:

use confusion;

why?  Because it is Perl's way of loading modules - this would
be a pragma (like strict and warnings).  Of course, we need to
get you to use:

no confusion;

Anyway, to the subject itself:

> The following example does what is expected, i.e. prints out the word
> password on its own line.
> 
> used.pm
> -------
> $password='password';
> 
> use.pl
> ------
> #!/usr/bin/perl
> 
> require "./used.pm";
> print "$password\n";
> 
> However, as soon as I turn on warnings and strict, and declare
> $password:
> #!/usr/bin/perl -w
> use strict;
> my $password;
> require "./used.pm";
> print "$password\n";

If you are willing to turn used.pm into a proper package, then it
will work much better.  In the form:

used.pm
-------

package Used;

$password = "password";

--

Then you can just use it by:

use used;

print $used::password . "\n";

===

Alternatively, open the file in the normal way and eval the
contents having first declared the variable $password.  I.e.

#!/usr/bin/perl -w

use strict;

my $password;
open USER, "user.pm" or die "Open failed: $!";
{
    local $/ = undef; # Slurp mode
    eval <USER>;      # Execute
}
close USER or warn "Close failed: $!";

print $password;


===

Hows that? :)

Jonathan Paton

=====
$_=q|.,&@$$. ,.@$&@$. .&$$@. ,,$ ....!$_=$p.'&$@.',y'&$@' .,';for(/\S+/g){
!|.q| .$ .,@, ,$, .,.. @, ,$ ,,@ .,,.!++$.<22?${'y'.$_}=chr$.+64:[$$=${'y'
!|.q| ,@$@&.,. $$$&, ..@&&$,,, $., ..!.$_},$y.=($.=~/22\|26\|3(3\|7)/x?' '
!|.q|. @  ., ,.&,,, , .$..&. .,$  .,,!.$$:"\l$$")]};$y=~/ (.*)/;warn"$1\n"
!|.q|. $ .,. .,$$&&$...&., @.,.&@$@ .|,map{-$|--?$r:$p.=$_}split'!';eval$r

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to