[26109] in Perl-Users-Digest
Perl-Users Digest, Issue: 8306 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 9 15:22:21 2005
Date: Tue, 9 Aug 2005 12:21:57 -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 Tue, 9 Aug 2005 Volume: 10 Number: 8306
Today's topics:
Re: "anonymous" variable in Perl? <Peter@PSDT.com>
ANNOUNCEMENT: POE 0.32, an event driven component frame <troc@pobox.com>
Re: Any interest in source code repository module/drive <slaven@rezic.de>
Any interest in source code repository module/drivers m <ceo@nospam.on.net>
Re: Any interest in source code repository module/drive <ceo@nospam.on.net>
Bizarre regex behaviour <no@email.com>
Re: Bizarre regex behaviour xhoster@gmail.com
Re: Bizarre regex behaviour <eric-amick@comcast.net>
Re: Bizarre regex behaviour axel@white-eagle.invalid.uk
Re: Bizarre regex behaviour <no@email.com>
Re: Bizarre regex behaviour <eric-amick@comcast.net>
Cloaked eval errors - bug or feature? <bas@quarantainenet.nl>
Comparing XML files <sgrumpa@yahoo.com>
Re: copy contructor (David Combs)
Re: Download Files With a perl script axel@white-eagle.invalid.uk
Re: FAQ 8.27 What's wrong with using backticks in a voi <emschwar@pobox.com>
Re: Feed a directory listing to a script (Anno Siegel)
Re: Feed a directory listing to a script <joe@inwap.com>
Re: Feed a directory listing to a script <chalupa@yomama-nospam.com>
Help with File::Path rmtree <jbl02no@spamhotmail.com>
Re: Help with File::Path rmtree <someone@example.com>
I don't understand what glob does here <ddunham@redwood.taos.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 08 Aug 2005 13:09:19 GMT
From: Peter Scott <Peter@PSDT.com>
Subject: Re: "anonymous" variable in Perl?
Message-Id: <pan.2005.08.08.13.09.07.838611@PSDT.com>
On Thu, 04 Aug 2005 09:04:07 +0000, Anno Siegel wrote:
> The non-standard
> module Time::Piece (available from CPAN) does it for you. It overrides
> localtime() and gmtime() so that they return objects which support
> appropriate methods.
>
> use Time::Piece;
> my $t = localtime;
> ( $day, $month) = ($t->mday, $t->mon);
Unnecessary to use a non-standard module:
% perl
use Time::localtime;
my ($day, $month) = (localtime->mday, localtime->mon);
print "$day $month\n";
^D
8 7
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
------------------------------
Date: Sat, 6 Aug 2005 16:29:48 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: ANNOUNCEMENT: POE 0.32, an event driven component framework
Message-Id: <IKt7sx.L66@zorch.sf-bay.org>
Keywords: multitasking, networking, framework, components, robust, cool
--------
Rejoice!
--------
POE 0.32 has been released. Thanks go out to everyone who helped
develop it.
Highlights of changes since the last announcement:
Scheduled Deprecations, and their Side Effects:
- The POE::Session->new() deprecation continues. The new()
constructor carps when used.
- Signal semantics have changed slightly. Now SIGCHLD andImproved Portability:
- Ed W. patched POE::Wheel::SockteFactory to support non-blocking
connect() under ActiveState Perl. Merijn Broeren patched it so the
non-blocking semantics don't bleed into sockets created through
other means.
- All known issues with POE running under Cygwin have been addressed.
- The core of the Tk event loop bridge has been rewritten, improving
its robustness and portability. It supports loop_do_timeslice(),
and it should be less prone to memory leaks.
- POE's tests now compensate for time fluctuations (especially
negative ones) on machines with variable CPU rates.
New Features:
- POE::Kernel's select() methods have gained pass-through parameters.
Values passed to select() this way will be passed through to event
handlers. It's easier to maintain continuity through file access.
Bug Fixes:
- Jonathan Steinert found and fixed a nasty edge case where event
arguments were not destroyed within the proper context. In rare
cases this would cause bizarre fatal errors.
- Many other bugs were fixed, but they weren't as shockingly bad as
the one listed here.
As if that wasn't enough, POE's web site contains detailed logs for
every public release, ever!
- http://poe.perl.org/?POE_CHANGES
Even now the latest tarball should be hurtling towards your favorite
CPAN mirror. It is also on the web, and so is a Windows PPD! Users
who need advanced notice of changes can follow POE's development in
CVS or discuss new features on the mailing list.
- http://poe.perl.org/?Where_to_Get_POE
- http://poe.perl.org/?POE_Support_Resources
Thanks again to everyone who helped with this release. Keep the
feedback and patches coming.
---------
About POE
---------
POE is a networking and multitasking framework for Perl. It has been
in active development since 1996, and its first public release was in
1998. O'Reilly's The Perl Conference (now part of OSCON) named it
"Best New Module" in 1999.
- http://poe.perl.org/?What_POE_Is
POE's users and developers continue to improve and build upon it. See
the CPAN for the most up-to-date list of POE based modules.
- http://search.cpan.org/search?mode=module&query=POE
POE's robustness and performance have made it an integral part of
mission critical applications since its first release. It is used in
several fields, and in projects ranging from just a few lines of code
to hundreds of thousands.
- Financial:
Market servers, clients, billing systems, and automated trading
agents.
- Web:
Commerce servers, content management systems, application servers,
data warehouses, WAP proxies, ad exchanges, web crawlers/spiders,
and a variety of specialized agents.
- System Administration:
Large-scale host monitors and maintenance agents, distributed load
testers, a distributed file system (InterMezzo), radius monitors,
system log managers and reports, SNMP monitors, and spam detectors.
- Entertainment:
Interactive TV servers; mp3 jukeboxes and streaming servers; game
server monitors, managers, and tournament controllers; and a
plethora of IRC applications, services, and agents (bots).
- Software Development:
Compile farm managers, build managers, distributed testing
frameworks.
- Monitoring and Automation:
X10 home control systems, weather station monitors, alarm monitors.
We look forward to hearing how POE has helped you.
--
Rocco Caputo - rcaputo@cpan.org - http://poe.perl.org/
------------------------------
Date: 07 Aug 2005 22:06:53 +0200
From: Slaven Rezic <slaven@rezic.de>
Subject: Re: Any interest in source code repository module/drivers modeled after DBI?
Message-Id: <87oe89qzoi.fsf@vran.herceg.de>
ChrisO <ceo@nospam.on.net> writes:
[...]
There's already VCS at CPAN: "Library for generic Version Control
System access in Perl". Unfortunately development seems to be stalled,
but at least the namespace and the idea are there.
Regards,
Slaven
--
Slaven Rezic - slaven <at> rezic <dot> de
BBBike - route planner for cyclists in Berlin
WWW version: http://www.bbbike.de
Perl/Tk version for Unix and Windows: http://bbbike.sourceforge.net
------------------------------
Date: Sun, 07 Aug 2005 14:50:06 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Any interest in source code repository module/drivers modeled after DBI?
Message-Id: <ycpJe.33$Zh2.29@newssvr17.news.prodigy.com>
At a job site a long time ago in a galaxy far, far away, a team labored
and toiled to use Perl as a build/deploy management framework to build
and deploy large J2EE apps calling external tools such as Ant to do the
dirty work. Perl was the framework driver and all the little tools were
the robot wenches...
Turns out, the company requiring work on the DeathStar project mandated
we use their source code repository, but couldn't decide at the time
what source code repository it was going to stay with and during the
first part of the project we changed SCR's 3 times! So when we went to
version 2 of the project, I decided to use a little Jedi/Perl magic and
wrote the pieces in the overall build/deploy framework to get, put,
checkin, checkout, label, etc. code from SCR in a generic way, modeled
after DBI. I was determined that one should never have to know the
underlying SCR tool for basic SCR functions just like for DBI (add,
update, delete records, etc). If Darthy baby asked us to change the SCR
again, we would just write the driver for the new SCR and the code above
would never have to change.
I've been sitting on this code for a while now. I have the SCR
framework, which I called simply "SCR" (like "DBI") that loads an
appropriate underlying SCR "driver" for VSS, CVS, Subversion, MKS, PVCS,
etc. and, as I said, abstracts a consistent call interface to Perl for
scripts to use. Before I do the work to release it into open source, I
just wonder if there is any interest in something like this? Since I
modeled it after DBI, I think it would be the approiate thing to
publicly release this code as well, but if no one cares, then I don't
want to take the time and effort to do it.
Additionally, I only have a VSS driver written and some CVS driver code
written. I have no driver code written for anything else (PVCS,
Subversion, MKS, etc.), but that's the beauty of the design and open
source. Someone can come along and write the appropriate driver for
other third party SCR engines.
Scant examples:
## Connect format is basically:
## SCR->connect( driver-sig, username, password, [specific options] );
my $scr = SCR->connect( 'scr:vss', 'chris', 'perlr0cks', SSDIR =>
"blah", REPOSITORY => "c:\\My\\Repository" );
## or
my $scr = SCR->connect( 'scr:cvs', 'chris', 'perlr0cks', PSERVER =>
"blah" ); # Or something like this; I have to check my CVS implem.
my $scr = SCR->connect( 'scr:cvs', 'chris', 'perlr0cks', CVSROOT =>
"blah" ); # Or something like this; I have to check my CVS implem.
## Then, methods are basically:
## $scr->method( general options first, any SCR specific opts last );
## (And overall, I've been quite able to avoid the later).
$scr->add( blah options );
$scr->get( blah options );
$scr->put( blah options );
$scr->checkin( blah options );
$scr->ci( blah options ); # Synonym for checkin()
$scr->checkout( blah options );
$scr->co( blah options ); # Synonym for checkout()
$scr->label( blah options );
$scr->remove( blah options );
...etc...
(Okay, I have to admit, I modeled a lot of the method names after CVS
command names...!)
Speak up here if anyone wants me to go ahead with this or you can
contact me at "PerlJunkie" on GMail. It's been great using SCR, and I
thought maybe others would like this?
(One can even, using this module, build a project over multiple
repository types, say CVS and PVCS, and never even know the difference.
It also helps make absolutely horrible software like VSS "appear" to
behave halfway decently since Perl can abstract things like recursive
labeling -- native VSS has horrible labeling options among other things!
-- when the underlying SCR doesn't really support it.)
-ceo
------------------------------
Date: Sun, 07 Aug 2005 23:31:11 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: Any interest in source code repository module/drivers modeled after DBI?
Message-Id: <3RwJe.38$O07.5@newssvr23.news.prodigy.net>
Slaven Rezic wrote:
> ChrisO <ceo@nospam.on.net> writes:
>
> [...]
>
> There's already VCS at CPAN: "Library for generic Version Control
> System access in Perl". Unfortunately development seems to be stalled,
> but at least the namespace and the idea are there.
>
Thanks for pointing this out. I looked around quickly and didn't come
across anything other than a wrapper for VSS and it was definitely VSS
specific. (Though by all this I admit I searched *very* quickly... :-))
I'll check VCS out. I don't want to duplicate any effort, nor, as I
said, invest any effort if there is no interest in such a thing.
-ceo
------------------------------
Date: Fri, 05 Aug 2005 22:55:00 +0100
From: Brian Wakem <no@email.com>
Subject: Bizarre regex behaviour
Message-Id: <3li5hkF12q30fU1@individual.net>
This is driving me mad. I've been chasing a bug in a program for 3hrs, I
have narrowed it down to this complete and working code.
This is the *exact code* I am running, followed by the actual output.
I've tried it on two machines, which run different versions of perl and I
get the same result.
Please, someone tell me what the hell is going on here, why doesn't the
regex in sub1 match the 3rd and 4th time through?
#!/usr/bin/perl
use strict;
use warnings;
sub1();
sub1();
if ('a' =~ m/a/) {
sub1();
}
sub1();
sub sub1 {
print "This is sub1\n";
if ('someword' =~ m//) {
print "Regex matches\n";
}
else {
print "Regex does not match, what on Earth is going on here?\n";
}
}
$ perl -v
This is perl, v5.8.6 built for i386-linux
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2004, Larry Wall
Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
$ perl tmp37.pl
This is sub1
Regex matches
This is sub1
Regex matches
This is sub1
Regex does not match, what on Earth is going on here?
This is sub1
Regex does not match, what on Earth is going on here?
$
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 05 Aug 2005 22:40:11 GMT
From: xhoster@gmail.com
Subject: Re: Bizarre regex behaviour
Message-Id: <20050805184011.030$d2@newsreader.com>
Brian Wakem <no@email.com> wrote:
> This is driving me mad. I've been chasing a bug in a program for 3hrs, I
> have narrowed it down to this complete and working code.
>
> This is the *exact code* I am running, followed by the actual output.
>
> I've tried it on two machines, which run different versions of perl and I
> get the same result.
>
> Please, someone tell me what the hell is going on here, why doesn't the
> regex in sub1 match the 3rd and 4th time through?
As documented in perldoc perlretut,
If the regexp evaluates to the empty string, the
regexp in the last successful match is used instead.
This seems like a mal-feature to me, but there you have it.
Note thst sub1 uses an empty string as the regex.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> sub1();
At this point, there is no last successful match. I would consider the
behavior to be undefined. Apparently perl just uses an actual empty regex,
which of course matches anything.
> sub1();
At this point, it uses the last successful regex, again the empty one.
> if ('a' =~ m/a/) {
> sub1();
At this point, sub1 uses the last successful regex, which is /a/
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sat, 06 Aug 2005 09:44:38 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: Bizarre regex behaviour
Message-Id: <lgf9f15sitn9muhrcka7on0cpou85ie471@4ax.com>
On 05 Aug 2005 22:40:11 GMT, xhoster@gmail.com wrote:
>Brian Wakem <no@email.com> wrote:
>> This is driving me mad. I've been chasing a bug in a program for 3hrs, I
>> have narrowed it down to this complete and working code.
>>
>> This is the *exact code* I am running, followed by the actual output.
>>
>> I've tried it on two machines, which run different versions of perl and I
>> get the same result.
>>
>> Please, someone tell me what the hell is going on here, why doesn't the
>> regex in sub1 match the 3rd and 4th time through?
>
>
>As documented in perldoc perlretut,
>
> If the regexp evaluates to the empty string, the
> regexp in the last successful match is used instead.
>
>This seems like a mal-feature to me, but there you have it.
It exists because of historical precedent, I think--a number of Unix
editors treat an empty regex that way to reduce typing when doing a
substitution repeatedly.
--
Eric Amick
Columbia, MD
------------------------------
Date: Sat, 06 Aug 2005 14:24:59 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Bizarre regex behaviour
Message-Id: <%K3Je.11230$ia4.9268@fe1.news.blueyonder.co.uk>
Eric Amick <eric-amick@comcast.net> wrote:
> On 05 Aug 2005 22:40:11 GMT, xhoster@gmail.com wrote:
>>Brian Wakem <no@email.com> wrote:
>>As documented in perldoc perlretut,
>>
>> If the regexp evaluates to the empty string, the
>> regexp in the last successful match is used instead.
>>
>>This seems like a mal-feature to me, but there you have it.
> It exists because of historical precedent, I think--a number of Unix
> editors treat an empty regex that way to reduce typing when doing a
> substitution repeatedly.
For searching rather than substitution. Vi for example, as in Perl,
a substitution with an empty string is always taken to mean
that there should be a deletion. Which is quite logical.
Axel
------------------------------
Date: Sat, 06 Aug 2005 16:30:00 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Bizarre regex behaviour
Message-Id: <3lk3bpF12sk1gU1@individual.net>
Eric Amick wrote:
> It exists because of historical precedent, I think--a number of Unix
> editors treat an empty regex that way to reduce typing when doing a
> substitution repeatedly.
>
Unfortunately I was relying on an empty string always matching. It took me
ages to narrow down what could be wrong. The work-around was trivial and
took seconds, but if I had known about this before I could have saved
myself oodles of time, I shall certainly not fall into that trap again. Oh
well, we live and learn.
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: Sat, 06 Aug 2005 22:48:11 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: Bizarre regex behaviour
Message-Id: <qbtaf1tbu60glqqi7v85karppvkv16i1hr@4ax.com>
On Sat, 06 Aug 2005 14:24:59 GMT, axel@white-eagle.invalid.uk wrote:
>Eric Amick <eric-amick@comcast.net> wrote:
>> On 05 Aug 2005 22:40:11 GMT, xhoster@gmail.com wrote:
>>>Brian Wakem <no@email.com> wrote:
>
>>>As documented in perldoc perlretut,
>>>
>>> If the regexp evaluates to the empty string, the
>>> regexp in the last successful match is used instead.
>>>
>>>This seems like a mal-feature to me, but there you have it.
>
>> It exists because of historical precedent, I think--a number of Unix
>> editors treat an empty regex that way to reduce typing when doing a
>> substitution repeatedly.
>
>For searching rather than substitution. Vi for example, as in Perl,
>a substitution with an empty string is always taken to mean
>that there should be a deletion. Which is quite logical.
I was thinking of the target of the substitution, i.e., the string to be
replaced, when I said that, but you have a point about searching in
general.
--
Eric Amick
Columbia, MD
------------------------------
Date: Tue, 09 Aug 2005 11:44:56 +0200
From: Bas van Sisseren <bas@quarantainenet.nl>
Subject: Cloaked eval errors - bug or feature?
Message-Id: <dd9tup$vka$1@netlx020.civ.utwente.nl>
Hi,
I recently found out i was using a 'local $@' and a 'die' in the same code
block by mistake. The result was an eval error which was cloaked by the
'local $@'. It seems to me this is not the behaviour someone would expect
of this combination.
I'm using perl v5.8.7 from debian sid.
Some examples:
=====[ Example #1 ]=====
#!/usr/bin/perl -w
$@='';
eval {
print "1\n";
eval {
print "2\n";
{
local $@;
die "something";
}
print "3\n";
};
die $@ if $@;
print "4\n";
};
if ($@) {
print "Exception caught: $@";
} else {
print "OK\n";
}
=======[ Result ]=======
1
2
4
OK
========================
The exception isn't caught in the 'die $@ if $@', therefore it isn't
possible anymore to rethrow this exception. It seems like the inner eval
didn't have any problems.
=====[ Example #2 ]=====
#!/usr/bin/perl -w
$@='';
eval {
print "1\n";
eval {
$@="hi there";
print "2\n";
{
local $@;
# die "something";
}
print "3\n";
};
die $@ if $@;
print "4\n";
};
if ($@) {
print "Exception caught: $@";
} else {
print "OK\n";
}
=======[ Result ]=======
1
2
3
4
OK
========================
Normal, expected, behaviour. At the end of the outer eval, the $@ variable
is cleared.
=====[ Example #3 ]=====
#!/usr/bin/perl -w
$@='';
eval {
print "1\n";
eval {
$@="hi there";
print "2\n";
{
local $@;
die "something";
}
print "3\n";
};
die $@ if $@;
print "4\n";
};
if ($@) {
print "Exception caught: $@";
} else {
print "OK\n";
}
=======[ Result ]=======
1
2
Exception caught: hi there at ./eval_test.pl line 16.
========================
Now, the previous $@ is inserted back into the $@ variable. We now have
caught an exception in the outer eval, which was never thrown.
Solution?
I think the $@ should not be set in the code-block of the die itself, but at
the point where code execution resumes, at the end of the eval{} block.
--
Bas van Sisseren
------------------------------
Date: Mon, 08 Aug 2005 18:22:57 -0700
From: Rumpa <sgrumpa@yahoo.com>
Subject: Comparing XML files
Message-Id: <dd90hh$2pab$1@heap.juniper.net>
Hi,
I have an XML file which has holds actual result. I have another XML file which has the expected result. I need to compare these two and see if they
are the same. Whitspaces and placement of the elements might be diferent. What is the best way to handle this?
Example:
Got this result:
<store>
<book>
<name>XYZ</name>
<author>ABC</author>
</book>
</store>
Expected result:
<store>
<book>
<author> ABC </author>
<name> XYZ </name>
</book>
</store>
Thanks,
Rumpa
------------------------------
Date: Tue, 9 Aug 2005 10:57:47 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: copy contructor
Message-Id: <dda27a$jc0$1@reader2.panix.com>
In article <dbjq74$jgn$1@mamenchi.zrz.TU-Berlin.DE>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
>> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
>> news:dbje2p$cp9$1@mamenchi.zrz.TU-Berlin.DE:
>>
>> > The code for the base class is mostly unchanged. The only difference
>> > is that it inserts a do-nothing method (one that just returns its
>> > object) into all of its accessors (not in other methods). So if the
>> > accessor was
>> >
>> > sub alpha { $_[ 0]->[ 0] }
>> >
>> > it becomes
>> >
>> > sub alpha { $_[ 0]->parent->[ 0] }
>> > # ...
>> > sub parent { shift }
>>
>> [ rest of the discussion and code snipped ]
>>
>> Anno:
>>
>> I wanted to thank you very much for this series of posts, especially
>> this last one. I found it very informative.
>
>Thankyou. It's nice to be appreciated. [As Brian (Nobull) just said in
>another thread.]
>
>In fact, I think I'll make a (not much) more extensive writeup of this
>material and put it on the web (at least). The final trick deserves
>publicity, if I say so myself, but even without it, more awareness of
>accessors and their significance would help OO programming in Perl.
>
>Anno
WHERE, WHERE?
WHEN, WHEN?
IF, IF?
Thanks from *lots* of people!
David
------------------------------
Date: Fri, 05 Aug 2005 20:04:48 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Download Files With a perl script
Message-Id: <ADPIe.8264$ia4.3808@fe1.news.blueyonder.co.uk>
heli0s <heli0s@localhost.localdomain> wrote:
>>> I'm having a bit of a problem with a script I'm writing. I want the script
>>> to read in a txt file with a list of files to download and then go through
>>> the list of files to get them from the net.
>>> it should be something like this:
>>> use LWP::Simple;
>>>
>>> open (FILE,"all.m3u");
>>> @file = <FILE>;
>>> close FILE;
>>>
>>> foreach $line (@file){
>>> get ( $line );
>>> }
>>> As seen in the above code, i've been looking at LWP::Simple, but what i
>>> have here is no good. Maybe i'm doing something wrong but i havent figured
>>> it out yet.
>> Do you have a sample of a couple of lines from all.m3u?
> there something like this:
> http://my.site.org/Albums/Asian%20Dub%20Foundation%20-%20Community
> %20Music/Asian%20Dub%20Foundation%20-%2001%20-%20real%20great%20britain.mp3
> (with all the spaces. Getting them out is kinda out of the question
> unfortunately)
The spaces should not be causing a problem.
Nor should not chomping the input from the file as in your original script,
although it is very bad practice not to.
Maybe the URLs are not correct or that you are getting an error
response. A quick way of checking is to use lynx or
another browser to see if you can pull one up.
One possible reason for getting an error response is a site
refusing to return documents based on the User Agent. In
that case you could use LWP::UserAgent and give an agent
name such as 'Mozilla' which should fool the site.
Axel
------------------------------
Date: Tue, 09 Aug 2005 11:50:59 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: FAQ 8.27 What's wrong with using backticks in a void context?
Message-Id: <etopssndmnw.fsf@wilson.emschwar>
PerlFAQ Server <comdog@panix.com> writes:
> 8.27: What's wrong with using backticks in a void context?
<snip>
> this code could and probably should be written as
>
> system("cat /etc/termcap") == 0
> or die "cat program failed!";
>
> which will get the output quickly (as it is generated, instead of only
> at the end) and also check the return value.
Er, no it won't. Using system() guarantees that the output won't go
anywhere (except stdout and/or stderr). I suspect 'get' here really
means 'print'. As it is, enough people are confused about when to use
`` and when to use system(); they don't need more help from the FAQ!
:)
How about rewording this as:
... which will echo the cat command's output as it is generated,
instead of waiting until the program has completed to print it
out, and also checks the return value.
Better yet, maybe an example which doesn't print output to the screen
might be more helpful, since it won't confuse the issue between
printing to STDOUT from within perl, or from within the exec()'d
program; maybe something like "cp file1 file2"?
-=Eric
------------------------------
Date: 8 Aug 2005 09:51:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Feed a directory listing to a script
Message-Id: <dd79u9$ot5$1@mamenchi.zrz.TU-Berlin.DE>
Shabam <chalupa@yomama-nospam.com> wrote in comp.lang.perl.misc:
> I have a command script that backs up a user account. This involves moving
> files from different directories into an archive.
>
> Now, I need that script to back up all user accounts on the system, by going
> through the directory structure and running the backup script on each one.
> Can someone show me how this can be done? I'm not a perl programmer and
> have only dabbled a bit in it.
>
> My directory structure is like this:
>
> /Users/0/
> /Users/1/
> /Users/2/
> /Users/3/
> ... so on...
>
> User account names reside in those folders, so user jason would be in
> "Users/j/jason".
So what have you tried so far, and how does it fail?
> Please don't tell me to just tar/gz the /Users/ directory. That will not
> work for this because it will be greater than 4GBs,
So?
> and it won't allow me to
> restore accounts individually.
Ah, but it does. The problem is, you'd have to read through the entire
tar file, but you can restore any selection of files you want.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: Mon, 08 Aug 2005 13:00:54 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Feed a directory listing to a script
Message-Id: <C8udnVaHU6iXJ2rfRVn-iw@comcast.com>
Shabam wrote:
> I have a command script that backs up a user account. This involves moving
> files from different directories into an archive.
>
> Now, I need that script to back up all user accounts on the system, by going
> through the directory structure and running the backup script on each one.
Here is a hint:
perl -le 'while(($user,$pw,$uid,$gid,$q,$c,$name,$home)=getpwent){print
"~$user = $home for $name" if $uid > 100}'
> Can someone show me how this can be done? I'm not a perl programmer and
> have only dabbled a bit in it.
OK, here's another hint. Replace the print() part with this:
system "tar cvf $user.tar $home >$user.dir 2>>error.log";
-Joe
P.S. Next time, do not include comp.lang.perl; it has been replaced
by the comp.lang.perl.misc newsgroup.
------------------------------
Date: Mon, 8 Aug 2005 20:57:44 -0700
From: "Shabam" <chalupa@yomama-nospam.com>
Subject: Re: Feed a directory listing to a script
Message-Id: <U-adnaqBQdPTqGXfRVn-sQ@adelphia.com>
> > Please don't tell me to just tar/gz the /Users/ directory. That will
not
> > work for this because it will be greater than 4GBs,
>
> So?
You don't get it do you?
------------------------------
Date: Sun, 07 Aug 2005 12:25:07 GMT
From: jbl <jbl02no@spamhotmail.com>
Subject: Help with File::Path rmtree
Message-Id: <42vbf1d3jce4b61gmu9fecrq4b38c9ddeb@4ax.com>
I have read the text in the description of the manpage, including
* All of the files and directories below each root, as well as the
roots themselves, will be deleted.
Using the instance below, I just want to be sure that folder/directory
00423, is the only one that will be removed, and not anything above
it.
#/usr/bin/perl
use strict;
use warnings;
use File::Path;
rmtree(["C:\Documents and Settings\user\My Documents\00423\"], 1, 1);
thanks
jbl
------------------------------
Date: Sun, 07 Aug 2005 14:34:13 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help with File::Path rmtree
Message-Id: <FZoJe.161695$HI.159280@edtnps84>
jbl wrote:
> I have read the text in the description of the manpage, including
>
> * All of the files and directories below each root, as well as the
> roots themselves, will be deleted.
>
> Using the instance below, I just want to be sure that folder/directory
> 00423, is the only one that will be removed, and not anything above
> it.
>
> #/usr/bin/perl
> use strict;
> use warnings;
> use File::Path;
>
> rmtree(["C:\Documents and Settings\user\My Documents\00423\"], 1, 1);
I can tell you without even testing it that that expression as written
will definitely NOT work.
Try running a Perl program with just this one line:
print "C:\Documents and Settings\user\My Documents\00423\";
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 06 Aug 2005 01:35:33 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: I don't understand what glob does here
Message-Id: <FtUIe.2670$fJ1.1378@newssvr13.news.prodigy.com>
I don't understand the behavior of the following...
$ touch "file"
$ perl -e 'foreach $num (0 .. 4) { print "$num .. "; print (scalar glob("file")); print " "; print (scalar glob("file")); { print " ok\n"; } }'
0 .. file file ok
1 .. ok
2 .. file file ok
3 .. ok
4 .. file file ok
I thought that if I were to get "undef" returned on the second scalar
invocation, I would have seen one "file" in each iteration, not 2
successful followed by 2 unsuccessful.
Why does the behavior change between iterations of the foreach loop
here? I've read through glob and File::Glob and I haven't seen anything
that appears to explain this.
Thanks.
--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
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 V10 Issue 8306
***************************************