[22833] in Perl-Users-Digest
Perl-Users Digest, Issue: 5054 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 28 21:06:15 2003
Date: Wed, 28 May 2003 18:05:09 -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 Wed, 28 May 2003 Volume: 10 Number: 5054
Today's topics:
Re: Bioperl? (entropy123)
Re: DMake (newbie) <daniel_newhouse@earthlink.net>
Re: Doing substitutions in a while loop (while /.../g) <krahnj@acm.org>
Re: Help: Completely Delete HOH key ($family)?? (Not a (entropy123)
How to trap fatal errors w/ perlembed? <topper@virginia.edu>
Re: lowercase and uppercase(multi-language) <mgjv@tradingpost.com.au>
Q about assignments for unmatched regex <michael+gnus@trollope.org>
Re: Q about assignments for unmatched regex (Malcolm Dew-Jones)
Re: Q about assignments for unmatched regex <jasonp@uq.net.au>
Re: Reversible loop <ericw@nospam.ku.edu>
Semi-Newbie Steps Into Module Hell <kevin.vaughn@ttu.edu>
Re: Semi-Newbie Steps Into Module Hell <bkennedy@hmsonline.com>
Re: Semi-Newbie Steps Into Module Hell (Jay Tilton)
setpgrp, setgid - not working, what am I missing? <persicom@acedsl.com>
sort request <creafin1998@yahoo.com>
Re: sort request <mbudash@sonic.net>
Re: Sorting an array of hashes (Jay Tilton)
Re: Sorting an array of hashes <uri@stemsystems.com>
Re: uninitialized value in eval block? <spam.me.senseless@sitting.duck>
Re: uninitialized value in eval block? (Tad McClellan)
using push @INC and use lib <thens@nospam.com>
Re: using push @INC and use lib <grazz@pobox.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 May 2003 16:24:29 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: Bioperl?
Message-Id: <90cdce37.0305281524.4e92dd7c@posting.google.com>
Uri, Abigail, & Bertt,
:) Newsgroups always have personalities...its just a matter of time...
entropy
------------------------------
Date: Thu, 29 May 2003 00:05:43 GMT
From: "Daniel L Newhouse" <daniel_newhouse@earthlink.net>
Subject: Re: DMake (newbie)
Message-Id: <r9cBa.21705$Io.1902516@newsread2.prod.itd.earthlink.net>
"Brian McCauley" <nobull@mail.com> wrote in message
news:u9of1n7zuc.fsf@wcl-l.bham.ac.uk...
> My advice is don't.
>
> If you consider yourself a newbie you shouldn't be trying to build
> Perl on Windows.
>
> --
I'm a newbie to Perl but not to programming, C, or Windows generally.
------------------------------
Date: Wed, 28 May 2003 23:18:48 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Doing substitutions in a while loop (while /.../g)
Message-Id: <3ED543D2.AABD3DC8@acm.org>
Tad McClellan wrote:
>
> Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
> > tadmc@augustmail.com (Tad McClellan) wrote in
> > news:slrnbd7ua0.3br.tadmc@magna.augustmail.com:
> >
> >> What? You don't re-read perlop.pod every once in a while?
> >>
> >> I do. I find out something I didn't catch the first time each
> >> time I re-read it.
> >
> > Geek. ;-)
>
> I have to have _something_ to read when I'm in the
> smallest room in my house...
Did you get one of them new MS models or did you jerry-rig one yourself?
:-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: 28 May 2003 16:23:30 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: Help: Completely Delete HOH key ($family)?? (Not a Ring/Cycle Question :) )
Message-Id: <90cdce37.0305281523.3c0c6f48@posting.google.com>
Brian,
Thanks man, didn't know that last bit..
entropy
------------------------------
Date: Wed, 28 May 2003 18:09:35 -0400
From: "David J. Topper" <topper@virginia.edu>
Subject: How to trap fatal errors w/ perlembed?
Message-Id: <3ED5339F.3080806@virginia.edu>
Running Slackware linux with 5.8.0. I've got Perl nicely embedded in my
app. But when I feed it an invalid buffer, it dies, quitting my app as
well. How can I fix this?
Here's the code I'm using to set up my perl instance:
int perl_parse_buf (char *inBuf) {
STRLEN n_a;
char *embedding[] = { "", "-U -e", "" };
if (!my_perl) {
my_perl = perl_alloc();
perl_construct( my_perl );
perl_parse(my_perl, xs_init, 3, embedding, NULL);
/* PL_exit_flags |= PERL_EXIT_DESTRUCT_END; */
perl_run(my_perl);
}
perlBuf = eval_pv(inBuf, TRUE);
return 0;
}
I thought the "-U" would allow "unsafe" operations.
Thanks,
DT
--
Technical Director, Virginia Center for Computer Music
http://www.people.virginia.edu/~djt7p
(804) 924-7355
------------------------------
Date: Thu, 29 May 2003 00:40:36 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: lowercase and uppercase(multi-language)
Message-Id: <slrnbdalo4.1lr.mgjv@verbruggen.comdyn.com.au>
On 28 May 2003 02:09:23 -0700,
deny_petr@yahoo.com <deny_petr@yahoo.com> wrote:
> Hi all,
>
> Could u help me?
Don't know. You should probably ask U.
> I want to search a string where are lowercase and uppercase letters.
> for example: "Hello".
> I `m trying to use "\L" and "\U", but they do not work with "\w".
I don't really understand what that is supposed to mean. How are \L
and \U supposed to "work with" \w? Are you thinking that they modify
the meaning of character classes like \w? If so, they don't. They just
modify "normal" characters in a (double-quoted) string context [1].
> binmode STDIN;
> undef $/; $a = <>;
> print "found\n" if $a =~ /(/U/w{1}/E/L/w{4}/E)/;
Syntax error.
> it do not work.
No, it wouldn't. It doesn't compile. It is not a good idea to retype
code. Cut and Paste when you post code here.
> I can use $a =~ /([A-Z]{1}[a-z]{4}/;
> But it did not support multi-language.
You should have another read of the perlre documentation, and look at
the POSIX character classes described in there. Especially the
[:upper:] and [:lower:] character classes would be interesting. Quote
from perlre:
For example use "[:upper:]" to match all the uppercase characters.
Note that the "[]" are part of the "[::]" construct, not part of the
whole character class. For example:
[01[:alpha:]%]
matches zero, one, any alphabetic character, and the percentage sign.
> How create a regexp which searchs the string(supporting multi-language)?
Use constructs that are locale sensitive. Also read (at least parts
of) the perllocale documentation, and make sure you "use locale".
Martien
[1] \U and \L are not regular expression specific, and I think it's
probably misleading that they are documented in perlre, even though
perlre carefully states, before the table that describes them:
Because patterns are processed as double quoted strings, the following
also work:
In other words: Those things work the same way in a regular expression
as in any old double-quoted string.
--
|
Martien Verbruggen |
Trading Post Australia | Hi, Dave here, what's the root password?
|
------------------------------
Date: 28 May 2003 18:54:37 -0400
From: Michael Powe <michael+gnus@trollope.org>
Subject: Q about assignments for unmatched regex
Message-Id: <ullwqk7gy.fsf@trollope.org>
hello,
i am looping through a file matching lines to a regex. however, some
lines don't return a match. so, i have something like this:
while (<FH>) {
my ($one,$two,$three,$four,$five,$six);
($one,$two,$three,$four,$five,$six) = ($_ =~ /$re/);
...
}
the question is, what goes into $one ... $six when the $re does not
match anything in the line? i would like to catch this condition when
it occurs. i thought it might be undef or an empty string, but if so,
i don't seem to have the right handle on how to detect that. how can
i check for the condition, so as to use the results only when the vars
contain matched values?
i tried if(defined($one)){ ... } and if ($one ne ""){ ... }. duds both.
thanks.
mp
------------------------------
Date: 28 May 2003 16:50:15 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Q about assignments for unmatched regex
Message-Id: <3ed54b37@news.victoria.tc.ca>
Michael Powe (michael+gnus@trollope.org) wrote:
: hello,
: i am looping through a file matching lines to a regex. however, some
: lines don't return a match. so, i have something like this:
: ...snip...
while (<FH>)
{
if ( my ($one,$two,$three,$four,$five,$six) = /$re/ )
{ # the re matched, and $one etc are in scope and can be used
}
else
{ # the re did not match, and you can't even accidently
# use the variables due to their scope.
}
}
------------------------------
Date: Wed, 28 May 2003 20:35:20 -0400
From: Jason Parker-Burlingham <jasonp@uq.net.au>
Subject: Re: Q about assignments for unmatched regex
Message-Id: <87k7casi7r.fsf@freezer.burling>
yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) writes:
> Michael Powe (michael+gnus@trollope.org) wrote:
> : hello,
>
> : i am looping through a file matching lines to a regex. however, some
> : lines don't return a match. so, i have something like this:
> : ...snip...
>
> while (<FH>)
> {
> if ( my ($one,$two,$three,$four,$five,$six) = /$re/ )
> { # the re matched, and $one etc are in scope and can be used
> }
> else
> { # the re did not match, and you can't even accidently
> # use the variables due to their scope.
> }
> }
The variables aren't out of scope in the else block, although they are
uninitialized because of the failing regular expression match.
Data::Dumper indicates they're set to undef:
#!/usr/bin/perl -w
use strict;
while(<DATA>) {
if (my ($foo, $bar) = m/^(.)(.)$/) {
print "$foo:$bar\n";
} else {
use Data::Dumper;
print Dumper $foo, $bar;
}
}
__DATA__
at
none
--
``Oooh! A gingerbread house! Hansel and Gretel are set for life!''
------------------------------
Date: Wed, 28 May 2003 22:56:05 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: Reversible loop
Message-Id: <pan.2003.05.28.17.52.57.970299.5251@nospam.ku.edu>
On Wed, 28 May 2003 07:20:34 -0500, Brian McCauley wrote:
> my @set = ( [ 39 .. 42 ],
> [ reverse 39 .. 42 ] );
> foreach my $dir (@set) {
> for my $i ( @$dir ) {
> print "i: $i ";
> }
> print "\n";
> }
Yes, this may be just what I am looking for (I'm not really sure yet) and
thanks to all for the other helpful suggestions.
I'm not sure at this point if I will go back and re-write the algorithm,
or wait to see if a completely different form manifests itself.
The trick is that there is a function call which returns $i_start and
$i_stop values which were originally thought to be ordered such that you
could loop with $i<$i_stop, but a case turned up where they were
reversed. I think I just fixed it with
($i_start, $i_stop) = sort({$a<=>$b} function(args));
but there was another case which was supposed to be handled by the
algorithm (though it didn't happen concurrently with this one) where
$i>$checkpoint had to throw another switch. This makes it look like the
dispatch table would work better, but I think the whole thing would end
up with a $direction = -1 or something that got used everywhere to make
the math work.
--Eric
------------------------------
Date: Wed, 28 May 2003 17:09:51 -0500
From: "Kevin Vaughn" <kevin.vaughn@ttu.edu>
Subject: Semi-Newbie Steps Into Module Hell
Message-Id: <vdactn97gf5j09@corp.supernews.com>
Disclaimer - I've never tried to update a module before (never had to).
What I'm trying to do:
- I'm running Perl 5.6.1 build 626 on Windows 2000.
- I'm trying to update the Win32::OLE module due to memory leaks
Where I currently am:
- "ppm search ole" says I'm running Win32-OLE version 0.1403
- The version of ole.pm residing in lib and site/lib says 0.1501
- The version listed on CPAN is 0.1502
What I've tried:
- "ppm install Win32::OLE" looks interesting since it creates a lot of
output, but a search afterwards still says I'm running 0.1403
- Copying over the source file yields this error: "Win32::OLE object
version 0.1501 does not match $Win32::OLE::VERSION 0.1502 at
C:/Perl/lib/DynaLoader.pm line 225."
Any ideas?
-Kevin
------------------------------
Date: Wed, 28 May 2003 18:41:28 -0400
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Semi-Newbie Steps Into Module Hell
Message-Id: <GTSdnRHR_5uEpkijXTWJhw@giganews.com>
"Kevin Vaughn" <kevin.vaughn@ttu.edu> wrote in message
news:vdactn97gf5j09@corp.supernews.com...
> Disclaimer - I've never tried to update a module before (never had to).
>
> What I'm trying to do:
> - I'm running Perl 5.6.1 build 626 on Windows 2000.
> - I'm trying to update the Win32::OLE module due to memory leaks
Have you tried Perl 5.8.0? The latest build has version .1603 - I don't
know if ActiveState bothers maintaining ppms for older versions of Perl
--Ben Kennedy
------------------------------
Date: Wed, 28 May 2003 23:34:14 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Semi-Newbie Steps Into Module Hell
Message-Id: <3ed54600.245856680@news.erols.com>
"Kevin Vaughn" <kevin.vaughn@ttu.edu> wrote:
: What I'm trying to do:
: - I'm running Perl 5.6.1 build 626 on Windows 2000.
: - I'm trying to update the Win32::OLE module due to memory leaks
:
: Where I currently am:
: - "ppm search ole" says I'm running Win32-OLE version 0.1403
: - The version of ole.pm residing in lib and site/lib says 0.1501
: - The version listed on CPAN is 0.1502
How did it end up in both lib/ and site/lib/ ? That's cause for
concern.
Could a third copy be installed in another place where Perl is looking
but you are not?
Find out first where Perl is loading Win32::OLE from.
#!perl
require Win32::OLE;
print "loaded Win32::OLE version $Win32::OLE::VERSION\n";
print "from ", $INC{'Win32/OLE.pm'};
If Perl is finding a copy in some rogue directory, figure out why it's
there. Obliterate it or install over top of it.
This might be a good excuse to upgrade to 5.8. It ought to be
painless, since you say you haven't installed any optional modules.
------------------------------
Date: Wed, 28 May 2003 20:31:25 -0400
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: setpgrp, setgid - not working, what am I missing?
Message-Id: <1054168284.671453@nntp.acecape.com>
I have a login that runs korn shells scripts that call perl scripts that
create various files. I want all the files created by these processes
and any system() or backtick calls therein to have their group set to
'clrpt'. The login is in that group, but it is not the default (which is
'develop').
First, I tried to put newgrp calls in the ksh scripts, but that didn't
work - newgrp spawns a new process and stops script execution. I cannot
change the default group on the login for various technical and politcal
reasons. I figured my best bet was to change the process group in the
perl scripts.
Well, I must be doing something really wrong. I tried three methods:
1) setpgrp()
2) assigining to $) and $( directly
3) POSIX::setgid.
Here's a sample script:
#!/usr/bin/env perl
use strict;
use warnings;
print "real: $(\n";
print "eff : $)\n";
use POSIX qw (setgid);
setgid(450);
print "real: $(\n";
print "eff : $)\n";
open (OH,'>test_setgrp.dat');
print OH 'Hello world';
close OH;
Here's the output:
real: 200 40 450 201 200
eff : 200 40 450 201 200
real: 200 40 450 201 200
eff : 200 40 450 201 200
Here's the file listing:
-rw-rw-r-- 1 persicom develop 11 May 28 20:26 test_setgrp.dat
I hoped to see output like:
real: 200 40 450 201 200
eff : 200 40 450 201 200
real: 450 40 450 201 200
eff : 450 40 450 201 200
and a file listing of:
-rw-rw-r-- 1 persicom clrpt 11 May 28 20:26 test_setgrp.dat
So, two questions:
1) Why can't I change groups? What piece of documentation did I miss?
2) Even if I change groups, will that affect the "group-iness" of files
created?
Thanks
--
Matthew
------------------------------
Date: Wed, 28 May 2003 18:30:17 -0500
From: "John Smith" <creafin1998@yahoo.com>
Subject: sort request
Message-Id: <vdahc0nbv1g9bf@corp.supernews.com>
Could someone please help me write an efficient perl sort routine for dates?
I need to sort dates in the following format: 28-May-03
It must chronologically sort ascending or descending. Thanks in advance to
anyone who is up to the challenge.
------------------------------
Date: Thu, 29 May 2003 00:27:21 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: sort request
Message-Id: <mbudash-2D5AAD.17272028052003@typhoon.sonic.net>
In article <vdahc0nbv1g9bf@corp.supernews.com>,
"John Smith" <creafin1998@yahoo.com> wrote:
> Could someone please help me write an efficient perl sort routine for dates?
> I need to sort dates in the following format: 28-May-03
> It must chronologically sort ascending or descending. Thanks in advance to
> anyone who is up to the challenge.
>
>
i smell schoolwork... but...
my %mons;
@mons{qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/} = (0..11);
my @dates = qw/28-May-03 21-Feb-01 21-May-03 15-Sep-04/;
my @sorted_dates;
# ascending
@sorted_dates = sort { thesort() } @dates;
# descending
@sorted_dates = sort { thesort(1) } @dates;
sub thesort {
my $descend = shift;
my (@a, @b);
if ($descend) {
@a = split /\-/, $b;
@b = split /\-/, $a;
}
else {
@a = split /\-/, $a;
@b = split /\-/, $b;
}
$a[2] <=> $b[2] || $mons{$a[1]} cmp $mons{$b[1]} || $a[0] <=> $b[0];
}
hth-
--
Michael Budash
------------------------------
Date: Wed, 28 May 2003 22:19:23 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Sorting an array of hashes
Message-Id: <3ed535c0.241695343@news.erols.com>
Uri Guttman <uri@stemsystems.com> wrote:
: >>>>> "RK" == Roman Khutkyy <beromko@yahoo.com> writes:
:
: RK> Just sort the array. @keys-old array, @order - the new one :
:
: hmm, did you just invent the bubble sort?
Can't be. Bubble sort would at least retain all the original
elements. That code is just broken.
------------------------------
Date: Wed, 28 May 2003 22:32:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Sorting an array of hashes
Message-Id: <x7znl6g0t0.fsf@mail.sysarch.com>
>>>>> "JT" == Jay Tilton <tiltonj@erols.com> writes:
JT> Uri Guttman <uri@stemsystems.com> wrote:
JT> : >>>>> "RK" == Roman Khutkyy <beromko@yahoo.com> writes:
JT> :
JT> : RK> Just sort the array. @keys-old array, @order - the new one :
JT> :
JT> : hmm, did you just invent the bubble sort?
JT> Can't be. Bubble sort would at least retain all the original
JT> elements. That code is just broken.
i can't parse the code with my eyeballs anyhow. i almost never use index vars
and seeing code using them like that is not fun. so we can claim it is a
slow (indexing is slow), broken bubble sort. any more qualifiers needed?
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 28 May 2003 23:03:48 +0100
From: SeeMySig <spam.me.senseless@sitting.duck>
Subject: Re: uninitialized value in eval block?
Message-Id: <gKDVgIJEJT1+Ew8D@nildram.co.uk>
In message <slrnbdaaod.1qv.tadmc@magna.augustmail.com>, Tad McClellan
<tadmc@augustmail.com> writes
>SeeMySig <spam.me.senseless@sitting.duck> wrote:
>> In the process of removing all warning violations from my CGI script, I
>> find the following gets passed during warningsToBrowser(1):
>>
>><!-- warning: Use of uninitialized value in concatenation (.) or string
>> at (eval 18) line 32. -->
>>
[Edited for brevity]
>
>> Line 32 is: $ENV{PATH} = "/bin:/usr/sbin"; # to keep -T happy!
>
>
>Is that line 32 in your program or the 32nd line in the 18th eval()
>that your program does?
>
>If the former, then I don't know why you are showing us that one either.
>
>
>> so they are unlikely culprits,
>
>
>Yes, especially since they have nowhere been implicated as the culprits. :-)
>
Tad,
Thanks for the reply. OK, accepted my illustrations were erroneous, now
I understand what the warning was saying.
>> The question is, where do I look for the source of the violation in eval
>> 18 line 32?
>
>
>step 1) determine what the 18th eval() is that your program is evaluating.
>
>step 2) count in that eval to the 32nd line.
>
>step 3) look for undef values near there
>
If I trace the 32nd line of my 18th eval (it's actually easier to locate
the sub-routine in use at the time the HTML was created), it is actually
a blank line! Presumably the debug parser includes blank lines and
comment lines? But now I know the logic of the warning I will probably
be able to find it.
But I have to ask why do most other warnings localise to an actual line
in the script, and so are pretty easy to correct, but this one does a
cryptic 'you-may-find-it-if-you-look-hard-enough'?
--
RA Jones
ra(dot)jones(at)dpw(dot)clara(dot)net
------------------------------
Date: Wed, 28 May 2003 18:16:41 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: uninitialized value in eval block?
Message-Id: <slrnbdagqp.1vn.tadmc@magna.augustmail.com>
SeeMySig <spam.me.senseless@sitting.duck> wrote:
> In message <slrnbdaaod.1qv.tadmc@magna.augustmail.com>, Tad McClellan
><tadmc@augustmail.com> writes
>>SeeMySig <spam.me.senseless@sitting.duck> wrote:
>>><!-- warning: Use of uninitialized value in concatenation (.) or string
>>> at (eval 18) line 32. -->
>>>
> [Edited for brevity]
[I did some editing here too]
> now
> I understand what the warning was saying.
My mission is accomplished then. :-)
>>> The question is, where do I look for the source of the violation in eval
>>> 18 line 32?
>>
>>step 1) determine what the 18th eval() is that your program is evaluating.
>>
>>step 2) count in that eval to the 32nd line.
>>
>>step 3) look for undef values near there
>>
> If I trace the 32nd line of my 18th eval
How is it that you are doing so many evals anyway?
Are they all of the "eval BLOCK" form rather than the "eval EXPR" form?
> (it's actually easier to locate
> the sub-routine in use at the time the HTML was created), it is actually
> a blank line! Presumably the debug parser
There is no "debug parser" (here), only The Parser (perl).
> includes blank lines and
> comment lines?
Yes, perl will correctly count line numbers, even in the face of
lines that do not contain any code to compile.
It may not _report_ them accurately though.
Parsing Is Hard.
> But now I know the logic of the warning I will probably
> be able to find it.
That is what I thought when I accepted my mission. :-)
> But I have to ask why do most other warnings localise to an actual line
> in the script, and so are pretty easy to correct, but this one does a
> cryptic 'you-may-find-it-if-you-look-hard-enough'?
Because you put it in an eval.
You are running perl inside of perl, that makes it "hard(er)".
I very seldom need to use the Perl debugger, but I'd use it
if I was chasing a bunch of "eval BLOCK"s in my program.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 May 2003 04:43:42 +0530
From: Thens <thens@nospam.com>
Subject: using push @INC and use lib
Message-Id: <20030529044342.522c8d06.thens@nospam.com>
All,
I would like to know the difference between the following piece of
code (if any) and suggestions on which is better
<code 1>
#!/usr/local/bin/perl -w
BEGIN{
push @INC, "/home/myname/mdoules";
}
__END__
<code 2>
#!/usr/local/bin/perl -w
use lib "/home/myname/mdoules";
__END__
Thanks and Regards,
Thens.
------------------------------
Date: Thu, 29 May 2003 00:18:46 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: using push @INC and use lib
Message-Id: <GlcBa.31621$4_1.8767899@twister.nyc.rr.com>
Thens <thens@nospam.com> wrote:
> I would like to know the difference between the following
> piece of code (if any) and suggestions on which is better
>
> <code 1>
> #!/usr/local/bin/perl -w
>
> BEGIN{
> push @INC, "/home/myname/mdoules";
> }
> __END__
>
> <code 2>
> #!/usr/local/bin/perl -w
>
> use lib "/home/myname/mdoules";
>
> __END__
They'd be identical if you used unshift() instead of push() in the
first example. As things are, the 'use lib' version would search
the local module directory first and the 'BEGIN{}' version would
search it after the default contents of @INC.
Unless you were counting on that distinction you should certainly
'use lib'. Fewer keystrokes, that's what it's there for, etc, etc.
--
Steve
------------------------------
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:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
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 V10 Issue 5054
***************************************