[32781] in Perl-Users-Digest
Perl-Users Digest, Issue: 4045 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 27 18:09:50 2013
Date: Fri, 27 Sep 2013 15:09:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 27 Sep 2013 Volume: 11 Number: 4045
Today's topics:
perl hash utilities <cal@example.invalid>
Re: perl hash utilities <ben.usenet@bsb.me.uk>
Re: perl hash utilities <cal@example.invalid>
Re: perl hash utilities <uri@stemsystems.com>
Re: perl hash utilities <ben.usenet@bsb.me.uk>
Re: perl hash utilities <cal@example.invalid>
Re: perl hash utilities <gravitalsun@hotmail.foo>
Re: perl hash utilities <uri@stemsystems.com>
Re: perl hash utilities <uri@stemsystems.com>
Re: perl hash utilities <ben@morrow.me.uk>
Re: perl hash utilities <derykus@gmail.com>
Re: perl hash utilities <cal@example.invalid>
Re: perl hash utilities <cal@example.invalid>
Re: perl hash utilities <ben@morrow.me.uk>
Re: perl hash utilities <glex_no-spam@qwest-spam-no.invalid>
Re: utilities in perl <glex_no-spam@qwest-spam-no.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Sep 2013 08:53:37 -0700
From: Cal Dershowitz <cal@example.invalid>
Subject: perl hash utilities
Message-Id: <CpWdnYk_MIocxdnPnZ2dnUVZ_qCdnZ2d@supernews.com>
I've been trying to break up perl tasks into smaller parts and have
taken something that used to work and now have it unable to pass data
properly:
$ perl config1.pl
Global symbol "$domain" requires explicit package name at config1.pl
line 14.
Global symbol "$domain" requires explicit package name at config1.pl
line 15.
Execution of config1.pl aborted due to compilation errors.
$ cat config1.pl
#!/usr/bin/perl -w
use strict;
my %domain;
my $ref_to_domain = \%domain;
sub get_config{
my $my_ftp = shift;
print "my ftp is $my_ftp\n";
my $ident = 'template_stuff/ident.txt';
my $config = do($ident);
unless ($config) {
die("read error: $!") if $!;
die("parse error: $@") if $@;
}
$domain = $config->{$my_ftp};
die("unknown domain: $!") unless $domain;
return $ref_to_domain;
}
sub show_hash{
my $href = shift;
my $ref_type = ref $href;
warn "expected hash ref\n" unless $ref_type eq 'HASH';
for my $key (keys %{$href}) {
print "$key => ${$href}{$key}\n";
}
}
get_config("my_ftp");
show_hash($ref_to_domain);
$
ident.txt is where it needs to be and is populated like this:
{
my_ftp => {
domain => 'www.merrillpjensen.com',
username => 'u63457',
password => 'mnbvvdfgcxz5',
},
site => {
domain => 'http://translate.google.com/',
language => 'russian',
word => 'north',
},
}
I define the domain hash at the getgo for this one, and it seems to be
out of scope in the subroutine. What do I need to do to fix this? Let
me state it another way.
$domain = $config->{$my_ftp};
Why does this not assign to %domain in the subroutine?
Thanks for your comment.
--
Cal
------------------------------
Date: Thu, 26 Sep 2013 17:16:48 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: perl hash utilities
Message-Id: <0.c12fc77d7844c9234240.20130926171648BST.87k3i3eexb.fsf@bsb.me.uk>
Cal Dershowitz <cal@example.invalid> writes:
> I've been trying to break up perl tasks into smaller parts and have
> taken something that used to work and now have it unable to pass data
> properly:
>
> $ perl config1.pl
> Global symbol "$domain" requires explicit package name at config1.pl
> line 14.
> Global symbol "$domain" requires explicit package name at config1.pl
> line 15.
> Execution of config1.pl aborted due to compilation errors.
> $ cat config1.pl
> #!/usr/bin/perl -w
> use strict;
> my %domain;
> my $ref_to_domain = \%domain;
> sub get_config{
> my $my_ftp = shift;
> print "my ftp is $my_ftp\n";
> my $ident = 'template_stuff/ident.txt';
> my $config = do($ident);
> unless ($config) {
> die("read error: $!") if $!;
> die("parse error: $@") if $@;
> }
> $domain = $config->{$my_ftp};
$domain is not the same as %domain (one's a scalar, the other is a
hash). What did you want this line to do to %domain? What keys/values
in the hash did you want it to set or alter?
<snip>
--
Ben.
------------------------------
Date: Thu, 26 Sep 2013 10:01:43 -0700
From: Cal Dershowitz <cal@example.invalid>
Subject: Re: perl hash utilities
Message-Id: <FIGdnbl0wa_q9dnPnZ2dnUVZ_q-dnZ2d@supernews.com>
On 09/26/2013 09:16 AM, Ben Bacarisse wrote:
> Cal Dershowitz <cal@example.invalid> writes:
>
>> I've been trying to break up perl tasks into smaller parts and have
>> taken something that used to work and now have it unable to pass data
>> properly:
>>
>> $ perl config1.pl
>> Global symbol "$domain" requires explicit package name at config1.pl
>> line 14.
>> Global symbol "$domain" requires explicit package name at config1.pl
>> line 15.
>> Execution of config1.pl aborted due to compilation errors.
>> $ cat config1.pl
>> #!/usr/bin/perl -w
>> use strict;
>> my %domain;
>> my $ref_to_domain = \%domain;
>> sub get_config{
>> my $my_ftp = shift;
>> print "my ftp is $my_ftp\n";
>> my $ident = 'template_stuff/ident.txt';
>> my $config = do($ident);
>> unless ($config) {
>> die("read error: $!") if $!;
>> die("parse error: $@") if $@;
>> }
>> $domain = $config->{$my_ftp};
>
> $domain is not the same as %domain (one's a scalar, the other is a
> hash). What did you want this line to do to %domain? What keys/values
> in the hash did you want it to set or alter?
>
> <snip>
>
I'm trying to mimic the thing I had before that works just fine, but
rambled on forever at top scope:
## usage needs 1 arg from argv my_ftp
#identity and config
my $ident = 'ident.txt';
my ( $config, $domain );
$config = do($ident);
unless ($config) {
die("read error: $!") if $!;
die("parse error: $@") if $@;
}
$domain = $config->{ $ARGV[0] };
die("unknown domain: $ARGV[0]") unless $domain;
Now, we're not supplying anything from argv.
my_ftp => {
domain => 'www.tyui.com',
username => 'sdfkgkdfj',
password => 'alisjflasjf',
},
So I'm looking to suck in these key/value pairs in a manner that
reflects the proper use of scoping and references. One thing that
screams out now is that I want the hash to have a different name than
any of its keys.
So what I'm looking to have at the end of this great endeavor is
2) a hash with the following values:
domain => 'www.tyui.com',
username => 'sdfkgkdfj',
password => 'alisjflasjf',
, and a reference to pass it around to see if I can print the darn thing.
--
Cal
------------------------------
Date: Thu, 26 Sep 2013 13:21:19 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: perl hash utilities
Message-Id: <87mwmzv6r4.fsf@stemsystems.com>
>>>>> "CD" == Cal Dershowitz <cal@example.invalid> writes:
CD> sub get_config{
CD> my $my_ftp = shift;
CD> print "my ftp is $my_ftp\n";
sub code should be indented. i can't read this at all. you write code
for the reader, not yourself.
CD> my $ident = 'template_stuff/ident.txt';
CD> my $config = do($ident);
first time i have seen do( file ) in ages. you might be better off
slurping in yourself and calling eval on it. same results with better
control.
CD> unless ($config) {
CD> die("read error: $!") if $!;
CD> die("parse error: $@") if $@;
you can't have $! as you didn't do a system call yourself. it may be set
and left over which is bogus. if the do fails it will die and you won't
even get to that code.
CD> }
CD> $domain = $config->{$my_ftp};
CD> die("unknown domain: $!") unless $domain;
why are you printing $! there? you are just checking a value. that can't
set $! which is only set by system calls. wasteful and misleading.
CD> $domain = $config->{$my_ftp};
CD> Why does this not assign to %domain in the subroutine?
$domain and %domain are separate variables. don't confuse $domain{foo}
which is a hash access with $domain which is a scalar variable.
uri
------------------------------
Date: Thu, 26 Sep 2013 19:27:35 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: perl hash utilities
Message-Id: <0.717efa86a21394c8d29e.20130926192735BST.87eh8be8vc.fsf@bsb.me.uk>
Cal Dershowitz <cal@example.invalid> writes:
<snip>
> So what I'm looking to have at the end of this great endeavor is
> 2) a hash with the following values:
> domain => 'www.tyui.com',
> username => 'sdfkgkdfj',
> password => 'alisjflasjf',
> , and a reference to pass it around to see if I can print the darn thing.
If $href holds a reference to a hash, then $href->{'domain'} =
'www.tyui.com' will set the 'domain' key in the hash referenced by
$href. So for a sub called like this:
my %domain;
...
fill_me_in(\%domain);
the body would be something along the lines of
sub fill_me_in
{
my $href = shift;
...
$href->{'domain'} = '...';
$href->{$some_key} = $some_value;
...
}
--
Ben.
------------------------------
Date: Thu, 26 Sep 2013 11:39:52 -0700
From: Cal Dershowitz <cal@example.invalid>
Subject: Re: perl hash utilities
Message-Id: <7vqdncbdTIXl4tnPnZ2dnUVZ_qudnZ2d@supernews.com>
On 09/26/2013 10:21 AM, Uri Guttman wrote:
>>>>>> "CD" == Cal Dershowitz <cal@example.invalid> writes:
>
> CD> sub get_config{
> CD> my $my_ftp = shift;
> CD> print "my ftp is $my_ftp\n";
>
> sub code should be indented. i can't read this at all. you write code
> for the reader, not yourself.
ok.
>
>
> CD> my $ident = 'template_stuff/ident.txt';
> CD> my $config = do($ident);
>
> first time i have seen do( file ) in ages. you might be better off
> slurping in yourself and calling eval on it. same results with better
> control.
I think I'm getting pretty close, as you see below.
>
>
> CD> unless ($config) {
> CD> die("read error: $!") if $!;
> CD> die("parse error: $@") if $@;
>
> you can't have $! as you didn't do a system call yourself. it may be set
> and left over which is bogus. if the do fails it will die and you won't
> even get to that code.
I won't be sad to see these lines disappear from my scripts going
forward at all.
>
>
> CD> }
> CD> $domain = $config->{$my_ftp};
> CD> die("unknown domain: $!") unless $domain;
>
> why are you printing $! there? you are just checking a value. that can't
> set $! which is only set by system calls. wasteful and misleading.
same comment.
>
> CD> $domain = $config->{$my_ftp};
>
> CD> Why does this not assign to %domain in the subroutine?
>
> $domain and %domain are separate variables. don't confuse $domain{foo}
> which is a hash access with $domain which is a scalar variable.
>
> uri
>
The word domain was overloaded in a way that barely made sense to me. I
believe what I endeavor to do here is called auto-vivification. I'm not
sure what separate the auto- version of it from the garden-variety
vivifying, but that goes precisely to my question as to how the hash
should appear in ident1.txt. To my eye, it looks like the treatments
I've seen.
$ perl config2.pl
YAML::XS::Load Error: The problem:
did not find expected ',' or '}'
was found at document: 1, line: 2, column: 16
while parsing a flow mapping at line: 1, column: 1
$ cat template_stuff/ident1.txt
{
my_ftp = {
domain => 'fakename',
username => 'fakeuser',
password => 'fakepass',
},
yoursky = {
domain => 'http://www.fourmilab.ch/yoursky/',
language => 'russian',
word => 'north',
},
}
$ cat config2.pl
#!/usr/bin/perl -w
use strict;
use File::Slurp;
use YAML::XS;
use Data::Dumper;
my $ident = 'template_stuff/ident1.txt';
my $ref = get_config($ident);
print "my hash print says this:\n";
show_hash($ref);
sub get_config{
print Dumper Load scalar read_file(shift);
}
sub show_hash{
my $href = shift;
my $ref_type = ref $href;
warn "expected hash ref\n" unless $ref_type eq 'HASH';
for my $key (keys %{$href}) {
print "$key => ${$href}{$key}\n";
}
}
$
It would seem that the complaint came for line 2, which looks right to
me (??)
Q1) What do I have to change about this identity file to make it kosher
for vivifying in this manner?
--
Cal
------------------------------
Date: Thu, 26 Sep 2013 21:57:37 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: perl hash utilities
Message-Id: <l2203b$1q9t$1@news.ntua.gr>
# hey this is easy !
#!/usr/bin/perl
use warnings;
use strict;
my %domain = %{get_config()};
use Data::Dumper;print Dumper \%domain;
sub get_config
{
my $code = '$_=';
while(<DATA>){$code.=$_}
eval $code;
$_
}
__DATA__
{
my_ftp => {
domain => 'www.merrillpjensen.com',
username => 'u63457',
password => 'mnbvvdfgcxz5',
},
site => {
domain => 'http://translate.google.com/',
language => 'russian',
word => 'north',
},
}
------------------------------
Date: Thu, 26 Sep 2013 18:42:20 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: perl hash utilities
Message-Id: <87ioxnurw3.fsf@stemsystems.com>
>>>>> "CD" == Cal Dershowitz <cal@example.invalid> writes:
CD> unless ($config) {
CD> die("read error: $!") if $!;
CD> die("parse error: $@") if $@;
>>
>> you can't have $! as you didn't do a system call yourself. it may be set
>> and left over which is bogus. if the do fails it will die and you won't
>> even get to that code.
CD> I won't be sad to see these lines disappear from my scripts going
CD> forward at all.
i don't get what sad has to do with it. the $! lines you have tell you
nothing. absolutely nothing. they are ONLY for when you make a system
call like open/close, etc. you are not making such a call so there is no
information in $! for you.
>>
>>
CD> }
CD> $domain = $config->{$my_ftp};
CD> die("unknown domain: $!") unless $domain;
>>
>> why are you printing $! there? you are just checking a value. that can't
>> set $! which is only set by system calls. wasteful and misleading.
CD> same comment.
same comment. lose the $! lines now.
>>
CD> $domain = $config->{$my_ftp};
>>
CD> Why does this not assign to %domain in the subroutine?
>>
>> $domain and %domain are separate variables. don't confuse $domain{foo}
>> which is a hash access with $domain which is a scalar variable.
>>
>> uri
>>
CD> The word domain was overloaded in a way that barely made sense to me.
CD> I believe what I endeavor to do here is called auto-vivification. I'm
CD> not sure what separate the auto- version of it from the garden-variety
CD> vivifying, but that goes precisely to my question as to how the hash
CD> should appear in ident1.txt. To my eye, it looks like the treatments
CD> I've seen.
no it isn't autovivication. you are just confusing a scalar and a
hash. it is a good practice not to use the same names for different
variable types. $domain and %domain_info or something like that. generic
names are not good in any case.
CD> Q1) What do I have to change about this identity file to make it
CD> kosher for vivifying in this manner?
i don't know what is going on but it isn't anything to do with
autovivification. you are using the term but you don't know what it
means. it has to do with perl creating references for you when you imply
there is one via a deep access.
uri
------------------------------
Date: Thu, 26 Sep 2013 18:45:49 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: perl hash utilities
Message-Id: <87eh8burqa.fsf@stemsystems.com>
>>>>> "GM" == George Mpouras <gravitalsun@hotmail.foo> writes:
GM> # hey this is easy !
then why can't you format it well too? seriously.
GM> #!/usr/bin/perl
GM> use warnings;
GM> use strict;
GM> my %domain = %{get_config()};
GM> use Data::Dumper;print Dumper \%domain;
GM> sub get_config
GM> {
GM> my $code = '$_=';
GM> while(<DATA>){$code.=$_}
GM> eval $code;
GM> $_
GM> }
fugly in every possible dimension. slow. poorly formatted. uses $_ for
no reason to hold the result.
use File::Slurp ;
my %domain = %{ eval read_file( \*DATA ) } ;
even better, drop the outer {} in DATA as it is not needed. then you
don't need the %{} dereference.
uri
------------------------------
Date: Fri, 27 Sep 2013 00:48:30 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl hash utilities
Message-Id: <enteha-c6o.ln1@anubis.morrow.me.uk>
Quoth Uri Guttman <uri@stemsystems.com>:
> >>>>> "CD" == Cal Dershowitz <cal@example.invalid> writes:
>
> CD> my $ident = 'template_stuff/ident.txt';
> CD> my $config = do($ident);
>
> first time i have seen do( file ) in ages. you might be better off
> slurping in yourself and calling eval on it. same results with better
> control.
You must have forgotten how it works, then...
> CD> unless ($config) {
> CD> die("read error: $!") if $!;
> CD> die("parse error: $@") if $@;
>
> you can't have $! as you didn't do a system call yourself. it may be set
> and left over which is bogus. if the do fails it will die and you won't
> even get to that code.
...because do FILE can set either $! or $@. It sets $! if reading the
file fails, and $@ if the file can be read but the eval fails. (However,
Cal is checking them in the wrong order: the documentation is explicit
that if $@ is set then $! may also be set to something spurious, so $@
should be checked first.)
Ben
------------------------------
Date: Fri, 27 Sep 2013 02:06:36 -0700
From: Charles DeRykus <derykus@gmail.com>
Subject: Re: perl hash utilities
Message-Id: <l23hqt$fq7$1@speranza.aioe.org>
On 9/26/2013 4:48 PM, Ben Morrow wrote:
>
> ...
>
>> CD> unless ($config) {
>> CD> die("read error: $!") if $!;
>> CD> die("parse error: $@") if $@;
>>
>> you can't have $! as you didn't do a system call yourself. it may be set
>> and left over which is bogus. if the do fails it will die and you won't
>> even get to that code.
>
> ...because do FILE can set either $! or $@. It sets $! if reading the
> file fails, and $@ if the file can be read but the eval fails. (However,
> Cal is checking them in the wrong order: the documentation is explicit
> that if $@ is set then $! may also be set to something spurious, so $@
> should be checked first.)
>
I notice the doc example grows messy:
unless ($return = do $file) {
warn "couldn't parse $file: $@" if $@;
warn "couldn't do $file: $!" unless defined $return;
warn "couldn't run $file" unless $return;
}
I'd be tempted to just write something like:
$return = do $file or warn "do: ",$@ || $! || "return value?";
--
Charles DeRykus
------------------------------
Date: Fri, 27 Sep 2013 13:59:01 -0700
From: Cal Dershowitz <cal@example.invalid>
Subject: Re: perl hash utilities
Message-Id: <MeCdnQygg_oObNjPnZ2dnUVZ_rCdnZ2d@supernews.com>
On 09/26/2013 03:45 PM, Uri Guttman wrote:
> use File::Slurp ;
> my %domain = %{ eval read_file( \*DATA ) } ;
>
> even better, drop the outer {} in DATA as it is not needed. then you
> don't need the %{} dereference.
>
> uri
>
I liked the economy of expression that you have here, I just can't pull
any vlues out of it yet. I tried several different things. I think
this was my best:
$ perl config3.pl
SCALAR(0x9c72ed4)$
$ cat config3.pl
#!/usr/bin/perl -w
use strict;
use File::Slurp;
my $ident = 'template_stuff/ident1.txt';
my $ref = \$ident;
my %domain = %{eval read_file( $ref )};
print_hash(\%domain);
sub print_hash{
print "subroutine says this is your hash: \n";
my $hash_ref = shift;
my %hash = %$hash_ref;
while ( (my $key,my $value) = each %hash )
{
print "key: $key, value: $hash{$key}\n";
}
}
$ cat template_stuff/ident1.txt
{
my_ftp = {
domain => 'fakename',
username => 'fakeuser',
password => 'fakepass',
},
yoursky = {
domain => 'http://www.fourmilab.ch/yoursky/',
language => 'russian',
word => 'north',
},
}
$
If I drop the braces, I get a syntax error. If I replace them with
parens, I get a syntax error.
Looked at file;;slurp stuff on cpan. I think I call with references
correctly, but this is fresh from a reading it. Do you have a
suggestion for a good way to google for file::slurp examples or find
them on the web by some other means? (I like using usenet because it's
public, but it's not like there isn't the rest of net now.)
Thanks for your comment.
--
Cal
------------------------------
Date: Fri, 27 Sep 2013 14:10:36 -0700
From: Cal Dershowitz <cal@example.invalid>
Subject: Re: perl hash utilities
Message-Id: <WZadnS7mVdnNadjPnZ2dnUVZ_uWdnZ2d@supernews.com>
On 09/26/2013 11:27 AM, Ben Bacarisse wrote:
> Cal Dershowitz <cal@example.invalid> writes:
> <snip>
>> So what I'm looking to have at the end of this great endeavor is
>> 2) a hash with the following values:
>> domain => 'www.tyui.com',
>> username => 'sdfkgkdfj',
>> password => 'alisjflasjf',
>> , and a reference to pass it around to see if I can print the darn thing.
>
> If $href holds a reference to a hash, then $href->{'domain'} =
> 'www.tyui.com' will set the 'domain' key in the hash referenced by
> $href. So for a sub called like this:
>
> my %domain;
> ...
> fill_me_in(\%domain);
>
> the body would be something along the lines of
>
> sub fill_me_in
> {
> my $href = shift;
> ...
> $href->{'domain'} = '...';
> $href->{$some_key} = $some_value;
> ...
> }
>
I see Ben. We've all defined arrays in main and passed them to a
subroutine and had that subroutine hand it back with new values.
Could a person return a reference to the hash to make the data not blink
out of scope at just the wrong time?
--
Cal
------------------------------
Date: Fri, 27 Sep 2013 22:42:18 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl hash utilities
Message-Id: <qmahha-6r71.ln1@anubis.morrow.me.uk>
Quoth Cal Dershowitz <cal@example.invalid>:
>
> I see Ben. We've all defined arrays in main and passed them to a
> subroutine and had that subroutine hand it back with new values.
No we haven't. That's very poor practice.
> Could a person return a reference to the hash to make the data not blink
> out of scope at just the wrong time?
Yes. You can also pass a reference to a hash, and modify that hash (via
the reference) in the sub. In both cases (more so in the first) it's
clear that the sub is or may be responsible for the values that end up
in the hash.
Ben
------------------------------
Date: Fri, 27 Sep 2013 16:55:44 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: perl hash utilities
Message-Id: <5245fee0$0$73606$815e3792@news.qwest.net>
On 09/27/13 15:59, Cal Dershowitz wrote:
[...]
> $ cat template_stuff/ident1.txt
> {
> my_ftp = {
> domain => 'fakename',
> username => 'fakeuser',
> password => 'fakepass',
> },
>
> yoursky = {
> domain => 'http://www.fourmilab.ch/yoursky/',
> language => 'russian',
> word => 'north',
> },
> }
>
> $
>
> If I drop the braces, I get a syntax error. If I replace them with
> parens, I get a syntax error.
What's creating ident1.txt???.. Why does it have to be in that format????
It seems that you are complicating things and wasting a lot of time
by coming up with your own format and then trying to shoehorn that
format into something usable.
Go the other way.. Change the format to something that is expected --
well defined. There's JSON, YAML, Data::Dumper's Freeze/Thaw, XML, etc.
Pick one and try it. Each one already has classes/methods to create data
structures out of the data. This will turn into a 5-minute task.
------------------------------
Date: Thu, 26 Sep 2013 09:48:53 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: utilities in perl
Message-Id: <52444955$0$73612$815e3792@news.qwest.net>
On 09/25/13 17:46, George Mpouras wrote:
>>> Or.. look at using Find::Bin. That way you could run
>>> /home/blah/get_file1.pl .. instead of always being in
>>> /home/blah and having to run ./get_file1.pl.. and the
>>> templates could be relative to get_file1.pl.
>>>
>> correction.. FindBin not Find::Bin.. sorry.
>
>
> why the FindBin and not the File::Find ;
>
>
The part that was meant to address was:
[...] For the purposes of the template, I basically
want to hard code the directory at this point.
Specifically, calling getcwd..
That's where FindBin comes in handy -- when your templates
are relative to where your program is located. Many
times your dev directory/machine might have different
paths or maybe you want to run it from something else
and want to call /home/junk/abc.pl instead of having to do
'cd /home/junk; ./abc.pl' etc. Using FindBin will
give you a lot of flexibility and you could move/cp everything
to a different directory ( e.g. for production ) and not
have to change any code.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 4045
***************************************