[23432] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5649 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 12 14:05:54 2003

Date: Sun, 12 Oct 2003 11:05:07 -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, 12 Oct 2003     Volume: 10 Number: 5649

Today's topics:
    Re: Creating hyperlinks from text (Tad McClellan)
        Current Issues Article Archive <af@arcis.co.uk>
    Re: embedding Variable (Tad McClellan)
    Re: Extracting specific info from a string (Tad McClellan)
    Re: Perl Examples <dave@dave.org.uk>
        POE 0.27 Released <troc@pobox.com>
        POP3 & SSL <sfandino@yahoo.com>
        Post radiobuttons (forms) using lwp-useragent (Rubel Kanubel)
    Re: Post radiobuttons (forms) using lwp-useragent <REMOVEsdnCAPS@comcast.net>
        Using map to assign var values from hash <radevenz@ix.netcom.com>
    Re: Using map to assign var values from hash <Wolfgang_.fischer@lycos.de>
    Re: Using map to assign var values from hash (Jay Tilton)
    Re: Using map to assign var values from hash (Greg Bacon)
    Re: Using map to assign var values from hash <REMOVEsdnCAPS@comcast.net>
    Re: Using map to assign var values from hash <REMOVEsdnCAPS@comcast.net>
        where is the mistake?! <geoff.cox@blueyonder.co.uk>
        why empty zip files? <geoff.cox@blueyonder.co.uk>
    Re: why empty zip files? (Greg Bacon)
    Re: why empty zip files? <geoff.cox@blueyonder.co.uk>
    Re: why empty zip files? <laocoon@fastmail.fm>
    Re: why empty zip files? <geoff.cox@blueyonder.co.uk>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 12 Oct 2003 08:57:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Creating hyperlinks from text
Message-Id: <slrnboinf4.blo.tadmc@magna.augustmail.com>

Fred <dreamer@cox.net> wrote:

> I am looking for an existing module, 

   perldoc -q module

      What modules and extensions are available for Perl?  
      What is CPAN?  What does CPAN/src/... mean?

      How do I install a module from CPAN?


> and how to use it.


After installing it, type:

   perldoc Some::Module

to see the module's documentation.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 12 Oct 2003 11:56:21 +0100
From: "[AF] Abdulhafid" <af@arcis.co.uk>
Subject: Current Issues Article Archive
Message-Id: <sraib.12437$Cl2.7727@newsfep3-gui.server.ntli.net>

A growing archive of fascinating media articles on current issues & affairs.
Available at Arcis Foundation Website:
www.arcis.co.uk/php/

--
Posted by News Bulk Poster
Unregistered version


------------------------------

Date: Sun, 12 Oct 2003 09:03:40 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: embedding Variable
Message-Id: <slrnboinps.blo.tadmc@magna.augustmail.com>

Mike Solomon <mike_solomon@lineone.net> wrote:

> If I write the following code

> my $output "my test = $test\n";

> then I will get


A syntax error.



    Do not re-type Perl code
        Use copy/paste or your editor's "import" function rather than
        attempting to type in your code. If you make a typo you will get
        followups about your typos instead of about the question you are
        trying to get answered.


Like this one.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 12 Oct 2003 09:38:08 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Extracting specific info from a string
Message-Id: <slrnboipqg.blo.tadmc@magna.augustmail.com>

Yannick Turgeon <nobody@nowhere.com> wrote:
                        ^^^^^^^^^^^

I suggest using some other form of munging.

That particular one is likely to be widely killfiled...


> One more thing. I use the "s" option but I don't undestand it quite well.


The "s" option makes dot match a newline.


> in which situation this could be a problem or something we don't want?


When you want the dots in your pattern to match newlines.  :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 12 Oct 2003 08:28:48 +0100
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: Perl Examples
Message-Id: <pan.2003.10.12.07.28.48.90363@dave.org.uk>

On Thu, 09 Oct 2003 10:52:26 -0700, Kristoff wrote:

> Hi,
> 
> I'm learning Perl and CGI with the book Visual Quickstart Guide by 
> Elizabeth Castro.  The problem is that I have the first edition book, 
> while Castro only has Perl and CGI example files for her second edition 
> book (available from her web site).  Does anybody out there happen to 
> still have the Perl and CGI examples from Castro's first book??
> 
> I've emailed Castro, but have not received a response, as of yet.

Actually the examples from the first edition are still available on the
web site. Go to <http://www.cookwood.com/perl/examples/perlexamples.html>
and look at the links in the final paragraph.

Julia has already warned you of the problems with that book. You'll find
that the 2nd edition has fixed most of these problems.

The Perl community's recommendations for Perl books (including beginners'
tutorials) are in the Perl FAQ. Try typing "perldoc -q books" at your
command line.

Dave...

-- 
  Love is a fire of flaming brandy
  Upon a crepe suzette



------------------------------

Date: Sat, 11 Oct 2003 02:19:07 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: POE 0.27 Released
Message-Id: <HMnGMG.F2L@zorch.sf-bay.org>
Keywords: multitasking, networking, framework, components, robust, cool

Version 0.27 of the POE networking and multitasking framework has been
released.  Thanks go out to everyone who assisted in its development.
This release is improved in several ways.

Scheduled deprecations:

 - Upgraded the mandatory signal warnings to errors.  Only eight
   months behind schedule! :)

Performance tuning:

 - Default block and buffer sizes have been increased.

 - Wheel::ReadWrite watermarks have been fixed.  When used properly,
   they allow POE programs to keep send buffers from running empty.

Improved Windows support:

 - Issues between POE's installer and ActiveState's automated PPD
   build system have been addressed.  Windows users may find 0.27 to
   be a lot easier to install through PPM.  Please report further
   issues to bug-POE@rt.cpan.org.

 - Added support for network I/O when using ActivePerl's build of Tk.
   Programs written to correctly use Tk should magically work under
   ActivePerl now.

 - Improved portability in the POE::Pipe and the ::OneWay and ::TwoWay
   classes, especially on Cygwin.  Wheel::Run should work better.

 - Worked around a long-standing bug in Cygwin's socketpair() and/or
   exec() implementation.

Bug fixes:

 - Filter::HTTPD now includes the tilde (~) as part of the legal
   character class for HTTP header names, per RFC 2616.

 - Wheel::Run now properly sets GID before UID.  Before, it would set
   UID first, and often GID could not be changed after that.

 - Wheel::FollowTail detects file shrinkage better.  File reset
   detection should work better on Linux.

 - A subtle garbage collection problem was collected.  Using call()
   between sessions should be much safer.

 - Fixed a copy-and-pasto in ASSERT_USAGE.

 - Various documentation fixes.

Removed annoyances:

 - Silence the "read error 0" non-errors in the TCP Client and Server
   components.  This should extend to whatever uses them, also.

 - Added delay_adjust(), to adjust delays set with delay_set().

 - Applied jriek's patch to support forward Seek to Wheel::FollowTail.
   Negative seek does the same as SeekBack.

Initial support for user-extensibility:

 - Added initial support for pluggable APIs into POE::Kernel.

 - Added private accessors to POE::Kernel's (and POE::Resource::*'s)
   internal states.  These accessors allow us to test POE's internals
   directly rather than by effect.

 - Merged Bruno Boettcher's Gnome.pm support into Gtk.pm.

 - Added stubs for Gtk2.  The Gtk2 event loop bridge is still in beta
   testing.

As if that wasn't enough, POE's web site contains detailed change 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 it via anonymous CVS or
POE's 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.  The O'Reilly Perl Conference (now
part of OSCON) named POE "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::Component

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 tens 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, 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@pobox.com - http://poe.perl.org/




------------------------------

Date: Sun, 12 Oct 2003 15:54:49 +0100
From: Salvador Fandino <sfandino@yahoo.com>
Subject: POP3 & SSL
Message-Id: <bmbpvt$lh0$01$1@news.t-online.com>

Hi,

Does anybody have a perl module or some code to access POP3 mailboxes 
that requiere SSL connections?

Nothing like that seems to be available from CPAN.

Bye,

   - Salva



------------------------------

Date: 12 Oct 2003 07:20:10 -0700
From: rubelkanubel@yahoo.no (Rubel Kanubel)
Subject: Post radiobuttons (forms) using lwp-useragent
Message-Id: <d9948989.0310120620.7d4f167f@posting.google.com>

Hi!

I've created a script that automatically logs into a site and fills
out a form. I'm using the LWP::Useragent module. The first form (the
login form) is no problem getting through. Examplified by the
following:

<code>

my $req = POST 'http://www.acme.com/login.php', [ name => 'john', pass
=> 'password' ];
my $res = $ua->request($req);

</code>

here the "name" and "pass" parameters represents textfield form
elements. The second form I'm trying to send includes radio button
form elements. But it doesnt seem like I can pass parameters like
above for these elements.

The radio button name is "rad_query", and its possible values are
"alt_1", "alt_2" and "alt_3".. but the following does not work

<code>

my $req = POST 'http://www.acme.com/login.php', [ rad_query" => 'alt
1' ];
my $res = $ua->request($req);

</code>

I know that radio buttons in php is represented as an array.. but I'm
not sure if this is the same in perl.. so I have a problem: How do I
pass radio button form elements by using LWP::Useragent.

Any answers, comments, ideas etc. would be very much appreciated.
Thanks!


/Regards Rubel Kanubel


------------------------------

Date: Sun, 12 Oct 2003 11:50:49 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Post radiobuttons (forms) using lwp-useragent
Message-Id: <Xns941282AC4B3C9sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

rubelkanubel@yahoo.no (Rubel Kanubel) wrote in 
news:d9948989.0310120620.7d4f167f@posting.google.com:

> <code>
> 
> my $req = POST 'http://www.acme.com/login.php', [ rad_query" => 'alt
> 1' ];
> my $res = $ua->request($req);

I was about to point out that you wanted 'alt_1' but your code says either 
'alt 1' or "alt\n1", but then I noticed that the above code can't possibly 
work anyhow.

Please post your real code by copy/paste instead of re-typing it.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP4mGYGPeouIeTNHoEQKcGQCg/VAijSzMYZ/6CY/ggRMXudo3BYYAoLNO
bdLe5OTS6Rjm1fBqgMItn0Bo
=RKMH
-----END PGP SIGNATURE-----


------------------------------

Date: Sun, 12 Oct 2003 04:42:53 -0400
From: "Richard A. DeVenezia" <radevenz@ix.netcom.com>
Subject: Using map to assign var values from hash
Message-Id: <bmb475$kr5ja$1@ID-168040.news.uni-berlin.de>

This doesn't assign variables.  Then commented out 'eval join' version does.
Why doesn't the first version work ?

#!perl -w
use strict;

doStuff (a=>1, b=>2, c=>'foo', foo=>'bar', z=>9);

sub doStuff {
  my %param = @_;
  my ($a, $b, $c);
  my @allowed = qw (a b c);

  no strict 'refs';
  map $$_ = $param{$_}, @allowed;
  use strict;

# eval join ("", map "\$$_ = \$param{'$_'};", @allowed);

  print "a=$a\nb=$b\nc=$c\n";
}

-- 
Richard




------------------------------

Date: Sun, 12 Oct 2003 12:47:16 +0200
From: Wolfgang Fischer <Wolfgang_.fischer@lycos.de>
Subject: Re: Using map to assign var values from hash
Message-Id: <pan.2003.10.12.10.47.16.368988@lycos.de>

On Sun, 12 Oct 2003 04:42:53 -0400, Richard A. DeVenezia wrote:

> This doesn't assign variables.  Then commented out 'eval join' version does.
> Why doesn't the first version work ?
> 
> #!perl -w
> use strict;
> 
> doStuff (a=>1, b=>2, c=>'foo', foo=>'bar', z=>9);
> 
> sub doStuff {
>   my %param = @_;
>   my ($a, $b, $c);
>   my @allowed = qw (a b c);
> 
>   no strict 'refs';
>   map $$_ = $param{$_}, @allowed;
Hello,
you can't use variables like $$_; You have to specify the variable name
at compile time, not at run time.
>   use strict;
> 
> # eval join ("", map "\$$_ = \$param{'$_'};", @allowed);
This creates and evals the string
"$a=$param{'a'};$b=$param{'b'};$c=$param{'c'};"
So eval doesn't get something like $$_=.... But why don't you use
this? 
my($a,$b,$c)=($param{'a'},$param{'b'},$param{'c'});
> 
>   print "a=$a\nb=$b\nc=$c\n";
> }



------------------------------

Date: Sun, 12 Oct 2003 11:31:10 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Using map to assign var values from hash
Message-Id: <3f893834.1262491@news.erols.com>

Wolfgang Fischer <Wolfgang_.fischer@lycos.de> wrote:

: On Sun, 12 Oct 2003 04:42:53 -0400, Richard A. DeVenezia wrote:
: 
: > This doesn't assign variables.  Then commented out 'eval join' version does.
: > Why doesn't the first version work ?
: > 
: > #!perl -w
: > use strict;
: > 
: > doStuff (a=>1, b=>2, c=>'foo', foo=>'bar', z=>9);
: > 
: > sub doStuff {
: >   my %param = @_;
: >   my ($a, $b, $c);
: >   my @allowed = qw (a b c);
: > 
: >   no strict 'refs';
: >   map $$_ = $param{$_}, @allowed;
:
: you can't use variables like $$_;

Sure you can.

: You have to specify the variable name
: at compile time, not at run time.

Not true at all.

What the OP is trying to do is to assign a value to a scalar by symbolic
reference.  It's working, but on the package variables $::a, $::b, and
$::c, not the lexically declared $a, $b and $c he expects.

: But why don't you use
: this? 
: my($a,$b,$c)=($param{'a'},$param{'b'},$param{'c'});

Solid advice.  Or even,

    my($a, $b, $c) = @param{qw/a b c/};



------------------------------

Date: Sun, 12 Oct 2003 11:37:45 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Using map to assign var values from hash
Message-Id: <voif89a5h8kbb@corp.supernews.com>

In article <bmb475$kr5ja$1@ID-168040.news.uni-berlin.de>,
    Richard A. DeVenezia <radevenz@ix.netcom.com> wrote:

: This doesn't assign variables.  Then commented out 'eval join' version
: does.  Why doesn't the first version work ?
: [...]

Symbolic references point to globals, not lexicals, but declaring $a,
$b, and $c as lexicals in that scope made a little more work necessary
to get at the globals.  Look at the globals after your assignment:

    #! /usr/local/bin/perl

    use warnings;
    use strict;

    our($a,$b,$c);

    doStuff (a=>1, b=>2, c=>'foo', foo=>'bar', z=>9);

    sub doStuff {
      my %param = @_;
    #  my ($a, $b, $c);
      my @allowed = qw (a b c);

      no strict 'refs';
      map $$_ = $param{$_}, @allowed;
      use strict;

    # eval join ("", map "\$$_ = \$param{'$_'};", @allowed);

      print "a=$a\nb=$b\nc=$c\n";
    }

Hope this helps,
Greg
-- 
 . . . this one single rule, rationally construed and applied, is enough to
form the starting point of all that is necessary in government: to make no
more laws than those useful for preventing a man or body of men from
infringing on the rights of other men.      -- Walt Whitman, "Government"


------------------------------

Date: Sun, 12 Oct 2003 09:12:20 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Using map to assign var values from hash
Message-Id: <Xns941267CE770D1sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Wolfgang Fischer <Wolfgang_.fischer@lycos.de> wrote in
news:pan.2003.10.12.10.47.16.368988@lycos.de: 

> On Sun, 12 Oct 2003 04:42:53 -0400, Richard A. DeVenezia wrote:
> 

>>   no strict 'refs';
>>   map $$_ = $param{$_}, @allowed;
> Hello,
> you can't use variables like $$_; You have to specify the variable
> name at compile time, not at run time.

Please do not post answers to questions unless you know what you're talking 
about.  One most certainly can specify variable names at runtime.  $$_ is 
perfectly valid Perl.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP4lhOmPeouIeTNHoEQLJ5gCcCypVbYabgVI/h9708V412VbAUhAAoNTo
Jq8LkmwsOPzR8iGIfrigG07A
=wYlV
-----END PGP SIGNATURE-----


------------------------------

Date: Sun, 12 Oct 2003 09:17:35 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Using map to assign var values from hash
Message-Id: <Xns941268B261570sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Richard A. DeVenezia" <radevenz@ix.netcom.com> wrote in
news:bmb475$kr5ja$1@ID-168040.news.uni-berlin.de: 

> This doesn't assign variables.  Then commented out 'eval join' version
> does. Why doesn't the first version work ?
> 
> #!perl -w
> use strict;
> 
> doStuff (a=>1, b=>2, c=>'foo', foo=>'bar', z=>9);
> 
> sub doStuff {
>   my %param = @_;
>   my ($a, $b, $c);
>   my @allowed = qw (a b c);
> 
>   no strict 'refs';
>   map $$_ = $param{$_}, @allowed;
>   use strict;
> 
> # eval join ("", map "\$$_ = \$param{'$_'};", @allowed);
> 
>   print "a=$a\nb=$b\nc=$c\n";
> }
> 

Jay Tilton and Greg Bacon have already pointed out what's going on here, 
so I won't repeat what they said.

However, a word of style: Why not leave the caller's value assignments in 
a hash, instead of polluting the global variable space?  Something like:

    $caller_options{$_} = $param{$_} for @allowed;

Without knowing the big picture of what you're doing, I can't say if this 
is better than assigning global variables or not.  But it's a thought.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP4lieWPeouIeTNHoEQKsIwCgmZFNxSr/lGy0kLbInmGU4SBFz7YAnjCU
Bs9KTxiWvjPLznNEvoOBxprk
=k07R
-----END PGP SIGNATURE-----


------------------------------

Date: Sun, 12 Oct 2003 08:33:31 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: where is the mistake?!
Message-Id: <094iov4aio3kcpruef7vvm8opqjo615cee@4ax.com>

Hello,

I have a directory with 20 MS Word doc files in it and wish to create
a separate zip file for each doc file. The names to be doc1.zip,
doc2.zip, etc

Is the code below anywhere near?!

Cheers

Geoff


use warnings;
use strict;

use File::Find;
use Archive::Zip;

my $dir = 'd:/a-keep8/perl/test/business-location';

find( sub {
    ( my $name = $_ ) or return;
    for (my $n=1;$n<21;$n++) {
    my $zip = Archive::Zip->new( $_ );
    $zip->writeToFileName(my $business-doc$n);
    }
    }, $dir );


------------------------------

Date: Sun, 12 Oct 2003 10:22:42 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: why empty zip files?
Message-Id: <viaiov02ua5a2u85j450gu0uk0oarsp8dh@4ax.com>

Hello,

The following code creates zip files, each 22 kb in size, but the doc
which should be there isn't there ...any ideas why?

I can get code to work where I define the file to be zipped and the
name of the zip file but trying to go through the whole folder using
File::Find is not working ...

Cheers

Geoff

use warnings;
use strict;

use File::Find;
use Archive::Zip;

my $dir = 'd:/a-keep8/perl/test';

find ( sub {

my $name = $_;
print ("$name \n");
my $zip = new Archive::Zip;
$zip->writeToFileNamed($name . ".zip");

}, $dir);



------------------------------

Date: Sun, 12 Oct 2003 11:29:40 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: why empty zip files?
Message-Id: <voiep44t0k615b@corp.supernews.com>

In article <viaiov02ua5a2u85j450gu0uk0oarsp8dh@4ax.com>,
    Geoff Cox  <geoff.cox@blueyonder.co.uk> wrote:

: The following code creates zip files, each 22 kb in size, but the doc
: which should be there isn't there ...any ideas why?
: 
: I can get code to work where I define the file to be zipped and the
: name of the zip file but trying to go through the whole folder using
: File::Find is not working ...

You need to tell the module to add the files to the archives.  You
also want to skip directories:

    #! perl

    use warnings;
    use strict;

    use File::Find;
    use Archive::Zip;

    my $dir = 'd:/a-keep8/perl/test';

    find sub {
        my $name = $_;
        return if -d;
        print ("$name \n");
        my $zip = new Archive::Zip;
        $zip->addFile($name);
        $zip->writeToFileNamed($name . ".zip");
    } => $dir;

Hope this helps,
Greg
-- 
Anger is a gift.
    -- rage against the machine


------------------------------

Date: Sun, 12 Oct 2003 11:46:10 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: why empty zip files?
Message-Id: <hefiov836rrs654a6fgc8fdksnaqals5t2@4ax.com>

On Sun, 12 Oct 2003 11:29:40 -0000, gbacon@hiwaay.net (Greg Bacon)
wrote:

>In article <viaiov02ua5a2u85j450gu0uk0oarsp8dh@4ax.com>,
>    Geoff Cox  <geoff.cox@blueyonder.co.uk> wrote:
>
>: The following code creates zip files, each 22 kb in size, but the doc
>: which should be there isn't there ...any ideas why?
>: 
>: I can get code to work where I define the file to be zipped and the
>: name of the zip file but trying to go through the whole folder using
>: File::Find is not working ...
>
>You need to tell the module to add the files to the archives.  You
>also want to skip directories:

Greg,

Many thanks - all is well now with this code - now next problem!
Instead of using the name of the doc file as the name for the zip file
I would like to name the zip files, doc1.zip, doc2.zip etc

I am not clear where the loop goes?

Cheers

Geoff






>    #! perl
>
>    use warnings;
>    use strict;
>
>    use File::Find;
>    use Archive::Zip;
>
>    my $dir = 'd:/a-keep8/perl/test';
>
>    find sub {
>        my $name = $_;
>        return if -d;
>        print ("$name \n");
>        my $zip = new Archive::Zip;
>        $zip->addFile($name);
>        $zip->writeToFileNamed($name . ".zip");
>    } => $dir;
>
>Hope this helps,
>Greg



------------------------------

Date: Sun, 12 Oct 2003 13:55:20 +0200
From: Lao Coon <laocoon@fastmail.fm>
Subject: Re: why empty zip files?
Message-Id: <bmbff7$2c1$01$1@news.t-online.com>

Geoff Cox <geoff.cox@blueyonder.co.uk> wrote in 
news:hefiov836rrs654a6fgc8fdksnaqals5t2@4ax.com:

> Instead of using the name of the doc file as the name for the zip file
> I would like to name the zip files, doc1.zip, doc2.zip etc
> 
> I am not clear where the loop goes?

No loop. File::Find->find already iterates over all the files.
Just use a counter

 ...

my $count = 0;

find sub {
    	...
    	$count++;
    	$zip->writeToFileNamed("doc$count.zip");
    	...
} => $dir;


Lao


------------------------------

Date: Sun, 12 Oct 2003 12:11:52 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: why empty zip files?
Message-Id: <p7hiovsqr3qh8h472v8pcoo2bnhke95n4d@4ax.com>

On Sun, 12 Oct 2003 13:55:20 +0200, Lao Coon <laocoon@fastmail.fm>
wrote:

>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote in 
>news:hefiov836rrs654a6fgc8fdksnaqals5t2@4ax.com:
>
>> Instead of using the name of the doc file as the name for the zip file
>> I would like to name the zip files, doc1.zip, doc2.zip etc
>> 
>> I am not clear where the loop goes?
>
>No loop. File::Find->find already iterates over all the files.
>Just use a counter

Lao,

thanks - all is well again!

Cheers

Geoff

>
>...
>
>my $count = 0;
>
>find sub {
>    	...
>    	$count++;
>    	$zip->writeToFileNamed("doc$count.zip");
>    	...
>} => $dir;
>
>
>Lao



------------------------------

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



------------------------------

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 5649
***************************************


home help back first fref pref prev next nref lref last post