[22153] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4374 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 9 18:07:01 2003

Date: Thu, 9 Jan 2003 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 9 Jan 2003     Volume: 10 Number: 4374

Today's topics:
    Re: Activeperl : ppm and GD <bobx@linuxmail.org>
    Re: Arrays. What don't I get? <bart.lateur@pandora.be>
        Converting CGI to XML (Keith R.)
    Re: Converting CGI to XML <usenet@dwall.fastmail.fm>
    Re: Converting CGI to XML <dorward@yahoo.com>
    Re: Converting CGI to XML <jurgenex@hotmail.com>
    Re: finding files older than a given date (Charles)
    Re: finding files older than a given date (Tad McClellan)
        grep  ==  ?? <sfarris9@insightbb.com>
    Re: grep  ==  ?? (Malcolm Dew-Jones)
    Re: grep  ==  ?? (Tad McClellan)
    Re: grep  ==  ?? <usenet@dwall.fastmail.fm>
    Re: Is there a maximum length for system() or backtick  <goldbb2@earthlink.net>
        Isogest 3.1 New release <l.ortolani@ecosystemspa.com>
    Re: Net::Ping issue <goldbb2@earthlink.net>
    Re: pack( "N", inet_aton("client.example.net")) <goldbb2@earthlink.net>
    Re: Recreating directory hierarchy <bik.mido@tiscalinet.it>
        Red Hat 8 breaking one-liner signature script (Emmy)
    Re: Taint check question <bongie@gmx.net>
    Re: These are discouraging stats to Perlistas & Pythoni (Sara)
    Re: tracing the HTTP <vladimir@NoSpamPLZ.net>
    Re: tracing the HTTP <pkrupa@redwood.rsc.raytheon.com>
    Re: Unix Vars declared in system() call -> %ENV (Malcolm Dew-Jones)
    Re: Unix Vars declared in system() call -> %ENV <goldbb2@earthlink.net>
    Re: What is a simple way to read and write zip files? <goldbb2@earthlink.net>
    Re: Why is map so much faster then a nested for loop? <goldbb2@earthlink.net>
    Re: win32::ole excel hiding columns FIXED <lance@augustmail.com>
        win32::ole excel hiding columns <lance@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 09 Jan 2003 21:51:23 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: Activeperl : ppm and GD
Message-Id: <v9mT9.5026$Fj2.2959901@news2.news.adelphia.net>

"Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message
news:slrnb1r7vk.sk7.randy@theoryx5.uwinnipeg.ca...
> On Thu, 09 Jan 2003 15:50:23 +0000,
>   Simon Andrews <simon.andrews@bbsrc.ac.uk> wrote:
> >Jan wrote:
> >> I had some scripts using the GD and Date modules.  Last I had to
> >> reinstall ActivePerl and since then (or since earlier ?) when I start
> >> ppm and do a search on GD I get only three modules.  That used to be
> >> much more.  Now even the GD module itself doesn't turn up.
> >
> >If you're using the new 5.8 builds then Activestate have started
> >including more modules in the default install, meaning that you may have
> >GD there already.  Try running "ppm query GD" on your system and see
> >what turns up.
>
> If it's not there, we have a GD-2.06 ppm package, suitable
> for ActivePerl 8xx builds, at
>     http://theoryx5.uwinnipeg.ca/ppms/
> which you can access within the ppm shell by setting the
> respository to
>   http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58
>
> --
> best regards,
> randy kobes

Randy,

Theoryx used to have the Storable.ppd file as well. I didn't notice it gone
until I tried to install the PlRPC.ppd and it errored out looking for
Storable at the Log4perl site. Do you know of another place to find it?

Bob




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

Date: Thu, 09 Jan 2003 21:23:41 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Arrays. What don't I get?
Message-Id: <31qr1vsomshqfrnejhvo2tjm17nj7f7u3b@4ax.com>

Richard S Beckett wrote:

>our @values = ($one, $two, $three, $four);

Your error is to assume that the array elements now become aliases to
the original variable. They're not: they're copies, *different* scalars
with the same value.

-- 
	Bart.


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

Date: 9 Jan 2003 14:23:33 -0800
From: kmrob72@comcast.net (Keith R.)
Subject: Converting CGI to XML
Message-Id: <745194ed.0301091423.3764ce52@posting.google.com>

Hello all,
Does anybody know if it's possible to convert CGI to XML? I've seen a
few things on the web regarding this but haven't found anything
descriptive enough. Please help. Thanks.
Keith 
SysAdmin
kmr@bruhn-newtech.com


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

Date: Thu, 09 Jan 2003 22:40:28 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Converting CGI to XML
Message-Id: <Xns92FEB3CB121FFdkwwashere@216.168.3.30>

Keith R. <kmrob72@comcast.net> wrote on 09 Jan 2003:

> Does anybody know if it's possible to convert CGI to XML? I've seen a
> few things on the web regarding this but haven't found anything
> descriptive enough. Please help. Thanks.

CGI is a standard for external gateway programs to interface with 
information servers such as HTTP servers[1], and XML [2] is a data 
format.  You can send XML via CGI, but I have no idea what you mean by 
converting CGI to XML.

Did you have a Perl question?



[1] http://hoohoo.ncsa.uiuc.edu/cgi/overview.html
[2] http://www.w3.org/XML/

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: Thu, 09 Jan 2003 22:39:11 +0000
From: David Dorward <dorward@yahoo.com>
Subject: Re: Converting CGI to XML
Message-Id: <avkts4$stb$1$8300dec7@news.demon.co.uk>

Keith R. wrote:
> Does anybody know if it's possible to convert CGI to XML? I've seen a
> few things on the web regarding this but haven't found anything
> descriptive enough. Please help. Thanks.

CGI is a means for a webserver to recieve generated content from programs.
XML is a language for defining mark up lanugages.
Converting between them is rather like converting between oxygen and the
colour pink.

-- 
David Dorward                                   http://david.us-lot.org/
"You cannot rewrite history, not one line."
                                      - The Doctor (Dr. Who: The Aztecs)


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

Date: Thu, 09 Jan 2003 22:45:48 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Converting CGI to XML
Message-Id: <wYmT9.35826$xb.15680@nwrddc02.gnilink.net>

Keith R. wrote:
> Does anybody know if it's possible to convert CGI to XML?

No, that's not possible.
CGI is an interface (the Common Gateway Interface).
XML is a markup language (the eXtensible Markup Language).
They are not related in any way and have just about nothing in common.

Or would you propose to convert let's say a car into Spanish, too?

jue




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

Date: 9 Jan 2003 12:44:03 -0800
From: schittdip@hotmail.com (Charles)
Subject: Re: finding files older than a given date
Message-Id: <c6e8de31.0301091244.5a0ff1a9@posting.google.com>

schittdip@hotmail.com (Charles) wrote in message news:<c6e8de31.0301090650.4a0eae88@posting.google.com>...
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb1oq2n.lkd.tadmc@magna.augustmail.com>...
> > Charles <schittdip@hotmail.com> wrote:
> > 
> > > What I want to do is create a script to run on a windows server that
> > > will recursively go into a directory and delete any files older than a
> > > given time period.
> > 
> > 
> > I suggest making a very good backup before trying this code!
> > 
> > (or, change the unlink() to a print():
> > 
> >       print "I would have deleted the '$File::Find::name' file\n";
> > )
> > 
> > 
> > ----------------------------------
> >    # untested!
> >    use File::Find;
> > 
> >    my $days = 14;
> >    find( \&unwanted, 'd:/stuff');
> > 
> >    sub unwanted {
> >       return unless -f;          # delete only plain files
> >       return unless -M > $days;
> >       unlink or warn "could not delete '$File::Find::name' file\n";
> >    }
> > ----------------------------------
> > 
> > 
> > You can view the module's docs with:
> > 
> >    perldoc File::Find
> 
> Thank you so much.  This works like a charm.  I was to focused on
> traversing the directory tree and didn't even think about a global
> search.  Being very new to Perl I have a lot to learn.

Ok one more question.  I want the output of the operation to go to a
text file rather than the screen.  I thought I had it with the
following code but it only writes the first line.  The other files
never show up. Where am I going wrong?

Thanks

#!perl -w
use File::Find;

my $days = 14;
find( \&unwanted, 'd:/temp');

sub unwanted {
	open (DELLOG, ">>output.txt");
	return unless -f;          # delete only plain files
      	return unless -M > $days;
      	unlink or warn "could not delete '$File::Find::name' file\n";
      	my $file = $File::Find::name;
      	my $date = (stat($file))[9];
      	#my $out = "I would have deleted the '$File::Find::name'
file\n";
	my $out =  "[".  localtime() ."] Deleted '$File::Find::name' Created
on [".scalar localtime($date)."]\n" ;
	print DELLOG $out;
      	close (DELLOG);
   }


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

Date: Thu, 9 Jan 2003 15:22:48 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: finding files older than a given date
Message-Id: <slrnb1rq18.php.tadmc@magna.augustmail.com>

Charles <schittdip@hotmail.com> wrote:
> schittdip@hotmail.com (Charles) wrote in message news:<c6e8de31.0301090650.4a0eae88@posting.google.com>...
>> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb1oq2n.lkd.tadmc@magna.augustmail.com>...


>> > You can view the module's docs with:
>> > 
>> >    perldoc File::Find


Did you do that yet?


>> Thank you so much.  This works like a charm.  I was to focused on
>> traversing the directory tree and didn't even think about a global
>> search.  


Errr, your program is still traversing the tree, but now the module
is doing it for you.


>> Being very new to Perl I have a lot to learn.


One of them being to read the documentation for the software
that you are using.   :-)


> Ok one more question.  I want the output of the operation to go to a
> text file rather than the screen.  I thought I had it with the
> following code but it only writes the first line.  The other files
> never show up. Where am I going wrong?


Aren't you really ending up with 'output.txt' files scattered
throughout all of the subdirs under d:/temp ?


> #!perl -w


Enabling warnings is good.

Also enabling strictures would be even better:

   use strict;

(and lexical warnings are better than -w, use them if you can)


> use File::Find;
> 
> my $days = 14;
> find( \&unwanted, 'd:/temp');
> 
> sub unwanted {
> 	open (DELLOG, ">>output.txt");


You should always, yes *always*, check the return value from open():

   open (DELLOG, ">>output.txt") or die "could not open 'output.txt' $!";


The module's docs say:

   You are chdir()'d to $File::Find::dir when the function is called

So you are open()ing in _each_ directory that is traversed.

Move the open() out of the function and into main, before calling find().


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


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

Date: Thu, 09 Jan 2003 21:03:44 GMT
From: steven farris <sfarris9@insightbb.com>
Subject: grep  ==  ??
Message-Id: <QslT9.301295$qF3.36839@sccrnsc04>

I'm porting some code and the following line has me stumped:

    } elsif ( $frequency =~ m!^ON\s+(.+)$!x) {
        #ON date [,date ...]
        $schedule = 1 if
            grep $_ == $sched_rundate, &make_date_list($1);

The make date list function returns an array of
date strings.

what's going on in the conditional grep statement?


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

Date: 9 Jan 2003 13:37:34 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: grep  ==  ??
Message-Id: <3e1deb9e@news.victoria.tc.ca>

steven farris (sfarris9@insightbb.com) wrote:
: I'm porting some code and the following line has me stumped:

:     } elsif ( $frequency =~ m!^ON\s+(.+)$!x) {
:         #ON date [,date ...]
:         $schedule = 1 if
:             grep $_ == $sched_rundate, &make_date_list($1);

Grep accepts an expression or a block, and returns either the matching
items or a count of the matching items, so this is basically the same as

	@dates = &make_date_list($1);
	$number_of_matches = grep { $_ == $sched_rundate }  @dates;

which appears to run through the list of dates and numerically compares
each date with $sched_rundate.  In this situation, grep returns the number
of times the compare is true, so if there's at least one equal then the
`$schedule = 1' assignment is done. 


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

Date: Thu, 9 Jan 2003 15:39:43 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: grep  ==  ??
Message-Id: <slrnb1rr0v.pla.tadmc@magna.augustmail.com>

steven farris <sfarris9@insightbb.com> wrote:
> I'm porting some code and the following line has me stumped:
> 
>     } elsif ( $frequency =~ m!^ON\s+(.+)$!x) {
>         #ON date [,date ...]
>         $schedule = 1 if
>             grep $_ == $sched_rundate, &make_date_list($1);
                                         ^
                                         ^

I doubt that you want the semantics that go with that
form of function call, see "perldoc perlsub".


> The make date list function returns an array of
> date strings.
> 
> what's going on in the conditional grep statement?


It is doing a numerical comparison against the list items
returned by make_date_list($1).

It returns "true" if any are numerically equal.


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


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

Date: Thu, 09 Jan 2003 21:54:32 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: grep  ==  ??
Message-Id: <Xns92FEAC01A6C55dkwwashere@216.168.3.30>

steven farris <sfarris9@insightbb.com> wrote on 09 Jan 2003:

> I'm porting some code and the following line has me stumped:
> 
>     } elsif ( $frequency =~ m!^ON\s+(.+)$!x) {
>         #ON date [,date ...]
>         $schedule = 1 if
>             grep $_ == $sched_rundate, &make_date_list($1);
> 
> The make date list function returns an array of
> date strings.
> 
> what's going on in the conditional grep statement?

It's checking to see if any of the date strings returned by 
make_date_list($1) are numerically equal to $sched_rundate.  grep() 
is in scalar context, so it returns the number of times its condition 
is true.  In case you don't know, $1 is what was returned by the 
capturing parentheses in the regular expression in the elsif 
condition.

If make_date_list() is returning a list of strings, then the 
comparison operator should be 'eq', not '==', i.e.;

    $schedule = 1 if
        grep $_ eq $sched_rundate, make_date_list($1);

$sched_rundate is also a string, right?

You probably don't need to call make_date_list() with the & in front 
of it.  See 'perldoc perlsub'.

If you're porting this then you probably don't need to fix it, but 
there do seem to be some odd things going on.

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: Thu, 09 Jan 2003 16:21:05 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Is there a maximum length for system() or backtick commands?
Message-Id: <3E1DE7C1.A0528F25@earthlink.net>

Hal Vaughan wrote:
> 
> I've been testing Bash for maximum command line lengths (and trying to
> find a limit in the man page) and can't find any.

The limit is not due to the shell, but due to the underlying syscall --
I would suggest you do 'man exec' from your commandline, and scroll down
to where it mentions ARG_MAX.

[snip]
> Is there a maximum length I can make $command without problems?  I can
> easily see sending 400 (or even 500) files to the printer this way. 
> I'd rather do it in one command (for various reasons), then breaking
> it down by limiting each command to only a certain number of files.

How about:
   open( FILENAMES_TO_PRINTER, "| xargs lp");
   foreach my $file (@files) {
      print FILENAMES_TO_PRINTER $file, "\n";
   }
   close FILENAMES_TO_PRINTER;
[untested]

This does have the effect of breaking it down, and limiting each command
to only a certain number of files, but the 'xargs' program knows what
ARG_MAX is, and puts on each commandline the *maximum* number of files.

The only alternative I can think of is to concatenate all of those files
into a single file (using pr to add headers and footers to each page),
and send it to lpr.  Something like:

   open( FILENAMES_TO_PRINTER, "| xargs pr | lp -");
   foreach my $file (@files) {
      print FILENAMES_TO_PRINTER $file, "\n";
   }
   close FILENAMES_TO_PRINTER;
[untested]

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Fri, 10 Jan 2003 00:07:38 +0100
From: Dante Ortolani <l.ortolani@ecosystemspa.com>
Subject: Isogest 3.1 New release
Message-Id: <avkuge$fuu$1@lacerta.tiscalinet.it>

Hi,
you can try on line by a demo the last release of my software written in 
pure perl.
Isogest is a Office Suite that work with Mysql or Postgres.

Site http://isogest.sourceforge.net/
Demo http://isogest.sourceforge.net/Demo/

[LucaS]


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

Date: Thu, 09 Jan 2003 17:17:35 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Net::Ping issue
Message-Id: <3E1DF4FF.E025E38E@earthlink.net>

Sunil wrote:
> 
> All,
>     I am trying to create a perl ping utility which can be used in
> both unix and windows boxes.

Have you considered checking if such a thing already exists?

For example, Net::Ping::External, from CPAN?

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 09 Jan 2003 17:44:16 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: pack( "N", inet_aton("client.example.net"))
Message-Id: <3E1DFB40.855E3EE7@earthlink.net>

M. S. Bob wrote:
[snip]
> my $i;
> print map { ++$i % 16 ? "$_ " : "$_\n" }
> unpack( 'H2' x length( $buffer ), $buffer ),
>         length( $buffer ) % 16 ? "\n" : '';
> print "\n";

This has little to do with your problem, but might I suggest you change
this to:

   {
      local $, = " ";
      local $\ = "\n";
      for my $i ( 0 .. length($buffer)/16 ) {
         print unpack("H2" x 16, substr($buffer, $i*16, 16));
      }
      if( my $i = length($buffer) % 16 ) {
         print unpack("H2" x $i, substr($buffer, -$i));
      }
      print "";
   }
[untested]

It's a bit longer, but it's more readable, I think.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 09 Jan 2003 22:47:44 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Recreating directory hierarchy
Message-Id: <uupr1v8r0lf291p2pr47938pr6c6vm82da@4ax.com>

On Wed, 08 Jan 2003 18:39:20 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:

>Michele Dondi wrote:
>> 
>> On Mon, 06 Jan 2003 23:23:28 -0500, Benjamin Goldberg
>> <goldbb2@earthlink.net> wrote:
>> 
>> >      return if -e $dest;
>>        ^^^^^^
>> 
>> Just a minor point, not strictly Perl-related: wouldn't it be better
>> to warn() the user too?
>
>I suppose... you want to provide some modified code?

No, really that was not my intention and OTOH I fully respect your
expertise, so if you think it's not the case to warn the user, I'll
accept it (an explanation would help, though). However I was thinking
of something like:

  warn("'$dest' exists: refusing to clobber it"), return if -e $dest;

[...]

I was just about to send this post when I realized, on a second
thought, that if '-e $dest' and $_ is not the toplevel (source) dir,
then also the dir containing $_ has a corresponding $dest (that does
exist) that must have been checked before, and if it had, it would
have not been processed.

So (reasoning "backwards") the line of code above could have been
executed for the destination toplevel dir only and in case it already
existed, the program would have prompted the user to press return and
then silently terminate.

But maybe I'm missing something obvious and all this is utter
nonsense...


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: 9 Jan 2003 14:40:24 -0800
From: mweb@inwind.it (Emmy)
Subject: Red Hat 8 breaking one-liner signature script
Message-Id: <e8974ed3.0301091440.42af1b76@posting.google.com>

Hello,

I used in mutt this one-liner for random signature,

set signature="perl -an0777F'\n\s*\n' -e 'print \$F[rand(@F)],
\"\ngee\n\"' ~/pers_doc/massime|"

All on one line, of course. The ~/pers_doc/massime text file contains
assorted quotes, often spanning more than one line. The quote
separator is an empty line (\n\s*\n above)

Now, used with Mutt 1.4, Perl 5.8 inside RH 8.0, it only prints one word of
a random sentence (see below, I added the "gee" string just to see
where it would be printed). From an xterm the one liner works
perfectly, i.e. prints whole multi-line signatures as before (removing
the backslashes before $F and the \n double quotes, of course). From
Mutt (launched as "xterm -e mutt" from the WM menu) it doesn't work.

This is the original quote in the "massime" file from which the word
"ratify", at the bottom of this message, came from:

All over the place, from the popular culture to the propaganda system,
there is constant pressure to make people feel that they are helpless,
that the only role they can have is to ratify decisions and to
consume.
                                                Noam Chomsky
 
It is splitting it in words, not in lines anymore, isn't it? Why?
 
What should I fix, and where should I look? It is known that Perl 5.8
and the Unicode system-wide settings don't really like each other yet,
but this is probably also due to the environment in which mutt
launches that script, right? Either way, any suggestion is
appreciated.

        TIA,
               emmy


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

Date: Thu, 09 Jan 2003 21:40:17 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Taint check question
Message-Id: <1254700.RGsibCF44d@nyoga.dubu.de>

Simon Andrews wrote:
> Copy your executable from wherever your reference copy is to your
> current directory
>   use File::Copy;
>   copy ('/usr/bin/oldprog','./oldprog') || die "Can't copy file $!";

I would prefer link()ing the program to the new directory, if possible,
not copying it.

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
If one synchronized swimmer drowns, do the rest have to drown too?



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

Date: 9 Jan 2003 11:07:25 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: These are discouraging stats to Perlistas & Pythonistas...
Message-Id: <776e0325.0301091107.3cf2de32@posting.google.com>

Andrew Lee <> wrote in message news:<i02p1vkdio5uvmfrj84koeoe1mr2ibb3jk@4ax.com>...

> 
> There is no end to the stupidity of recruiters/headhunters/incopetent
> IT managers.  How many times have you seen an advertisement for PEARL?
> I had a manager once who insisted that strict.pm was useless "cause it
> breaks all my programs."
> 
> Sheesh!

Ha! I had to laugh out loud at this one Andrew, mainly because IT'S
TRUE! I was asked to please remove -w and -T from the she-bang line,
and take out "use strict" because when people have to modify my code,
they are getting warnings and errors. They were complaining that they
have to remove them themselves and why didn't I just stop using them??

I must be STUPID!

Thanks for the laugh I needed one today..
-Gx


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

Date: Thu, 09 Jan 2003 21:01:43 GMT
From: "Vladimir P." <vladimir@NoSpamPLZ.net>
Subject: Re: tracing the HTTP
Message-Id: <XqlT9.7347$iR6.37101@wagner.videotron.net>

On Wed, 8 Jan 2003 19:44:14 +0100, Sascha Kerschhofer wrote:
> Hi,
> 
> How can I log the communication between my web-browser and any webserver? I
> am interested in the
> 
> POST /download/xy.php HTTP/1.1
> ... stuff.
> 
> Or is there any software that does that for me (Windows Software)?
> Thank you.
> Sascha
> 
> 

Any sniffer will do -  Solaris comes with snoop and Linux with tcpdump....
Since you are stuck in M$Win land,  install windump (windump.polito.it).


-- 
 .signature: No such file or directory


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

Date: Thu, 09 Jan 2003 21:12:41 +0000
From: "Peter A. Krupa" <pkrupa@redwood.rsc.raytheon.com>
Subject: Re: tracing the HTTP
Message-Id: <3E1DE5C9.DCD4769B@redwood.rsc.raytheon.com>

I used this snippet of Perl to see what my browser was requesting.  It's just a
basic server out of an O'Reilly book. You would need to configure your browser
to use the localhost as a proxy.  You could probably just take Tom
Christiansen's fwdport and modify it to dump what's going on:
http://www.cpan.org/authors/Tom_Christiansen/scripts/fwdport.gz

* * *

use IO::Socket;

socket ( SERVER, PF_INET, SOCK_STREAM, getprotobyname ( 'tcp' ) ) || die $!;

$serveraddress = sockaddr_in ( 80, INADDR_ANY );

bind ( SERVER, $serveraddress ) || die $!;

listen ( SERVER, 1 );

while ( 1 )
{
  accept ( CLIENT, SERVER );

  recv ( CLIENT, $data, 4096, 0 );

  print ( "$data\n" );

  sleep ( 1 );

  close ( CLIENT );
}



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

Date: 9 Jan 2003 13:14:02 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Unix Vars declared in system() call -> %ENV
Message-Id: <3e1de61a@news.victoria.tc.ca>

Christopher Hamel (hamelcd@hotmail.com) wrote:

: The ksh program in particular is a centralized variable respository,
: so altought I could put it into Perl, it's used by a multitude of
: other programs (Perl and ksh), and it's best to only have one place to
: look.

Modify the centralized shell program to use a perl script, and then use
that perl script in other perl scripts.  Your various shell scripts that
use the variables don't need to change. 

One simple minded approach shown below.  The perl code could be improved,
but shows what I mean.


Previous - central.sh

	#!/bin/sh
	export MY_IMPORTANT_VAR="this is it's value";

New
 perl script - central.pl

	#!/usr/bin/perl

	$MY_IMPORTANT_VAR="this is it's value";

	return 1 if caller;    # exit if require'd

	print "export MY_IMPORTANT_VAR=\"$MY_IMPORTANT_VAR\"\n";


 shell script - central.sh

	#!/bin/sh
	eval `central.pl`

 example perl program
	#!perl
	require "central.pl";
	print $MY_IMPORTANT_VAR;

 example shell script, same as before

	#!/bin/sh
	. central.sh
	echo $MY_IMPORTANT_VAR



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

Date: Thu, 09 Jan 2003 17:32:56 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Unix Vars declared in system() call -> %ENV
Message-Id: <3E1DF898.7EF043DD@earthlink.net>

Christopher Hamel wrote:
> 
> Perhaps this is easy; perhaps it's impossible.
> 
> Within a Perl program, I have a desire to launch a Unix Korn shell
> script that exports a number of variables.  A snippet of the program
> looks as follows:
> 
>   if [[ $HOST = "0xae026c0" ]] ; then
>     export SERVER=test21
>   else [[ $HOST = "0xae02647" ]] ; then
>     export SERVER=prod21
>   fi
> 
>   export FP_DIR=/i2/$ENVIRONMENT/fp
> 
> (pretty basic stuff)
> 
> Is there any way to launch this program within Perl and have the
> variable declarations within the program update %ENV?

Sure:
   open SHELL_SCRIPT, "-|", '. my_unix_script >/dev/null; env'
      or die "Couldn't start shell script: $!";
   my $lastkey = "";
   while( my $keyvalue = <SHELL_SCRIPT> ) {
      chomp($keyvalue);
      my ($key, $value) = split /=/, $keyvalue, 2;
      if( defined($value) ) {
         $ENV{$lastkey = $key} = $value;
      } else {
         $ENV{$lastkey} .= "\n" . $key;
      }
   }
   close SHELL_SCRIPT
      or die "Error running shell script: \$? == $?\n";
[untested]



-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 09 Jan 2003 16:22:46 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: What is a simple way to read and write zip files?
Message-Id: <3E1DE826.21FF9A7@earthlink.net>

Hal Vaughan wrote:
> 
> I am working with something that is close to an odd mailmerge.  I need
> to open a file, modify it, then close it.  The only problem is the
> files I have to modify are OpenOffice.org files, which are compressed
> zip files and contain more than one file.
> 
> I don't want to mess with temp files, since I have to read in a master
> file and produce a very large number of files from it.  The easiest
> thing for me to do would be to read the entire file into a scalar and
> then uncompress it (or read it directly to an uncompressed scalar),
> make my changes to the content, then re-compress it and write it back
> out to a new file.

Look into Archive::ZIP, on CPAN.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 09 Jan 2003 16:47:02 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Why is map so much faster then a nested for loop?
Message-Id: <3E1DEDD6.1939048B@earthlink.net>

Aaron Simmons wrote:
> 
> I recently optimized some of my code by using a map instead of a
> nested for loop.  This one change took the code that used to take 53
> seconds to iterate over 95,000 rows down to 4 seconds.
> 
> Original Code:
> for ($i=0; $i<@{$rows->[0]}; $i++) {
>     $row = +{}; # Create new anonymous hash
> 
>     for ($j=0; $j<$RS->Fields->Count; $j++) {
>         $row->{$fields[$j]} = $rows->[$j]->[$i];
>     }
> 
>     push @{$rs}, $row;
> }
[snip sped up code]
> Why and how is this so much faster?

You're doing a number of different steps for your speedup.

Compare your original code to:

my $max = $RS->Fields->Count() - 1;
for my $i ( 0 .. $#{$rows->[0]} ) {
   my %row;
   for my $j ( 0 .. $max ) {
      $row{$fields[$j]} = $rows->[$j][$i];
   }
   push @{$rs}, \%row;
}

Simply changing the C-style for loops into more perlish loops produces a
fairly large speedup, all by itself.  Changing the inner for loop into a
map, as follows:

my $max = $RS->Fields->Count() - 1;
for my $i ( 0 .. $#{$rows->[0]} ) {
   my %row = map {;
      $fields[$_], $rows->[$_][$i];
   } 0 .. $max;
   push @{$rs}, \%row;
}

Produces yet another speedup (I think -- I'm not sure on this one).
And certainly changing the list-to-hash construction into a direct
anonymous hash construction produces a bit of a speedup:

my $max = $RS->Fields->Count() - 1;
for my $i ( 0 .. $#{$rows->[0]} ) {
   push @{$rs}, +{
      map {;
         $fields[$_], $rows->[$_][$i];
      } 0 .. $max
   };
}

You might get even more speedup by changing the outer for loop into a
map, too:

my $max = $RS->Fields->Count() - 1;
push @{$rs}, map {;
   my $i = $_;
   +{
      map {;
         $fields[$_], $rows->[$_][$i];
      } 0 .. $max
   };
} 0 .. $#{$rows->[0]};

Other possibilities to consider are hash slices:

my $max = $RS->Fields->Count() - 1;
for my $i ( 0 .. $#{$rows->[0]} ) {
   my %row;
   @row{@fields} = map $_->[$i], @$rows;
   push @{$rs}, \%row;
}

Possibly changing the for to a map:

my $max = $RS->Fields->Count() - 1;
push @{$rs}, map {; my $i = $_; my %row;
   @row{@fields} = map $_->[$i], @$rows;
   \%row;
} 0 .. $#{$rows->[0]};

(Both of these assume that there are the same number of items in @fields
as there are in @{$rows->[0]}.)

Caveat Lector: All of these code snippets are untested and
unbenchmarked.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 09 Jan 2003 16:47:24 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: Re: win32::ole excel hiding columns FIXED
Message-Id: <Xns92FEAACC2F47Blanceaugustmailcom@216.166.71.236>

$Sheet->Columns("$qtrhide:$qtrhide")->EntireColumn->{Hidden}="True";

Lance Hoffmeyer <lance@augustmail.com> wrote in 
news:Xns92FEA775C3ABClanceaugustmailcom@216.166.71.236:

> What do I need to add/subtract here?
> 
> $Sheet->Columns($qtrhide)->EntireColumn->Hidden->{Value} = ("False");
> 



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

Date: Thu, 09 Jan 2003 16:27:43 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: win32::ole excel hiding columns
Message-Id: <Xns92FEA775C3ABClanceaugustmailcom@216.166.71.236>

What do I need to add/subtract here?

$Sheet->Columns($qtrhide)->EntireColumn->Hidden->{Value} = ("False");


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

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


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