Hi -
> -----Original Message-----
> From: ktb [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, February 16, 2003 6:52 AM
> To: [EMAIL PROTECTED]
> Subject: help with (do $ENV{HOME})
>
>
> I've read the faq on "do" and looked around the web but can't discover
> what I'm doing wrong.
>
> I have a file named "text" with the following line it it -
> $name = "kent";
>
> My prog contains the following -
> #!/usr/bin/perl
> use diagnostics;
> use strict;
> use warnings;
>
> do "$ENV{HOME}/scratch/address_book/text";
> my $name;
> print "$name\n";
>
> The problem I'm having is my print statement just prints a new line
> without printing any text. It was my understanding that the "do"
> function would pull the scalars from "text" into my prog as if it was
> part of the program.
>
> What am I doing wrong?
> Thanks,
> kent
>
I think this type of 'do' reads the file and
evals it (you should check $@ to see if it evaled
OK). The eval returns whatever the script in the file
returns. So...
1) Change your file to contain only "kent";
2) load $name as follows:
my $name = do "$ENV{HOME}/scratch/address_book/text";
die "bad file (whatever): $@\n" if $@;
3) all done.
Aloha => Beau;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]