[30402] in Perl-Users-Digest
Perl-Users Digest, Issue: 1645 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 16 14:09:53 2008
Date: Mon, 16 Jun 2008 11:09:10 -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 Mon, 16 Jun 2008 Volume: 11 Number: 1645
Today's topics:
[ANN] GromPerl persistent Perl interpreter <gromnospam@googlemail.com>
Re: calling external program tiff2pdf <john1949@yahoo.com>
Expat / XML::Parser / _crypt_struct <skendric@fhcrc.org>
Re: Idle thought about bless <baxter.brad@gmail.com>
Is there an include for perl? <bill@ts1000.us>
Re: Is there an include for perl? <1usa@llenroc.ude.invalid>
Re: Is there an include for perl? <jurgenex@hotmail.com>
Re: Is there an include for perl? <mark.clementsREMOVETHIS@wanadoo.fr>
Re: Is there an include for perl? <bill@ts1000.us>
Re: Learning Perl (Randal L. Schwartz)
Re: Learning Perl <brian.d.foy@gmail.com>
Re: Learning Perl <uri@stemsystems.com>
Re: Learning Perl <gord.c.e@gmail.com>
Re: Learning Perl <gord.c.e@gmail.com>
Re: Learning Perl <gord.c.e@gmail.com>
Re: Learning Perl <1usa@llenroc.ude.invalid>
Re: Learning Perl <jurgenex@hotmail.com>
Re: Learning Perl <ced@blv-sam-01.ca.boeing.com>
Re: LWP::Simple getstore with absolute path not working <szrRE@szromanMO.comVE>
Re: LWP::Simple getstore with absolute path not working <hjp-usenet2@hjp.at>
Re: Offsetting dates from the past in Date::Manip <grehom@ntlworld.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 16 Jun 2008 17:48:21 +0200
From: "GVDC" <gromnospam@googlemail.com>
Subject: [ANN] GromPerl persistent Perl interpreter
Message-Id: <g362i5$k5b$1@news.eunet.yu>
GromPerl persistent Perl interpreter
-----------------------------------------------------------------------
GromPerl is a persistent version of Perl interpreter provided by Bauk Web
server's Grom persistent interpreter connector library.
Perl interpreter compiled and linked with Grom connector library produces a
version of Perl interpreter capable of operating in persistent mode with
Bauk Web server and executing *.pl scripts in Web directory.
It provides Web designers/programmers ability to use Perl script code for
creating dynamic pages/Web scripts and interact with objects on Web server
ie. to manipulate files and directories, handle client-sent data, databases,
create content management systems, etc.
Download:
http://www.bauk.ws/gromperl.html
http://www.bauk.ws/readme.html#gromconnector
GromPerl persistent Perl interpreter
Grom persistent interpreter connector library
------------------------------
Date: Mon, 16 Jun 2008 11:01:59 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: calling external program tiff2pdf
Message-Id: <g35dmj$6p5$1@news.albasani.net>
"szr" <szrRE@szromanMO.comVE> wrote in message
news:g3447m01dsg@news4.newsguy.com...
> John wrote:
>> "Jens Thoms Toerring" <jt@toerring.de> wrote in message
>> news:6bf1i4F3arn58U1@mid.uni-berlin.de...
>>> John <john1949@yahoo.com> wrote:
>>>> Part of program
>>>
>>>> my $filename="fred.tiff";
>>>> my $newfile="john.pdf";
>>>> system ("tiff2pdf -o $newfile $filename");
>>>
>>>> There is no conversion.
>>>
>>> I guess you shouldn't have a space between the '-o' and the
>>> '$newfile'.
>>> Regards, Jens
>>> --
>>> \ Jens Thoms Toerring ___ jt@toerring.de
>>> \__________________________ http://toerring.de
>>
>> Hi
>>
>> Tried that but it didn't work.
>> It is strange since it works on the linux command line when I key in
>> tiff2pdf -o john.pdf fred.tiff
>> Odd.
>
> Then it might be a permissions problem then. Make sure the script has rw
> access to the dir the pdf will be written in.
>
> --
> szr
>
Hi
I had already chmod and I could r/w.
Many thanks for input
Regards
John
------------------------------
Date: Mon, 16 Jun 2008 07:43:47 -0700 (PDT)
From: sbk <skendric@fhcrc.org>
Subject: Expat / XML::Parser / _crypt_struct
Message-Id: <b1843500-1c0b-4ea5-b8da-a6accc75532d@u12g2000prd.googlegroups.com>
how do i dig deeper into this issue?
i'm trying to install XML::Parser:
[...]
make[1]: Entering directory `/home/netops/.cpan/build/XML-Parser-2.36-
mgvNC9/Expat'
cp Expat.pm ../blib/lib/XML/Parser/Expat.pm
/opt/vdops/bin/perl /opt/vdops/lib/perl5/5.8.8/ExtUtils/xsubpp -
noprototypes -ty
pemap /opt/vdops/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap
Expat.xs > Expat.xsc && mv Expat.xsc Expat.c
cc -c -I/opt/local/include -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=3D64 -I/usr/include/gdbm -O2 -DVERSION=3D\"2.36\" -
DXS_VERSION=3D\"2.36\" -fpic "-I/opt/vdops/lib/perl5/5.8.8/i686-linux-
thread-multi/CORE" Expat.c
In file included from /opt/vdops/lib/perl5/5.8.8/i686-linux-thread-
multi/CORE/op.h:497,
from /opt/vdops/lib/perl5/5.8.8/i686-linux-thread-
multi/CORE/perl.h:2754,
from Expat.xs:15:
/opt/vdops/lib/perl5/5.8.8/i686-linux-thread-multi/CORE/reentr.h:612:
error: field =91_crypt_struct=92 has incomplete type
make[1]: *** [Expat.o] Error 1
make[1]: Leaving directory `/home/netops/.cpan/build/XML-Parser-2.36-
mgvNC9/Expat'
make: *** [subdirs] Error 2
(/usr/bin/make exited with 512)
the relevant section (around line 612) from 'reentr.h' looks like
this:
#ifdef HAS_CRYPT_R
#if CRYPT_R_PROTO =3D=3D REENTRANT_PROTO_B_CCD
CRYPTD* _crypt_data;
#else
struct crypt_data _crypt_struct;
#endif
#endif /* HAS_CRYPT_R */
so, presumably, the data type "_crypt_struct" hasn't been defined
=3D=3D> where should this be defined?
--sk
stuart kendrick
fhcrc
------------------------------
Date: Mon, 16 Jun 2008 08:02:22 -0700 (PDT)
From: Brad Baxter <baxter.brad@gmail.com>
Subject: Re: Idle thought about bless
Message-Id: <cd02293f-52d8-4201-82ef-718e039a794c@25g2000hsx.googlegroups.com>
On Jun 13, 10:48 pm, fishfry <BLOCKSPAMfish...@your-mailbox.com>
wrote:
> In other words, objects are an application of bless, but bless really
> has nothing to do with objects. It just maps a variable to a string.
Perhaps more precisely: it maps a referent to a string. The variable
just contains a reference to the referent.
--
Brad
------------------------------
Date: Mon, 16 Jun 2008 09:26:59 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Is there an include for perl?
Message-Id: <a184527d-be78-40ab-bb6c-3ba53955cbfa@y21g2000hsf.googlegroups.com>
I am looking for an include for perl. I know about require, use etc
and use them, but I have a program that is getting large and would
like to put some of the code into their own files and just use a
include "filename" where the code I pulled belongs and have nothing
else done to that included code other than it being inserted when the
program is run. As an example:
main program:
line 1
line 2
include "other program"
line 3
line 4
other program
line 2a
line 2b
line 2c
when perl runs main program it sees it as
line 1
line 2
line 2a
line 2b
line 2c
line 3
line 4
I know you can do this with require but I have issues with variables
being set in one require not being available in another
Bill H
------------------------------
Date: Mon, 16 Jun 2008 17:12:40 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Is there an include for perl?
Message-Id: <Xns9ABF8660EA18Fasu1cornelledu@127.0.0.1>
Bill H <bill@ts1000.us> wrote in news:a184527d-be78-40ab-bb6c-
3ba53955cbfa@y21g2000hsf.googlegroups.com:
> I am looking for an include for perl. I know about require, use etc
> and use them, but I have a program that is getting large and would
> like to put some of the code into their own files and just use a
> include "filename" where the code I pulled belongs and have nothing
> else done to that included code other than it being inserted when the
> program is run. As an example:
>
http://search.cpan.org/~autrijus/Filter-Macro-0.11/lib/Filter/Macro.pm
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Mon, 16 Jun 2008 17:19:39 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Is there an include for perl?
Message-Id: <c48d54pdpqamn4a4j28u35ev4jkvgf2c6s@4ax.com>
Bill H <bill@ts1000.us> wrote:
>I am looking for an include for perl. I know about require, use etc
>and use them, but I have a program that is getting large and would
>like to put some of the code into their own files and just use a
>include "filename" where the code I pulled belongs and have nothing
>else done to that included code other than it being inserted when the
>program is run.
Are you looking for do()?
jue
------------------------------
Date: Mon, 16 Jun 2008 17:39:00 +0000
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Is there an include for perl?
Message-Id: <4856a533$0$893$ba4acef3@news.orange.fr>
Bill H wrote:
> I am looking for an include for perl. I know about require, use etc
> and use them, but I have a program that is getting large and would
> like to put some of the code into their own files and just use a
> include "filename" where the code I pulled belongs and have nothing
> else done to that included code other than it being inserted when the
> program is run. As an example:
>
>
> main program:
>
> line 1
> line 2
> include "other program"
> line 3
> line 4
>
> other program
> line 2a
> line 2b
> line 2c
>
> when perl runs main program it sees it as
>
> line 1
> line 2
> line 2a
> line 2b
> line 2c
> line 3
> line 4
>
> I know you can do this with require but I have issues with variables
> being set in one require not being available in another
You may want to consider exactly what you want to accomplish by this.
Breaking your program up into separate chunks to improve manageability
is no bad thing (quite the opposite), but the normal mechanism is
creating modules and "use"ing them. Simply doing a textual include as
you want to do may seem to be the simplest solution technically, but may
not be particular good design. Lines 2a-2c in the example above could be
replaced by a simple call to a subroutine in an external module.
Mark
------------------------------
Date: Mon, 16 Jun 2008 11:07:20 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: Is there an include for perl?
Message-Id: <b6ce4298-e305-4f30-ad5e-7b20afb7b761@25g2000hsx.googlegroups.com>
On Jun 16, 1:19=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> Bill H <b...@ts1000.us> wrote:
> >I am looking for an include for perl. I know about require, use etc
> >and use them, but I have a program that is getting large and would
> >like to put some of the code into their own files and just use a
> >include "filename" where the code I pulled belongs and have nothing
> >else done to that included code other than it being inserted when the
> >program is run.
>
> Are you looking for do()?
>
> jue
Hi Jurgen. I looked at do() and it didn't seem to fit what I want.
Bill H
------------------------------
Date: Mon, 16 Jun 2008 04:45:40 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "Gordon Corbin Etly" <gord.c.e@gmail.com>
Subject: Re: Learning Perl
Message-Id: <86tzftr4bf.fsf@blue.stonehenge.com>
>>>>> "Gordon" == Gordon Corbin Etly <gord.c.e@gmail.com> writes:
Gordon> Actaully, yes they do:
Gordon> # perl -e 'my @arr; print int(@arr == undef), "\n"'
Gordon> 1
Gordon> # perl -e 'my %hash; print int(%hash == undef), "\n"'
Gordon> 1
Gordon> If you assign actual values before hand then it prints "0\n"
No, they don't. You really don't grok this very well, and your
test is flawed.
@arr == undef
would be *precisely* the same as
@arr == 0
since "==" forces both of its arguments to numeric values, and undef
as a number is 0.
And @arr in a scalar context (also forced by ==) says nothing about
the contents of the array, but rather the *length*, in this case 0.
So all you've proven is that an array that has not had anything assigned
in it has 0 elements. I think we knew that already. It says *nothing*
about the "undef" "contents", which even as I type it, boggles me.
"undef" is a scalar concept. An array can contain an undef element,
but it doesn't contain that initially. A hash can contain an undef
value, but not an undef key, and again, doesn't contain undef initially.
So, yes, the original "flash card" is incorrect here, and your explanation
only muddies the issue.
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Mon, 16 Jun 2008 09:10:23 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: Learning Perl
Message-Id: <160620080910234982%brian.d.foy@gmail.com>
In article <6bmh95F3c5ntcU1@mid.individual.net>, Gordon Corbin Etly
<gord.c.e@gmail.com> wrote:
> > > What is the syntax for a list literal
> > > ( value1, value2, ....)
> > >
> > > huh? that is a list. literals are possible values in the list.
>
> Actually, you could say a list is a literal representation of an array,
No, you can't say that. It's jut a "list literal", as in one that you
type in yourself and you see the actual values. An array is not part of
that. An array can contain a list, but not every list is contained by
an array. It's the difference between data and variables.
------------------------------
Date: Mon, 16 Jun 2008 14:24:56 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Learning Perl
Message-Id: <x7d4mhjw3r.fsf@mail.sysarch.com>
randal already proved your lack of array-fu. i will leave it at that.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Mon, 16 Jun 2008 09:19:55 -0700
From: "Gordon Corbin Etly" <gord.c.e@gmail.com>
Subject: Re: Learning Perl
Message-Id: <6bni5cF3d330cU1@mid.individual.net>
Randal L. Schwartz wrote:
>>>>>> "Gordon" == Gordon Corbin Etly <gord.c.e@gmail.com> writes:
> Gordon> Actaully, yes they do:
>
> Gordon> # perl -e 'my @arr; print int(@arr == undef), "\n"'
> Gordon> 1
> Gordon> # perl -e 'my %hash; print int(%hash == undef), "\n"'
> Gordon> 1
>
> Gordon> If you assign actual values before hand then it prints "0\n"
> No, they don't. You really don't grok this very well, and your
> test is flawed.
See below for the code I should of used.
> @arr == undef
>
> would be *precisely* the same as
>
> @arr == 0
>
> since "==" forces both of its arguments to numeric values, and undef
> as a number is 0.
Are you sure about that? undef is supposed to be seprate than 0 or '',
so it seems a little odd == wouldn't know the difference. Though you can
just use defined() like I did below.
> And @arr in a scalar context (also forced by ==) says nothing about
> the contents of the array, but rather the *length*, in this case 0.
Ok, you're right about the forcing of scalar context.
Here is what I should of written:
# perl -e 'my @arr; print int(defined(@arr)), "\n"'
0
Now take this:
# perl -e 'my @arr = (123); print int(defined(@arr)), "\n"'
1
So @arr *is* undefined until it's, well, defined. Same goes for a hash.
> So all you've proven is that an array that has not had anything
> assigned in it has 0 elements. I think we knew that already. It
> says *nothing* about the "undef" "contents", which even as I type it,
> boggles me.
See above; scalar, array, hash, they are defined until they are, well,
defined, so until then, they are undef. I'm not sure when this suddenly
became a lost mystery.
> "undef" is a scalar concept. An array can contain an undef element,
> but it doesn't contain that initially. A hash can contain an undef
> value, but not an undef key, and again, doesn't contain undef
> initially.
Then why does defined() return false until the array or hash are
defined?
> So, yes, the original "flash card" is incorrect here, and your
> explanation only muddies the issue.
How is it wrong?
" > > What value do variables hold until defined
" > > undef
Variables *are* undefined until they are, well, you know, _defined_. :)
I would of used a different wording, though, than "What value do
variables hold", but it's not really wrong either.
--
G. C. Etly
------------------------------
Date: Mon, 16 Jun 2008 09:25:41 -0700
From: "Gordon Corbin Etly" <gord.c.e@gmail.com>
Subject: Re: Learning Perl
Message-Id: <6bnig6F3b3ja4U1@mid.individual.net>
brian d foy wrote:
> In article <6bmh95F3c5ntcU1@mid.individual.net>, Gordon Corbin Etly
> <gord.c.e@gmail.com> wrote:
> > > > What is the syntax for a list literal
> > > > ( value1, value2, ....)
> > > >
> > > > huh? that is a list. literals are possible values in the list.
> > Actually, you could say a list is a literal representation of an
> > array,
> No, you can't say that. It's jut a "list literal", as in one that you
> type in yourself and you see the actual values.
Ok, "list literal", doesn't seem quote right. A list is a list. What an
array hold's is a list. Just like a scalar holds 123 or "abc". How is
qw/a 2 c 3 e/ any different?
Consider: [1, 2, 3]
That is a list in an anonymous array. The list is the literal
representation of the array.
Just like in c or C++
int arr[5] = {1, 2, 3, 4, 5};
This was always considered the literal form of arr[0]=1; arrar[1]=2;
...
So how is my @arr = (1, 2, 3, 4 ,5); any different that that?
--
G. C. Etly
------------------------------
Date: Mon, 16 Jun 2008 09:27:30 -0700
From: "Gordon Corbin Etly" <gord.c.e@gmail.com>
Subject: Re: Learning Perl
Message-Id: <6bnijjF396n6sU1@mid.individual.net>
Uri Guttman wrote:
> randal already proved your lack of array-fu. i will leave it at that.
And I posted a better example (admittedly my first one was indeed
flawed.) I how ever am no lacking in the manner you describe. However,
I'm at a loss as to why you made such a pointless reply.
--
G. C. Etly
------------------------------
Date: Mon, 16 Jun 2008 17:18:43 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Learning Perl
Message-Id: <Xns9ABF87671984Dasu1cornelledu@127.0.0.1>
"Gordon Corbin Etly" <gord.c.e@gmail.com> wrote in news:6bni5cF3d330cU1
@mid.individual.net:
> See below for the code I should of used.
s/should of/should have/
...
> Here is what I should of written:
Ditto
>
> # perl -e 'my @arr; print int(defined(@arr)), "\n"'
> 0
>
>
> Now take this:
No, you take this:
C:\> perl -we "my @arr; print int(defined(@arr)), qq{\n}"
defined(@array) is deprecated at -e line 1.
(Maybe you should just omit the defined()?)
0
perldoc -f defined
Use of "defined" on aggregates (hashes and arrays) is
deprecated. It used to report whether memory for that aggregate
has ever been allocated. This behavior may disappear in future
versions of Perl. You should instead use a simple test for size:
if (@an_array) { print "has array elements\n" }
if (%a_hash) { print "has hash members\n" }
*Sigh*
*PLONK*
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Mon, 16 Jun 2008 17:34:03 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Learning Perl
Message-Id: <bc8d54159peso8tt4at7fbk0m9bdnbv2s4@4ax.com>
"Gordon Corbin Etly" <gord.c.e@gmail.com> wrote:
Trying yet another ID besides
<get@bentsys.com>
<getly@bentsys-INVALID.com>
<g.etly@bent-INVALID-sys.com>
<g.etly@bentsys.INVALID.com>
<.@.invalid>
<g@e.nvalid>
<g@e.nvalid>
>Randal L. Schwartz wrote:
>Here is what I should of written:
> # perl -e 'my @arr; print int(defined(@arr)), "\n"'
> 0
>
>Now take this:
>
> # perl -e 'my @arr = (123); print int(defined(@arr)), "\n"'
> 1
>
>So @arr *is* undefined until it's, well, defined. Same goes for a hash.
Which part don't you understand (from perldoc -f defined)?
Use of "defined" on aggregates (hashes and arrays) is
deprecated. It used to report whether memory for that
aggregate
has ever been allocated. This behavior may disappear in
future
versions of Perl.
Adjusting killfile once again.
jue
------------------------------
Date: Mon, 16 Jun 2008 10:37:29 -0700 (PDT)
From: "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Learning Perl
Message-Id: <0b9d4b98-fbbf-443b-bd1a-7de276cf322f@w34g2000prm.googlegroups.com>
On Jun 16, 9:19 am, "Gordon Corbin Etly" <gord....@gmail.com> wrote:
> Randal L. Schwartz wrote:
> >>>>>> "Gordon" == Gordon Corbin Etly <gord....@gmail.com> writes:
> > Gordon> Actaully, yes they do:
>
> > Gordon> # perl -e 'my @arr; print int(@arr == undef), "\n"'
> > Gordon> 1
> > Gordon> # perl -e 'my %hash; print int(%hash == undef), "\n"'
> > Gordon> 1
>
> > Gordon> If you assign actual values before hand then it prints "0\n"
> > No, they don't. You really don't grok this very well, and your
> > test is flawed.
>
> See below for the code I should of used.
>
> > @arr == undef
>
> > would be *precisely* the same as
>
> > @arr == 0
>
> > since "==" forces both of its arguments to numeric values, and undef
> > as a number is 0.
>
> Are you sure about that? undef is supposed to be seprate than 0 or '',
> so it seems a little odd == wouldn't know the difference. Though you can
> just use defined() like I did below.
>
> > And @arr in a scalar context (also forced by ==) says nothing about
> > the contents of the array, but rather the *length*, in this case 0.
>
> Ok, you're right about the forcing of scalar context.
>
> Here is what I should of written:
>
> # perl -e 'my @arr; print int(defined(@arr)), "\n"'
> 0
>
> Now take this:
>
> # perl -e 'my @arr = (123); print int(defined(@arr)), "\n"'
> 1
>
> So @arr *is* undefined until it's, well, defined. Same goes for a hash.
>
> > So all you've proven is that an array that has not had anything
> > assigned in it has 0 elements. I think we knew that already. It
> > says *nothing* about the "undef" "contents", which even as I type it,
> > boggles me.
>
> See above; scalar, array, hash, they are defined until they are, well,
> defined, so until then, they are undef. I'm not sure when this suddenly
> became a lost mystery.
>
> > "undef" is a scalar concept. An array can contain an undef element,
> > but it doesn't contain that initially. A hash can contain an undef
> > value, but not an undef key, and again, doesn't contain undef
> > initially.
>
> Then why does defined() return false until the array or hash are
> defined?
Because defined()'s meaning gets twisty
when dealing with arrays/hashes. Until
memory's been allocated, defined() will
be false but then remain true even if it
gets emptied again:
$ perl -le '@a=(1);print defined @a;@a=();
print defined @a'
1
1
perldoc -q empty
Why does defined() return true on empty
arrays and hashes?
The short story is that you should probably
only use defined on scalars or functions, not
on aggregates (arrays and hashes). See
"defined" in perlfunc in the 5.004 release
or later of Perl for more detail.
perldoc -f defined
Use of "defined" on aggregates (hashes and
arrays) is deprecated. It used to report
whether memory for that aggregate has ever
been allocated. This behavior may disappear
in future versions of Perl.
--
Charles DeRykus
------------------------------
Date: Mon, 16 Jun 2008 00:41:15 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: LWP::Simple getstore with absolute path not working
Message-Id: <g355es024qa@news4.newsguy.com>
emrefan wrote:
> On Jun 16, 5:55 am, "szr" <sz...@szromanMO.comVE> wrote:
>> Ben Morrow wrote:
>>> Quoth emrefan <dksle...@hotmail.com>:
>>>> I am using the following line of sort in a batch file to fetch
>>>> things off the network quickly and mostly I have success but if I
>>>> need to indicate an absolute path in the URL, I always get a "not
>>>> found" error. I have perl 5.8.x, URI.pm 1.36 and URI::URL.pm 5.03
>>>> on the XP system
>>>> where did the test. Help!
>>
>>>> perl -MLWP::Simple -e "getstore( '%1', '%2' );"
>>
>>>> Oh, the exact URL that I tested it was something like this:
>>
>>>> ftp://user:passw...@some.computer.some.where//dir-under-the-root/some-dir/some-file
>>
>>>> I thought the "//" before "dir-under-the-root" should have it
>>>> working for me, but no.
>>
>>> FTP urls don't work like that. The standard hack is
>>
>> Actually the url he gave is mostly correct (should be just one "/"
>> after the host par:
>>
>> ftp://user:passw...@some.computer.some.where/dir-under-the-root/some-dir/some-file
>>
>> This should work just fine.
>>
>> You may want to test it in a browser and then in your script add
>> checks to catch cases where adir or file doesn't exist.
>>
>>> ftp://host/%2fdir-under-the-root/some-dir/some-file
>>
>>> where %2f is a url-encoded '/'; but strictly speaking this requires
>>> your FTP server to support a chdir to '/dir-under-the-root' in one
>>> go, which is not required. Most do, however.
>>
>> Why would it need to do that? Give that url, it should be going to
>> "/fdir-under-the-root/some-dir/some-file" in one go.
>
> When a user logs in via ftp (including when the user is "anonymous"),
> he is placed in wherever is considered his home directory
Actually this is server/config (and client/config) dependant. For
example on my personal system, if I login in as a run of the mill user,
it drops me into my home (actually it chroots unless otherwise specified
for that user in the ftpd config.)
> and if this home directory does not happen to be "/", then the URL
> with just a slash after the hostname is not going to work as intended.
That's because it expects an absolute path. Depending on the ftp
server's configuration, the ftp root that your login "sees" could be in
fact the home dir itself (which is the case when some form of chroot'ing
is used), or the true root of the system, in which case you referernce
your home dir be something like /home/user, depending on the the
platform/OS.
If you want to access directory 'foo' that resides in your home dir, and
your ftp's root / is chroot'ed to your home dir, they this should work:
ftp://server/foo
else, if you are not chrooted (where the ftp's root is the real root of
the system), then
ftp://server/home/johnsmith/foo
is is what you want.
Again, it depends on what / (root) for your ftp login is, which is
dependant on the ftp server software and the platform it runs on.
> I tested that, had problems and so queried. With an "%2f" after
> the hostname, it worked. I reckond I'd call that a bug in
> URI.pm & co. but at least I now have a workaround.
When you login manually via ftp with the same account, and type "cd /"
and they "pwd" or "ls", where do you see your self, in your home
directory, or in the server's real root directory?
Also, do you know what platform your ftp server is running on?
--
szr
------------------------------
Date: Mon, 16 Jun 2008 16:42:39 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: LWP::Simple getstore with absolute path not working
Message-Id: <slrng5cuv0.jnj.hjp-usenet2@hrunkner.hjp.at>
On 2008-06-16 06:34, emrefan <dksleung@hotmail.com> wrote:
> On Jun 16, 5:55 am, "szr" <sz...@szromanMO.comVE> wrote:
>> You may want to test it in a browser and then in your script add checks
>> to catch cases where adir or file doesn't exist.
>>
>> > ftp://host/%2fdir-under-the-root/some-dir/some-file
>>
>> > where %2f is a url-encoded '/'; but strictly speaking this requires
>> > your FTP server to support a chdir to '/dir-under-the-root' in one
>> > go, which is not required. Most do, however.
It should support a chdir to / (if it has a directory called "/"), so
you should be able to write
ftp://host/%2f/dir-under-the-root/some-dir/some-file
then.
>> Why would it need to do that? Give that url, it should be going to
>> "/fdir-under-the-root/some-dir/some-file" in one go.
>
> When a user logs in via ftp (including when the user is "anonymous"),
> he is placed in wherever is considered his home directory and if this
> home directory does not happen to be "/", then the URL with just a
> slash after the hostname is not going to work as intended. I tested
> that, had problems and so queried. With an "%2f" after the hostname,
> it worked. I reckond I'd call that a bug in URI.pm & co. but at least
> I now have a workaround.
It's not a bug. That's how FTP URIs are supposed to work. To quote from
RFC 1738:
| The url-path of a FTP URL has the following syntax:
|
| <cwd1>/<cwd2>/.../<cwdN>/<name>;type=<typecode>
|
| Where <cwd1> through <cwdN> and <name> are (possibly encoded) strings
| and <typecode> is one of the characters "a", "i", or "d".
[...]
| The url-path is interpreted as a series of FTP commands as follows:
|
| Each of the <cwd> elements is to be supplied, sequentially, as the
| argument to a CWD (change working directory) command.
|
| If the typecode is "d", perform a NLST (name list) command with
| <name> as the argument, and interpret the results as a file
| directory listing.
|
| Otherwise, perform a TYPE command with <typecode> as the argument,
| and then access the file whose name is <name> (for example, using
| the RETR command.)
So ftp://host/%2fdir-under-the-root/some-dir/some-file means:
Connect to host and log in as anonymous.
cwd /dir-under-the-root
cwd some-dir
retr some-file
Note that /dir-under-the-root is only a directory under the root on unix
and window systems. Other OSs may have other conventions (once upon a
time, FTP servers running VMS or IBM host OSs were common), and the host
OS may not even have the concept of a "root directory".
hp
------------------------------
Date: Mon, 16 Jun 2008 01:01:03 -0700 (PDT)
From: Grehom <grehom@ntlworld.com>
Subject: Re: Offsetting dates from the past in Date::Manip
Message-Id: <fa31af11-2348-44c0-b1cd-98211896e0aa@j22g2000hsf.googlegroups.com>
On Jun 15, 8:00 pm, "pwar...@gmail.com" <pwar...@gmail.com> wrote:
> I'm trying to use Date::Manip to resolve strings which represent dates
> according to a known reference point - e.g. given a known date, what
> does "Friday" represent?. If I do something like this:
>
> my $date = ParseDate("Friday");
> print $date;
>
> I get the result I expect, i.e. 13/06/08 (assuming I changed the
> format to DD/MM/YY). However, the date used for as the reference point
> is always the current date, and I want to be able to put in an
> arbitrary date and have the reference resolved from there. For
> example, if I use this time last year, "Friday" should be resolved to
> a different date - 15/06/07. Does anyone know if it is possible to do
> this within Date::Manip? I've tried using DateCalc, but this gives me
> an offset from the current date, which isn't really what I want.
>
> Thanks in advance,
>
> Paul
>
> P.S. I'm only dealing with recent dates (1990-present), so there
> shouldn't be any problems with pre-1900 dates etc.
yes, I know you were asking about Date::Manip, but a solution using
Date::Calc is:
#!/usr/bin/perl
use strict;
use warnings;
use Date::Calc qw ( :all );
my @today = Today();
my @year_ago = Add_Delta_YM( Today(), -1, 0 );
my $that_day = Day_of_Week(@year_ago[0..2]);
my $day_reference = 5; # Friday is day 5 of week
my $days_until_reference = ($day_reference - $that_day + 7) % 7;
my @friday_a_year_ago = Add_Delta_YMD( @year_ago, 0, 0,
$days_until_reference);
print Date_to_Text( @friday_a_year_ago[0..2] );
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 1645
***************************************