[24381] in Perl-Users-Digest
Perl-Users Digest, Issue: 6570 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 16 09:06:17 2004
Date: Sun, 16 May 2004 06: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 Sun, 16 May 2004 Volume: 10 Number: 6570
Today's topics:
Re: Archive::Zip and File::Find error? <usenet@morrow.me.uk>
Re: Archive::Zip and File::Find error? <geoffacox@dontspamblueyonder.co.uk>
Re: Archive::Zip and File::Find error? <geoffacox@dontspamblueyonder.co.uk>
Re: Archive::Zip and File::Find error? <usenet@morrow.me.uk>
Re: Archive::Zip and File::Find error? <usenet@morrow.me.uk>
Re: Archive::Zip and File::Find error? <geoffacox@dontspamblueyonder.co.uk>
Re: Dynamic Menus in Perl <jwillmore@remove.adelphia.net>
Re: Favorite Editor for Perl programming <matternc@comcast.net>
Re: Favorite Editor for Perl programming <matternc@comcast.net>
Re: Favorite Editor for Perl programming <spamtrap@dot-app.org>
Re: Favorite Editor for Perl programming <bart.lateur@pandora.be>
IF problem?! <tihana@kata.com>
Re: IF problem?! <depesz@depesz.pl>
Re: IF problem?! <jurgenex@hotmail.com>
Re: IF problem?! <tihana@kata.com>
Re: IF problem?! <eric-amick@comcast.net>
Re: lookahead or lookbehind <krahnj@acm.org>
Re: Q: using perldoc to read a file <usenet@morrow.me.uk>
Re: Request: Statistical analysis - Event detection <christian3110@noos.fr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 15 May 2004 23:03:27 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Archive::Zip and File::Find error?
Message-Id: <c867jv$h0l$2@wisteria.csv.warwick.ac.uk>
Quoth Geoff Cox <geoffacox@dontspamblueyonder.co.uk>:
> The following code should unzip all the zip files (which only contain
> 1 doc file each) in the folders within the d:/files folder. It isn't
> working - where is it wrong?!
>
> #!perl
> use warnings;
> use strict;
> use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
> use File::Find;
>
> my $dir = 'd:/files';
>
> find sub {
> #my $name = $_;
Please sort out your indentation.
> return if -d;
>
> my $zip = Archive::Zip->new();
> die "Error reading $name:$!" unless $zip->read( $name ) == AZ_OK;
$name is not set.
> $zip->read($_);
Why don't you check this one?
> $zip->extractTree($name) ;
>
> }, $dir;
Please post your actual code, and give a better description of what is
happening than 'it isn't working'. Have you read the Posting Guidelines?
Ben
--
We do not stop playing because we grow old;
we grow old because we stop playing.
ben@morrow.me.uk
------------------------------
Date: Sun, 16 May 2004 07:06:18 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: Archive::Zip and File::Find error?
Message-Id: <fb4ea0pdgk4bmb1380tmcpc99e426cnl9q@4ax.com>
On Sat, 15 May 2004 23:03:27 +0000 (UTC), Ben Morrow
<usenet@morrow.me.uk> wrote:
Ben
thanks for your reply - I have improved the indentation I hope and
changed the code a little.
The aim is to go through all the sub folders of the d:\files folder
and extract all the MS Word .doc files in all the zip files. There is
only 1 .doc file in each zip file.
When running the script it works on some of the files within one of
the sub folders but then I get the error message
"can't open nameofzipfile.zip: no such file or directory at
d:/perl/lib/File/Find.pm line 888"
IT also puts a copy of the .doc file from the above zip file in each
of the other folders!
Something simple somewhere I guess?
Cheers
Geoff
#!perl
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use File::Find;
my $dir = 'd:/files';
my $zip = Archive::Zip->new();
find sub {
if ( $_ =~ /zip/ ) {
return if -d;
die "Error reading $_:$!" unless $zip->read($_) == AZ_OK;
$zip->extractTree();
}
}, $dir;
------------------------------
Date: Sun, 16 May 2004 07:20:44 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: Archive::Zip and File::Find error?
Message-Id: <rc5ea0p1r5fkumm2ddduihu71jcuosrsld@4ax.com>
On Sun, 16 May 2004 07:06:18 GMT, Geoff Cox
<geoffacox@dontspamblueyonder.co.uk> wrote:
Ben
I have found the problem/soved it - perhaps you can help me understand
the reason why
I needed to move "my $zip = Archive::Zip->new();" into the find sub,
as below..a new instance had to be created for each folder?
Cheers
Geoff
#!perl
use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
use File::Find;
my $dir = 'd:/files';
find sub {
my $zip = Archive::Zip->new();
if ( $_ =~ /zip/ ) {
return if -d;
die "Error reading $_:$!" unless $zip->read($_) == AZ_OK;
$zip->extractTree();
}
}, $dir;
------------------------------
Date: Sun, 16 May 2004 09:34:06 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Archive::Zip and File::Find error?
Message-Id: <c87cie$rht$1@wisteria.csv.warwick.ac.uk>
Quoth Geoff Cox <geoffacox@dontspamblueyonder.co.uk>:
> On Sat, 15 May 2004 23:03:27 +0000 (UTC), Ben Morrow
> <usenet@morrow.me.uk> wrote:
>
> Ben
>
> thanks for your reply - I have improved the indentation I hope and
> changed the code a little.
>
> The aim is to go through all the sub folders of the d:\files folder
> and extract all the MS Word .doc files in all the zip files. There is
> only 1 .doc file in each zip file.
>
> When running the script it works on some of the files within one of
> the sub folders but then I get the error message
>
> "can't open nameofzipfile.zip: no such file or directory at
> d:/perl/lib/File/Find.pm line 888"
>
> IT also puts a copy of the .doc file from the above zip file in each
> of the other folders!
>
> Something simple somewhere I guess?
My guess would be that by changing things in the filesystem within your
find sub you are confusing File::Find. Try this instead:
my $dir = 'd:/files';
my @zips;
find sub {
-d and return;
/\.zip$/ and push @zips, [$File::Find::dir, $_];
}, $dir;
my $zip = Archive::Zip->new;
for (@zips) {
chdir $_->[0] or die "can't chdir to $_->[0]: $!";
$zip->read($_->[1]) == AZ_OK or die "can't read $_->[1]";
$zip->extractTree == AZ_OK or die "can't extract $_->[1]";
}
Ben
--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** ben@morrow.me.uk
------------------------------
Date: Sun, 16 May 2004 09:39:32 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Archive::Zip and File::Find error?
Message-Id: <c87csk$rht$2@wisteria.csv.warwick.ac.uk>
Quoth Geoff Cox <geoffacox@dontspamblueyonder.co.uk>:
> On Sun, 16 May 2004 07:06:18 GMT, Geoff Cox
> <geoffacox@dontspamblueyonder.co.uk> wrote:
>
> Ben
>
> I have found the problem/soved it - perhaps you can help me understand
> the reason why
>
> I needed to move "my $zip = Archive::Zip->new();" into the find sub,
> as below..a new instance had to be created for each folder?
Oh yes, that's right: Archive::Zip->read reads new members from the
given zip and *adds* them to the archive. It is quite clever about
keeping some of the archive in memory and leaving the rest on disk:
presumably it died the first time it tried to go back to the disk for
one of the early archives and couldn't find it any more because you'd
changed directory.
>
> Cheers
>
> Geoff
>
> #!perl
> use warnings;
> use strict;
> use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
> use File::Find;
>
> my $dir = 'd:/files';
>
> find sub {
>
> my $zip = Archive::Zip->new();
>
> if ( $_ =~ /zip/ ) {
>
> return if -d;
>
> die "Error reading $_:$!" unless $zip->read($_) == AZ_OK;
You can move the ->new down here: no need to do it for things you're
skipping:
my $zip = Archive::Zip->new($_) or die "Error reading $_";
> $zip->extractTree();
>
> }
>
> }, $dir;
>
--
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
------------------------------
Date: Sun, 16 May 2004 12:03:06 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: Archive::Zip and File::Find error?
Message-Id: <o1mea0tmnm2ru2uaibpejjgpm95rn5jpte@4ax.com>
On Sun, 16 May 2004 09:39:32 +0000 (UTC), Ben Morrow
<usenet@morrow.me.uk> wrote:
>
>Quoth Geoff Cox <geoffacox@dontspamblueyonder.co.uk>:
>> On Sun, 16 May 2004 07:06:18 GMT, Geoff Cox
>> <geoffacox@dontspamblueyonder.co.uk> wrote:
>>
>> Ben
>>
>> I have found the problem/soved it - perhaps you can help me understand
>> the reason why
>>
>> I needed to move "my $zip = Archive::Zip->new();" into the find sub,
>> as below..a new instance had to be created for each folder?
>
>Oh yes, that's right: Archive::Zip->read reads new members from the
>given zip and *adds* them to the archive. It is quite clever about
>keeping some of the archive in memory and leaving the rest on disk:
>presumably it died the first time it tried to go back to the disk for
>one of the early archives and couldn't find it any more because you'd
>changed directory.
Ben
OK, thanks for the explanation.
Cheers
Geoff
------------------------------
Date: Sat, 15 May 2004 23:17:23 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Dynamic Menus in Perl
Message-Id: <pan.2004.05.16.03.17.19.483274@remove.adelphia.net>
On Sun, 16 May 2004 02:37:04 +0930, Timothy Casey wrote:
> I am wondering if dynamic (multi-tiered dropdown/fold-out) menus are
> possible to impliment using a cgi/perl script. A problem with CSS & large
> sites is remembering to edit the menu on every page! I imagine that a
> reference to a single perl script might simplify things.
[ ... ]
Look over the Template Toolkit (http://www.template-toolkit.org/). In
fact, one of the examples given in the module deals with menus.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"Every time I think I know where it's at, they move it."
------------------------------
Date: Sat, 15 May 2004 21:13:50 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Favorite Editor for Perl programming
Message-Id: <VrKdnYgqY7TTXTvd4p2dnA@comcast.com>
Sherm Pendley wrote:
> Tad McClellan wrote:
>
>> Edward Wijaya <ewijaya@singnet.com.sg> wrote:
>>
>>> Is X(Emacs) better than vi(M)?
>>
>> Yes.
>
>>> Is X(Emacs) better than vi(M)?
>>
>>
>> No.
>
> The truth is finally revealed - Tad's an elf. ;-)
>
"Go not to the elves for counsel, but *do* read their
posting guidelines..."
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Sat, 15 May 2004 21:15:30 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Favorite Editor for Perl programming
Message-Id: <VrKdnYsqY7QvXTvd4p2dnA@comcast.com>
John Bokma wrote:
> knowsitall wrote:
>
>> No. But vi will be close second after vim. Then come (in this order):
>> emacs
>> xemacs
>> editor
>
> copy con: script
>
>> notepad
>> ms word.
>
No, notepad is better than copy con:. copy con: IS better than MS Word,
though. Using MS Word to write anything that needs to be plain ASCII
text is like trying to pound in a nail with a screwdriver.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Sat, 15 May 2004 22:20:04 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Favorite Editor for Perl programming
Message-Id: <57qdna19PalJUjvdRVn-sQ@adelphia.com>
Chris Mattern wrote:
> Using MS Word to write anything that needs to be plain ASCII
> text is like trying to pound in a nail with a screwdriver.
I *have* used a screwdriver, and occasionally a crescent wrench to pound a
nail. I also stomped a nail flush with steel-toed boots once - it tripped
me and I was angry. ;-)
But editing ASCII with MS Word? That's just crazy talk...
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sun, 16 May 2004 07:36:07 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Favorite Editor for Perl programming
Message-Id: <ke6ea05vb8ihlh39v1fba8og8i67or30i3@4ax.com>
Edward Wijaya wrote:
>Is X(Emacs) better than vi(M)?
>How does one fare to another?
>Or there is other better choice?
Aaaaaarghhhh!!!......
* runs away screaming *
--
Bart.
------------------------------
Date: Sun, 16 May 2004 13:20:21 +0200
From: <tihana@kata.com>
Subject: IF problem?!
Message-Id: <c87ip2$nk4$1@ls219.htnet.hr>
How is possible that My printout prints all value of $sop, e.g.
-----------------
My printout:
ERI
SOF
HTM
SOF
------------------
My Perl program:
...
if ($sup=="HTM") {
print "$sup\n";
}
...
------------------
------------------------------
Date: Sun, 16 May 2004 13:35:15 +0200
From: hubert depesz lubaczewski <depesz@depesz.pl>
Subject: Re: IF problem?!
Message-Id: <slrn.pl.caekfj.46e.depesz@master.hq.eo.pl>
<tihana@kata.com> wyrzeĽbił(a):
> if ($sup=="HTM") {
change == to eq.
that's first.
second - what about "new line characters"?
depesz
--
napisanie do mnie na priv daje 99.9% gwarancję braku odpowiedzi
*-----------------------------------------------------------------*
sklep z rzeczami do domu: http://ulek.pl/
------------------------------
Date: Sun, 16 May 2004 12:25:31 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: IF problem?!
Message-Id: <%4Jpc.78068$sK3.38398@nwrddc03.gnilink.net>
tihana@kata.com wrote:
> How is possible that My printout prints all value of $sop, e.g.
> -----------------
> My printout:
> ERI
> SOF
> HTM
> SOF
> ------------------
> My Perl program:
> ...
> if ($sup=="HTM") {
> print "$sup\n";
> }
Maybe because all of "ERI", "SOF", "HTM", and "SOF" have the same numerical
value "0" and thus "==" always yields true?
If you want to compare text then you may want to use the text equality
operator "eq".
jue
------------------------------
Date: Sun, 16 May 2004 14:45:02 +0200
From: <tihana@kata.com>
Subject: Re: IF problem?!
Message-Id: <c87noh$tun$1@ls219.htnet.hr>
1.) Is that mean that == is different than eq ?
That line work normaly "if ($dir == 0) {..."
2.) What about "\n" is something wrong too?
> change == to eq.
> that's first.
> second - what about "new line characters"?
>> My Perl program:
>> ...
>> if ($sup=="HTM") {
>> print "$sup\n";
>> }
>> ...
------------------------------
Date: Sun, 16 May 2004 08:58:15 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: IF problem?!
Message-Id: <v7pea05hftj9sm983vi1gmi36lss06iv1r@4ax.com>
On Sun, 16 May 2004 13:20:21 +0200, <tihana@kata.com> wrote:
>How is possible that My printout prints all value of $sop, e.g.
>-----------------
>My printout:
>ERI
>SOF
>HTM
>SOF
>------------------
>My Perl program:
>...
>if ($sup=="HTM") {
> print "$sup\n";
>}
You want the string equality operator 'eq'.
--
Eric Amick
Columbia, MD
------------------------------
Date: Sun, 16 May 2004 07:32:27 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: lookahead or lookbehind
Message-Id: <40A718FB.55127855@acm.org>
Aqua wrote:
>
> I have a huge data file like this
> ========
> fdp "abcd18"
> $anchor "fig3","","",0<>
> $text "Figure_fig3",68.0711,0,0,0,0,0<>
> $gap 0,8,0,10.3<>
> $bcolour White<>
> $areas<>
>
> fdp "abcd19"
> $anchor "fig1","","",0<>
> $text "Figure_fig1",40.1263,0,0,0,0,0<>
> $gap 2,6,2,8<>
> $bcolour White<>
> $areas<>
>
> fdp "abcd21"
> $anchor "tab1","","",0<>
> $text "Table_tab1",0,0,0,0,0,0<>
> $gap 0,4.2175,0,7.42<>
> $areas<>
> ========
>
> I wanted to match text "Figure_fig1" block which should start with fdp
> and ends with $areas<>.
>
> use strict;
> open( INFILE, "<domtest.txt" ) or die "Cannot open: $!\n";
> my @Line = <INFILE>;
> my $FileLine = join( "", @Line );
> $FileLine =~ /(fdp .*?(?!fdp).*text \"Figure_fig1\")/s;
> close INFILE;
>
> But in my Reg exp it always matches from first fdp.
>
> I would appreciate any help in this regard
This should work:
use warnings;
use strict;
open INFILE, 'domtest.txt' or die "Cannot open: $!\n";
$/ = ''; # Set paragraph mode
while ( <INFILE> ) {
last if /^fdp/ and /text "Figure_fig1"/;
}
my $block = $_;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 15 May 2004 22:57:49 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Q: using perldoc to read a file
Message-Id: <c8679d$h0l$1@wisteria.csv.warwick.ac.uk>
Quoth yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones):
> I wish to use perldoc to read a file formatted as a pod.
>
> According to perldoc -h, I should be able to use -F to indicate the
> argument is a filename, but this only seems to work some of the time.
>
>
> $ perldoc -F ./pod.pod
> Cannot find blib even in /home/malcolm/src/template/../../../../..
> BEGIN failed--compilation aborted at (eval 2) line 1.
> ...propagated at /usr/bin/perldoc line 165.
>
>
> Most annoyingly, this seems to bite me exactly when I'm working on
> unfinished perl code. Perldoc will happily find and format a pod format
> file when I'm working in most any other directory that I'm not using for
> perl code.
>
> $ cp pod.pod ~
> $ cd ~
> $ perldoc pod.pod # don't even have to say it's a file
> -document formats as expected-
>
> So, what gives?
You may want to try upgrading to 5.8's perldoc, which appears to work in
every case to me:
$ ls -R
./lib:
all.pm all.pod
$ perldoc ./all
[displays all.pod]
$ perldoc -F ./all.pm
[displays all.pm]
$ perldoc -F ./all.pod
[displays all.pod]
You can install it by installing Pod::Perldoc from CPAN.
Ben
--
We do not stop playing because we grow old;
we grow old because we stop playing.
ben@morrow.me.uk
------------------------------
Date: Sun, 16 May 2004 13:27:56 +0200
From: Christian <christian3110@noos.fr>
Subject: Re: Request: Statistical analysis - Event detection
Message-Id: <40a7503c$0$31307$79c14f64@nan-newsreader-04.noos.net>
This nice Eric Bohlman wrote:
> Christian <christian3110@noos.fr> wrote in
> news:40a52830$0$31695$79c14f64@nan-newsreader-05.noos.net:
>> So I'm thinking about developing something that could help
>> automatically identify "events", using statistical analysis. The user
>> would specify for instance "this curve should stay horizontal", or
>> "this indicator should be periodical", or "this value should increase
>> at such or such rate", and the module would detect and signal when a
>> curve strays from its supposed, ideal behavior.
>
> This sounds like it falls under "statistical process control" (SPC),
> for
> which there's a well-developed literature. Note that SPC isn't only
> about identifying process shifts, but also about characterizing the
> normal behavior of processes in order to determine how well they're
> meeting requirements.
Hi Eric,
thanks for the hint! Indeed I can see there's lots of litterature on the
net about this, and some softwares also. However I think I'll have to
develop something on my own, tailored to my particular needs (I have
hundreds of indicators to watch concurrently).
Again thank you for your help!
Christian
------------------------------
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 6570
***************************************