[22484] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4705 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 13 14:05:57 2003

Date: Thu, 13 Mar 2003 11:05:10 -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, 13 Mar 2003     Volume: 10 Number: 4705

Today's topics:
        ActiveState 5.8 - Download a whole repository? <finisterre@postmaster.co.uk>
    Re: ActiveState 5.8 - Download a whole repository? <usenet@dwall.fastmail.fm>
    Re: ActiveState 5.8 - Download a whole repository? <dont@want.spam>
    Re: Alternatives to FormMail <sbour@niaid.nih.gov>
    Re: Building a hierarchy <tzz@lifelogs.com>
    Re: Counter64 values returned by the Net::SNMP module (Don Smith)
    Re: Creating a dynamic list of filehandles <cbk047@email.mot.com>
    Re: Creating a dynamic list of filehandles <cbk047@email.mot.com>
    Re: Creating a dynamic list of filehandles <cbk047@email.mot.com>
    Re: Creating a dynamic list of filehandles <tassilo.parseval@rwth-aachen.de>
    Re: handling multiple reponses from a Net::Telnet sessi (Beeblebrox)
    Re: handling multiple reponses from a Net::Telnet sessi (Anno Siegel)
    Re: HoH vs. more memory efficient way to sum log entrie <bkennedy@hmsonline.com>
    Re: HoH vs. more memory efficient way to sum log entrie <grazz@nyc.rr.com>
    Re: HoH vs. more memory efficient way to sum log entrie <grazz@nyc.rr.com>
    Re: HoH vs. more memory efficient way to sum log entrie <usenet@dwall.fastmail.fm>
    Re: how to create own perl module <tzz@lifelogs.com>
        Interpolation problem? (Paul)
    Re: Interpolation problem? <usenet@dwall.fastmail.fm>
    Re: Letting users change their password via web form... <tzz@lifelogs.com>
    Re: Merging log files using hash - good idea/possible? (Thomas)
    Re: problems when installing cpan <tassilo.parseval@rwth-aachen.de>
    Re: Trying to Learn Chomp <mpapec@yahoo.com>
    Re: Trying to Learn Chomp (Anno Siegel)
    Re: what is current user from .htaccess? (Randal L. Schwartz)
    Re: What's wrong with the Perl docs <mpapec@yahoo.com>
    Re: What's wrong with the Perl docs <abigail@abigail.nl>
    Re: What's wrong with the Perl docs (Anno Siegel)
    Re: XPATH vs Regular Expressions <mirod@xmltwig.com>
    Re: XPATH vs Regular Expressions <none@none.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 13 Mar 2003 16:53:00 -0000
From: "Fred Finisterre" <finisterre@postmaster.co.uk>
Subject: ActiveState 5.8 - Download a whole repository?
Message-Id: <b4qd0b$bh1$1@news8.svr.pol.co.uk>

Is there anywhere I can download an entire Perl repository. I can't get PPM
to work through my company's web proxy - even when I use the environment
variables to set my proxy name, userid and password in DOS.

Cheers,

Fred.




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

Date: Thu, 13 Mar 2003 17:06:37 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: ActiveState 5.8 - Download a whole repository?
Message-Id: <Xns933D7B313BC2Edkwwashere@216.168.3.30>

Fred Finisterre <finisterre@postmaster.co.uk> wrote on 13 Mar 2003:

> Is there anywhere I can download an entire Perl repository. I
> can't get PPM to work through my company's web proxy - even when I
> use the environment variables to set my proxy name, userid and
> password in DOS. 

You seem to have read the "PPM, Proxies and Firewalls" section of the 
PPM docs, but skipped the first few paragraphs.  Take another look. :-)

http://ppm.activestate.com/PPMPackages/

-- 
David K. Wall - usenet@dwall.fastmail.fm
WWJD? JWRTFM.


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

Date: Thu, 13 Mar 2003 17:28:08 +0000
From: Chris Lowth <dont@want.spam>
Subject: Re: ActiveState 5.8 - Download a whole repository?
Message-Id: <3e3ca.254$iZ5.200@newsfep3-gui.server.ntli.net>

Fred Finisterre wrote:

> Is there anywhere I can download an entire Perl repository. I can't get
> PPM to work through my company's web proxy - even when I use the
> environment variables to set my proxy name, userid and password in DOS.
> 
> Cheers,
> 
> Fred.

Take a look at..

http://ppm.activestate.com/PPMPackages/

Try "wget" to pull down the bits you want.

Chris
-- 
Real address: chris at lowth dot sea oh em.
For free GPL e-mail virus blockade ...
  http://protector.sourceforge.net


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

Date: Thu, 13 Mar 2003 13:23:02 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Re: Alternatives to FormMail
Message-Id: <BA9636B6.6092%sbour@niaid.nih.gov>

in article 9d3debce.0303130621.4106c290@posting.google.com, Dave Cross at
dave@dave.org.uk wrote on 3/13/03 09:21:

> sbour@niaid.nih.gov (Steph) top-posted
> news:<79e85d7d.0303121139.73dc1620@posting.google.com>...
>> Actually, I ask this like I know there are many but I don't know which
>> one to use ;-) At this point I'm using FormMail from the London Perl
>> Mongers nms project (Matt Wright's code emulation).
>> So I'll rephrase: what is in your opinion the best combination of perl
>> script and email service for web forms. I'm looking at SendMail.cgi
>> and it looks like it could possible do both. However the doc is a
>> little slim for a newbie like me and I'm not sure how to modify my web
>> forms to use SendMail.cgi instead of the current formmail/sendmail
>> combination.
> 
> Have you considered the nms_sendmail script that you can also get from
> nms?
> 
> Or, the latest version of the nms formmail script don't need an
> external email program, you can configure it to talk directly to an
> SMTP server.
> 
> Dave...

Thanks for the tips Dave. However, it appears that nms-formmmail 2.22 still
uses /usr/sbin/sendmail by default. It's true though that nms-sendmail can
replace /usr/sbin/sendmail and that nms-formmail can be configured to use
nms-sendmail. However, that still leaves me with a 2 elements system to
support and configure. The SendMail script here
<http://www.tneoh.zoneit.com/perl/SendMail/> appears to work under Mac OS X
client with no mail server installed and an external SMTP.
Please correct me if I'm wrong. 



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

Date: Thu, 13 Mar 2003 11:45:30 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Building a hierarchy
Message-Id: <4nn0jztdud.fsf@lockgroove.bwh.harvard.edu>

On Thu, 13 Mar 2003, tore@aursand.no wrote:
> I had a hard time figuring out a subject which could cover the topic
> of my post, so bear with me. :)
> 
> PROBLEM: I need to build a hierarchy from my elements in my
> database. The elements are stored in an 'element' table, while they
> relations (and positions based on the relations) are stored in an
> 'element_parent' table;
> 
>   +----------------+     +----------------+
>   | element        |     | element_parent |
>   +----------------+     +----------------+
>   | element_id     |     | element_id     |
>   | elementtype_id |     | parent_id      |
>   +----------------+     | position       |
>                          +----------------+
> 
> Why do it this way?  Why don't just store 'parent_id' in the
> 'element' table?  Reason: One element can have more than one parent,
> and in addition have different 'position' values depending on the
> parent element.

Look at the Class::DBI module.

http://www.class-dbi.com

or on CPAN.

It supports this sort of 1-to-n (has_many) relationships easily, and
will minimize the work you do to connect and use your database table.
The script you show can probably be reduced to 1/10 of its current
size, not to mention it would be much more logic-oriented (instead of
SQL-oriented) if you use Class::DBI.

In addition, Class::DBI is very good about caching results, so it will
only query the database when it has to.

HTH
Ted


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

Date: 13 Mar 2003 09:31:19 -0800
From: neauva@yahoo.com (Don Smith)
Subject: Re: Counter64 values returned by the Net::SNMP module
Message-Id: <b1deef29.0303130931.35decd56@posting.google.com>

Speaking of Net::SNMP v4.0.3....

Has anyone out there modified the module so that "get_request" and
"get_next_request" functions return the value types as well?
The functions currently return OID=>value pairs (var_bind_list).

The module conveniently translates the values for you and throws
away the type info (e.g., OCTET_STRING).  But, I'm writing a tool
that will explore an agent, without any a-priori MIB info available.
I need that type info that gets returned.

It looks like a change to Message.pm and/or PDU.pm would be somewhat
extensive and a bit nasty.  Anyone out there have any suggestions?

TIA!
D. Smith



"Cox NNTP" <dgay@init0.org> wrote in message news:<u7d9a.114499$P1.7082807@news1.east.cox.net>...
> >
> > I am using the Net::SNMP module v4.0.3 (with ActiveState Perl 5.6.1)
> > to return, among other things, Counter64 values. But every such value
> > is returned as either 0 or 9223372036854775808.
> >
> > (This is data defined by the Fiber Channel Management MIB, being
> > returned by a McDATA SNMP Agent.)
> >
> > Obviously not all statistics counts will have exactly the same
> > large value; so it looks like something is wrong here! Any ideas?
> >
> > I'm pulling the values straight out of the $session->var_bind_list
> > hash.
> >
> 
> Can you retrieve the values you would expect by using snmpget/walk (without
> using the perl module)?


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

Date: Thu, 13 Mar 2003 10:06:58 -0600
From: Bryan Krone <cbk047@email.mot.com>
Subject: Re: Creating a dynamic list of filehandles
Message-Id: <3E70ACA2.BAC9A140@email.mot.com>

Mark Drummond wrote:

> Hi all. I want to create a set of filehandles, based on a list of
> "things" in another file. For example, say I have a file which contains
> the names of all the disks in a disk array, something like this:
>
> c0t0d0
> c0t1d0
> c1t0d0
> c1t1d0
> .
> .
> .
>
> Now let's say I have aanother (single) file with performance data on all
> these disks, like iostat output. I want to take that performance data
> and sift it into a set of files based on the disk names. So I want to
> create a set of files named "$diskname.dat" and then write data lines
> for each disk into it's own file.
>
> Maybe I am missing something obvious, but I cannot figure out a way to
> this in a generic manner, so it will work with an arbitrary list of
> disk, or cpus, or other "things". I think I could do it if I used a
> single filehandle and used a variable for the filename like:
>
> [not syntactically correct]
> foreach $dataline {
>         match the correct object (disk, cpu, whatever) {
>                 open FOO, $object.dat
>                 write FOO $bar
>         }
> }
>
> But that solution, if workable, would result in me opening and closing
> the files thousands of times each. I would prefer to just open each file
> once, something more like:
>
>         open $FOO, $object.dat
>
> Though I am guessing that is not possible?
>
> Any ideas?
>
> Mark



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

Date: Thu, 13 Mar 2003 10:19:16 -0600
From: Bryan Krone <cbk047@email.mot.com>
Subject: Re: Creating a dynamic list of filehandles
Message-Id: <3E70AF84.9E638EB4@email.mot.com>

Mark Drummond wrote:
> 
> Hi all. I want to create a set of filehandles, based on a list of
> "things" in another file. For example, say I have a file which contains
> the names of all the disks in a disk array, something like this:
> 
> c0t0d0
> c0t1d0
> c1t0d0
> c1t1d0
> .
> .
> .
> 
> Now let's say I have aanother (single) file with performance data on all
> these disks, like iostat output. I want to take that performance data
> and sift it into a set of files based on the disk names. So I want to
> create a set of files named "$diskname.dat" and then write data lines
> for each disk into it's own file.
> 
> Maybe I am missing something obvious, but I cannot figure out a way to
> this in a generic manner, so it will work with an arbitrary list of
> disk, or cpus, or other "things". I think I could do it if I used a
> single filehandle and used a variable for the filename like:
> 
> [not syntactically correct]
> foreach $dataline {
>         match the correct object (disk, cpu, whatever) {
>                 open FOO, $object.dat
>                 write FOO $bar
>         }
> }


[not syntactically correct]
foreach $dataline {
        match the correct object (disk, cpu, whatever) {
		if( !defined $openfile{$object} )
		{
                	open FOO, $object.dat
			$openfile{$object}++;
		}
                write FOO $bar
        }
}



> 
> But that solution, if workable, would result in me opening and closing
> the files thousands of times each. I would prefer to just open each file
> once, something more like:
> 
>         open $FOO, $object.dat
> 
> Though I am guessing that is not possible?
> 
> Any ideas?
> 
> Mark


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

Date: Thu, 13 Mar 2003 10:37:03 -0600
From: Bryan Krone <cbk047@email.mot.com>
Subject: Re: Creating a dynamic list of filehandles
Message-Id: <3E70B3AF.D0132EA9@email.mot.com>

Bryan Krone wrote:
> 
> Mark Drummond wrote:
> >
> > Hi all. I want to create a set of filehandles, based on a list of
> > "things" in another file. For example, say I have a file which contains
> > the names of all the disks in a disk array, something like this:
> >
> > c0t0d0
> > c0t1d0
> > c1t0d0
> > c1t1d0
> > .
> > .
> > .
> >
> > Now let's say I have aanother (single) file with performance data on all
> > these disks, like iostat output. I want to take that performance data
> > and sift it into a set of files based on the disk names. So I want to
> > create a set of files named "$diskname.dat" and then write data lines
> > for each disk into it's own file.
> >
> > Maybe I am missing something obvious, but I cannot figure out a way to
> > this in a generic manner, so it will work with an arbitrary list of
> > disk, or cpus, or other "things". I think I could do it if I used a
> > single filehandle and used a variable for the filename like:
> >
> > [not syntactically correct]
> > foreach $dataline {
> >         match the correct object (disk, cpu, whatever) {
> >                 open FOO, $object.dat
> >                 write FOO $bar
> >         }
> > }
> 
[not syntactically correct]
foreach $dataline {
        match the correct object (disk, cpu, whatever) {
                if( !defined $openfile{$object} )
                {
                        open $object, $object.dat
                        $openfile{$object}++;
                }
                write $object $bar
        }
}

> >
> > But that solution, if workable, would result in me opening and closing
> > the files thousands of times each. I would prefer to just open each file
> > once, something more like:
> >
> >         open $FOO, $object.dat
> >
> > Though I am guessing that is not possible?
> >
> > Any ideas?
> >
> > Mark


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

Date: 13 Mar 2003 16:52:15 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Creating a dynamic list of filehandles
Message-Id: <b4qcvv$a5b$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Mark Drummond:

[ working with lot of open file-handles ]

> Maybe I am missing something obvious, but I cannot figure out a way to 
> this in a generic manner, so it will work with an arbitrary list of 
> disk, or cpus, or other "things". I think I could do it if I used a 
> single filehandle and used a variable for the filename like:
> 
> [not syntactically correct]
> foreach $dataline {
> 	match the correct object (disk, cpu, whatever) {
> 		open FOO, $object.dat
> 		write FOO $bar
> 	}
> }
> 
> But that solution, if workable, would result in me opening and closing 
> the files thousands of times each. I would prefer to just open each file 
> once, something more like:
> 
> 	open $FOO, $object.dat
> 
> Though I am guessing that is not possible?

It is possible (with Perl >= 5.6.0). You could use a hash to store the
handle based on some string:

    my %handles;
    ...
    open $handles{ $object }, ">$object.dat" or die $!;

And later:

    print { $handles{ $object } } "Some string";
          ^                     ^

You need these two curlies since in this case the filehandle is returned
by an expression. For reading, there's also a slight red-herring. You
can't directly read from such a handle but need to pull it into a simple
scalar before that:

    my $h = $handles{ $object };
    while (<$h>) {
        ...
    }

But be aware that your operating system may have a limit of how many
file handles you can keep open. Depending on how low this is, you might
need to close and re-open the handles each time you need them.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 13 Mar 2003 10:05:10 -0800
From: sl1433@hotmail.com (Beeblebrox)
Subject: Re: handling multiple reponses from a Net::Telnet session?
Message-Id: <c976cb73.0303131005.71952b80@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b4pobv$bit$3@mamenchi.zrz.TU-Berlin.DE>...
> Beeblebrox <sl1433@hotmail.com> wrote in comp.lang.perl.misc:
> > Hello,
> > 
> > I have a perl script that telnet's into some of our network equipment,
> > to automate some tasks.  I use a series of "print"/"waitfor"s; it
> > works great, unless the last person to login didn't save a config
> > change on the network device, in which case the network device prompts
> > for a confirmation (that I saw the alert).
> > 
> > So, how do I handle more-than-1 possible response to a particular
> > "print" entry I make within an Net::Telnet session?  A couple examples
> > would be fantastic.  I've read thru the perl.org cpan doc, but it
> > didn't have any examples that fit my situation.
> 
> Have you noticed you can give waitfor() a regular expression to wait for?
> 
> Anno

Yes, but in case #1, I don't need to give any answer, and in case #2 I
answer with a "y".

I can write a waitfor with more than 1 possibility, but how do I give
a different response based on the feedback from the waitfor?  I've
already read the Net::Telnet manpage in perl.org's CPAN site, but it
doesn't appear to give an example of how to handle this.


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

Date: 13 Mar 2003 18:37:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: handling multiple reponses from a Net::Telnet session?
Message-Id: <b4qj4o$4us$2@mamenchi.zrz.TU-Berlin.DE>

Beeblebrox <sl1433@hotmail.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<b4pobv$bit$3@mamenchi.zrz.TU-Berlin.DE>...
> > Beeblebrox <sl1433@hotmail.com> wrote in comp.lang.perl.misc:
> > > Hello,
> > > 
> > > I have a perl script that telnet's into some of our network equipment,
> > > to automate some tasks.  I use a series of "print"/"waitfor"s; it
> > > works great, unless the last person to login didn't save a config
> > > change on the network device, in which case the network device prompts
> > > for a confirmation (that I saw the alert).
> > > 
> > > So, how do I handle more-than-1 possible response to a particular
> > > "print" entry I make within an Net::Telnet session?  A couple examples
> > > would be fantastic.  I've read thru the perl.org cpan doc, but it
> > > didn't have any examples that fit my situation.
> > 
> > Have you noticed you can give waitfor() a regular expression to wait for?
> > 
> > Anno
> 
> Yes, but in case #1, I don't need to give any answer, and in case #2 I
> answer with a "y".
> 
> I can write a waitfor with more than 1 possibility, but how do I give
> a different response based on the feedback from the waitfor?  I've
> already read the Net::Telnet manpage in perl.org's CPAN site, but it
> doesn't appear to give an example of how to handle this.

Why don't you read it on your own machine?  "perldoc Net::Telnet" should
bring it up.  There, look for the method "waitfor" you're working with.
You will find this example of a call:

    ($prematch, $match) = $obj->waitfor($matchop);

So presumably $match will contain what $matchop matched.  Base your
reply, or lack of it, on $match.

Anno


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

Date: Thu, 13 Mar 2003 11:58:25 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: HoH vs. more memory efficient way to sum log entries?
Message-Id: <GsOcnds6LOOxJO2jXTWcpQ@giganews.com>


<adam@pls.posthere.com> wrote in message
news:bk817vgm8d2lqojd6ofatrj9fi843hglnj@4ax.com...

> But since I am running it on the squid logs for the entire month of
> February (and our cache is big/busy), it is running out of memory
>
> ...
>
> open(LOG,"$squidlog") || die "cannot open $squidlog: $!";
>
> foreach $match (<LOG>)
>  {

What this is doing is reading the entire log file into memory, and is
probably the culprit rather than your data structure.  Try:

while(my $match = <LOG>) {

When you call <LOG> in your code, it is an array context.  This means that
it will read every line from the handle and return it as an array.  The code
I provded calls <LOG> in scalar context, meaning that it will pull only the
next line.  The 'while' will keep going until the end of file, in which
<LOG> return undef and the loop terminates.

--Ben Kennedy




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

Date: Thu, 13 Mar 2003 17:51:09 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: HoH vs. more memory efficient way to sum log entries?
Message-Id: <hy3ca.130694$ma2.24651962@twister.nyc.rr.com>

adam@pls.posthere.com wrote:
> 
> I use this script or one like it for lots of handy 
> counting jobs.  In the case below I am creating a 
> Hash of a Hash to sum up the amount of data each 
> "page type" has.  So expected output would look like 
> this:
>    www.somesite.com nonpub.htm = 496343   (that's in bytes)
> 
> But since I am running it on the squid logs for the 
> entire month of February (and our cache is big/busy), 
> it is running out of memory.  Do any of you know of a 
> more memory efficient way to do such a count?

use DB_File;

And instead of a multi-level hash, you can just use 
the "output" string for the key:

      $db{"$domain: $file"} += $bytes;
    } 

    while ( my($k,$v) = each %db ) {
      print "$k = $v\n";
    }

This doesn't do any grouping, but if you use the 
btree database it will come out sorted.

If you need to extract $domain and $file again,
it might be better to use $;

      $db{$domain,$file} += $bytes;
    }

    while ( my($k,$v) = each %db ) {
      my ($domain, $file) = split /$;/, $v;

And you probably want to use a list slice to split
the log fields:

    my ($bytes, $uri) = (split)[8,10];

Or at least use "undef" for padding (not $junk).

HTH
-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'


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

Date: Thu, 13 Mar 2003 17:53:21 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: HoH vs. more memory efficient way to sum log entries?
Message-Id: <lA3ca.130695$ma2.24653393@twister.nyc.rr.com>

Ben Kennedy <bkennedy@hmsonline.com> wrote:
> 
> <adam@pls.posthere.com> wrote in message
> news:bk817vgm8d2lqojd6ofatrj9fi843hglnj@4ax.com...
> 
>> But since I am running it on the squid logs for the entire month of
>> February (and our cache is big/busy), it is running out of memory
>>
>> ...
>>
>> open(LOG,"$squidlog") || die "cannot open $squidlog: $!";
>>
>> foreach $match (<LOG>)
>>  {
> 
> What this is doing is reading the entire log file into memory, and is
> probably the culprit rather than your data structure.  Try:

Rrr.. didn't even see that.

Just ignore my suggestion downthread. :)

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'


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

Date: Thu, 13 Mar 2003 18:17:59 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: HoH vs. more memory efficient way to sum log entries?
Message-Id: <Xns933D874B2C0C9dkwwashere@216.168.3.30>

 <adam@pls.posthere.com> wrote on 13 Mar 2003:

[program running out of memory]

> #!/usr/bin/perl -w
> 
> $squidlog="./feb_squid_logs";
> 
> open(LOG,"$squidlog") || die "cannot open $squidlog: $!";
> 
> foreach $match (<LOG>) 

As Ben Kennedy pointed out, the real memory hog is <LOG> in list 
context.  Use scalar context.

>  {
>     ( $junk, $junk, $junk, $junk, $junk, $junk, $junk, $junk,
>     $bytes, 
> $junk, $url, $junk, $junk, $junk ) = split(/ +/, $match);
>     next unless ($bytes > 30000);        # only count/sum objects
>     that 
> are larger than 30K
>     $file_object = $url;
>     $front_url = $url;
>     $file_object =~ s#^.*/(.*)#$1#g;
>     $front_url =~ s#^http://(.*?)/+.*#$1#g;
>     if ($file_object ne "" ) {
>          $HoH{$front_url}{$file_object} += $bytes;
>        }
> }

You can trim this a bit and make it somewhat more readable, depending 
on your idea of readable. :-)

    my %HoH;
    while (my $match = <DATA>)  {
        my ($bytes, $url) = (split(/ +/, $match))[8,10];
        next unless ($bytes > 30000);  
        if ($url =~ m|^
            (?: (?:  [^:/?#]+ ): )?     # protocol
            (?: // ([^/?#]*)  )?        # $1 = domain
            ([^?#]*)                    # $2 = path/filename
            |x) {
            $HoH{$1}{$2} += $bytes if $2 ne '/';
        }
    }

If you only want the filename instead of the entire path, I'd suggest 
File::Basename.

By the way, that regex above is from the docs for URI.pm.


> foreach $domain ( keys %HoH ) {
>       foreach $file ( keys %{ $HoH{$domain} } ) {
>             print "$domain: $file = $HoH{$domain}{$file} \n";
>       }
>       print "\n";
>}

You don't seem to care about the order, so you can cut down on memory 
usage by using each():

    while (my ($domain, $path_hash) = each %HoH ) {
        while (my ($path, $bytes) = each %{$path_hash}) {
            print "$domain: $path = $bytes\n";
        }
        print "\n";
    }

-- 
David K. Wall - usenet@dwall.fastmail.fm
WWJD? JWRTFM.


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

Date: Thu, 13 Mar 2003 11:52:31 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: how to create own perl module
Message-Id: <4nk7f3tdio.fsf@lockgroove.bwh.harvard.edu>

On 12 Mar 2003, rpalla@kentlaw.edu wrote:
> I am trying to create my own module to connect to database and to
> query some tables. please help

(assuming you mean a RDBMS using SQL)

Look at Class::DBI, http://www.class-dbi.com and on CPAN.

It may simplify the job greatly; in my experience you end up writing
a few lines of code where you used to write many lines of SQL and
code.

If you don't know what RDBMS and SQL are, you should look at books on
introductory database design or online tutorials on the same topic.

Ted


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

Date: 13 Mar 2003 10:06:04 -0800
From: ppopour@coastalnow.net (Paul)
Subject: Interpolation problem?
Message-Id: <8ba68739.0303131006.4246be16@posting.google.com>

I've tried every combination I could think of in this regex and read
the perlre and perlop material and search for post on the problem but
I must be missing the obvious.

I'm traversing an IIS server directory structure comparing file sizes.
 I want to strip my root path off of a fully qualified file name that
is being compiled as the structure is traversed.

$root  = '//server4/k\$/inetpub';
$entry = '//server4/k\$/inetpub/Wwwroot/sub1/filename.ext';
$entry =~ s/$root//;
print "$entry\n";

I've changed $root to the server name and the results are as expected.
 I've tried double quoting with double backslashes and that didn't
seem to make any difference.  I've changed the delimiter to | and #
that didn't seem to make any difference.  Any help would be
appreciated.

Paul


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

Date: Thu, 13 Mar 2003 18:22:42 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Interpolation problem?
Message-Id: <Xns933D88174EA61dkwwashere@216.168.3.30>

Paul <ppopour@coastalnow.net> wrote on 13 Mar 2003:

> I'm traversing an IIS server directory structure comparing file
> sizes. 
>  I want to strip my root path off of a fully qualified file name
>  that 
> is being compiled as the structure is traversed.
> 
> $root  = '//server4/k\$/inetpub';
> $entry = '//server4/k\$/inetpub/Wwwroot/sub1/filename.ext';
> $entry =~ s/$root//;
> print "$entry\n";

Don't use a regex.  Use File::Basename.

    use File::Basename;
    my $entry = '//server4/k\$/inetpub/Wwwroot/sub1/filename.ext';
    my $filename = basename $entry;
    print $filename;

-- 
David K. Wall - usenet@dwall.fastmail.fm
WWJD? JWRTFM.


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

Date: Thu, 13 Mar 2003 12:02:31 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Letting users change their password via web form...
Message-Id: <4nhea7td20.fsf@lockgroove.bwh.harvard.edu>

On Wed, 12 Mar 2003, Mandrake@dream-server.com wrote:
> For what it's worth, I found the answer on my own, and now I guess
> when I have a perl related question it will be better to just
> research it until I find the answer, rather than ask a question, as
> that seems to really bother people... 

If you did any sort of search (newsgroup/web) on this topic you would
find many, many answers to your original question.  Did you find them
so unsatisfactory that you wanted to try asking the question again?

Here, so you can refer to this next time:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=change+password+unix+web+form+perl&btnG=Google+Search

4600 items, just now.

> and if someone comes to ME and asks how to do it, I'll tell them,
> instead of feeding them a line and telling them to get lost.

Stick around and answer people's questions, then.

Ted


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

Date: 13 Mar 2003 09:51:45 -0800
From: tornell@hotmail.com (Thomas)
Subject: Re: Merging log files using hash - good idea/possible?
Message-Id: <24ae4e25.0303130951.d5e3083@posting.google.com>

Really interesting: When adding more servers to the cluster it could
be useful to look into it again, since the fee is annoying me.

The problem I noticed was that the number of visits increased after
the merge, because the visit sessions were broken up in a way that
Webtrends did not like. Not being a programmer myself I am always
depending on other peoples' time, and since the report users were
screaming for correct statistics and the programmer's time was
limited, I paid myself out of the problem...

I am however not completely sure if we are talking about the same
problem: merging logfiles would have worked perfectly if I just wanted
to combine logfiles from different sites into one report. My problem
is that one web site is running on two servers, and the visitors (even
within one session) are ramdomly served by them. This created the
visit count problem described above.

Regards, Thomas


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

Date: 13 Mar 2003 16:08:23 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: problems when installing cpan
Message-Id: <b4qadn$7dk$1@nets3.rz.RWTH-Aachen.DE>

Also sprach ramesh:

> I am getting errors when i am trying to install cpan module in perl. 
> getting messages saying objects not found.

Can you be more specific? What error messages (copy and paste them)?
What exactly were you trying to do? Trying to install CPAN.pm? Or
another module by using CPAN.pm?

The more information you give the more likely you'll get an useful
answer.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Thu, 13 Mar 2003 18:14:03 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Trying to Learn Chomp
Message-Id: <9id17vkfkopoc8k8bkokpgesjqh1n1347n@4ax.com>

X-Ftn-To: Bill Smith 

"Bill Smith" <wksmith@optonline.net> wrote:
>--snip--
>> I had the same problem under win32 and perl; for some reason perl
>doesn't
>> write last line to STDOUT.
>--snip--
>
>Strange, I was not able to duplicate the problem.  The script works as
>expected with or without the chomp() using ActiveState perl 5.6.1 under
>Windows ME.

I didn't try it but the problem sounded familiar. I still can't see last
line from captured output from my win editor but this is related to text
editor and not to win32 perl as I thought. :!

>The OP's use of 'cat' suggests that he is using some version of Unix,
>not win32.

or something in between. :) His prompt doesn't look like *nix.


-- 
Matija


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

Date: 13 Mar 2003 18:49:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Trying to Learn Chomp
Message-Id: <b4qjs1$4us$3@mamenchi.zrz.TU-Berlin.DE>

Matija Papec  <mpapec@yahoo.com> wrote in comp.lang.perl.misc:
> X-Ftn-To: Bill Smith 
> 
> "Bill Smith" <wksmith@optonline.net> wrote:
> >--snip--
> >> I had the same problem under win32 and perl; for some reason perl
> >doesn't
> >> write last line to STDOUT.
> >--snip--
> >
> >Strange, I was not able to duplicate the problem.  The script works as
> >expected with or without the chomp() using ActiveState perl 5.6.1 under
> >Windows ME.
> 
> I didn't try it but the problem sounded familiar. I still can't see last
> line from captured output from my win editor but this is related to text
> editor and not to win32 perl as I thought. :!

The problem is sometimes an artifact of the shell, specifically the shell
prompt.  The last line is written, but the shell prompt may go to the
beginning of the current line first and clear it (or just overwrite it).
The cure is to close all lines with a system-conformant linefeed.

Anno


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

Date: Thu, 13 Mar 2003 16:29:35 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: prempel@paradata.com (Paul)
Subject: Re: what is current user from .htaccess?
Message-Id: <771957b0cf29749c0aa6c05560725fb5@news.teranews.com>

>>>>> "Paul" == Paul  <prempel@paradata.com> writes:

Paul> I have a perl cgi program that requires user authentication via the
Paul> apache .htaccess file.  Is there a CPAN module or some sort of tool i
Paul> can use to detect what user name the user was authenticated with?

It shows up in $ENV{AUTH_TYPE} and $ENV{REMOTE_USER}.  If those
are set, the user is the latter.  If not, then not.

Paul>   On
Paul> a similar note, is there a way to expire that session so that they
Paul> must log in again?

No, that's an ugly problem.  What you should do instead is brand the
browser with a cookie and use login/logout associations on server
side, including timing out the login after some inactivity.  I have
an explanation and sample code at
<http://www.stonehenge.com/merlyn/WebTechniques/col61.html>.

print "Just another Perl hacker,"
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 13 Mar 2003 18:14:05 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: What's wrong with the Perl docs
Message-Id: <73b17vkb31rq6tj9e1pgo3rk8d7lhvc4et@4ax.com>

X-Ftn-To: Helgi Briem 

helgi@decode.is (Helgi Briem) wrote:
>>Foreign Language variations are unlikely to be kept up to date 
>
>What does that mean?  Unicode support finally got
>through in 5.8.  What is Foreign Language variation?
>Perl in kanji?
>
>>Code examples should follow the Perl style guide 
>
>Examples?

Maybe this:
---
  How can I make my hash remember the order I put elements into it?
            Use the Tie::IxHash from CPAN.

                use Tie::IxHash;
                tie my %myhash, Tie::IxHash;
                for (my $i=0; $i<20; $i++) {
                    $myhash{$i} = 2*$i;
                }
                my @keys = keys %myhash;
                # @keys = (0,1,2,3,...)
---

for (my $i=0; $i<20; $i++)
Perlstyle doesn't mention it directly but this is C construct(and a very
ugly one).



-- 
Matija


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

Date: 13 Mar 2003 17:58:13 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: What's wrong with the Perl docs
Message-Id: <slrnb71hll.jja.abigail@alexandra.abigail.nl>

Tore Aursand (tore@aursand.no) wrote on MMMCDLXXXI September MCMXCIII in
<URL:news:pan.2003.03.13.14.16.21.481185@aursand.no>:
{}  On Thu, 13 Mar 2003 13:50:37 +0000, Helgi Briem wrote:
{} >> Foreign Language variations are unlikely to be kept up to date
{}  
{} > What does that mean?  Unicode support finally got through in 5.8.  What
{} > is Foreign Language variation? Perl in kanji?
{}  
{}  Yes? :)  I think he means foreign language variations of the
{}  documentation.  How can you code in Perl if you don't understand English
{}  anyway?


Your question sounds to me like "How can you drive a car if you don't
understand English anyway?".

The professor who taughed me how to program said of Pascal: the 
programming language isn't in English. It just have keywords that
happen to look like English words.



Abigail
-- 
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/                xor      !@ _?
       exit print                                                  :
            print and push @_ => shift and goto &{(caller (0)) [3]}}
            split // => "KsvQtbuf fbsodpmu\ni flsI "  xor       & _


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

Date: 13 Mar 2003 18:25:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: What's wrong with the Perl docs
Message-Id: <b4qie7$4us$1@mamenchi.zrz.TU-Berlin.DE>

Helgi Briem <helgi@decode.is> wrote in comp.lang.perl.misc:
> On Thu, 13 Mar 2003 16:06:59 +0100, "Tore Aursand"
> <tore@aursand.no> wrote:
> 
> >On Thu, 13 Mar 2003 13:50:37 +0000, Helgi Briem wrote:
> >>> Foreign Language variations are unlikely to be kept up to date
> >
> >> What does that mean?  Unicode support finally got through 
> >>in 5.8.  What  is Foreign Language variation? Perl in kanji?
> >
> >Yes? :)  I think he means foreign language variations of the
> >documentation.  
> 
> Oh right.  Not perl in Japanese, perldoc in Japanese.
> 
> I find that a ridiculous request/requirement.  The
> standard docs should be in the language the technology
> is implemented in, in this case English. Local enthusiasts
> can try translating the docs or writing books.

I don't think the desire to read about a programming language in your
native tongue is ridiculous as such.  O'Reilly publish their most
popular books in German translation, the more prominent Perl titles
among them.

Of course, it is not going to happen with the original documentation
of a fast-moving open project like Perl.  Even if a base translation
were available, you'd need a team of, uh, three competent translators
to keep up with the doc changes (Perl and core modules) in their spare
time.  Per target language.

> >How can you code in Perl if you don't 
> >understand English anyway?
> 
> Exactly.  

You don't have to understand what the symbols mean to handle them correctly.
(Of course it helps.)  Few Lisp programmers remember (though all have read
it once, somewhere) what the names "car" and "cdr" for the most basic
operations of the language stand for.  That hasn't stopped them from using
them successfully, along with the rest of the language, some of which is
similarly obscure.

"car" is "Contents of Address part of Register", and "cdr" is "Contents
of Decrement part of Register", so remembering what they stand for means
remembering how they were implemented on one obsolete machine.  Not
particularly useful.  It is amazing how one of the most influential
computing endeavors ever got away with so lousy naming conventions.  But
I digress...

I don't think you need a profound understanding of English to benefit
from Perls excellent (with notable exceptions), naming conventions.
Being able to read a technical text comfortably is another matter.  I
guess a lot of people learn it by doing because there is no other way.
They don't have to like it.

Anno


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

Date: Thu, 13 Mar 2003 17:51:35 +0100
From: Michel Rodriguez <mirod@xmltwig.com>
Subject: Re: XPATH vs Regular Expressions
Message-Id: <b4qcuo$fe2$1@news-reader0.wanadoo.fr>

Tinky Winky wrote:

> I usually use 'regular expressions' to extract information from XML
> tags. I just discovered that I can use XPATH interface to do the same
> thing using location path like "/plist/dict/key". Is there any
> advantage using one method over another ?

The main advantage is that using XPath means that you are using a real XML
parser. Using regexp means that you are not parsing XML, but rather a
limited subset of it, probably without realizing it.

Do your regexp behave properly when facing nested identical tags, comments,
processing instructions, '>' in attribute values, entities or CDATA
sections? If yes then congratulations, you wrote an XML parser in Perl,
please share it with us! Most likely you did not, and hence you face the
prospect of you code breaking unexpectedly (and possibly silently) when
faced with perfectly valid XML. This might never happen, depending on the
context in which you are working, but the added security, and not having to
figure out exactly what kind of data you can and cannot handle often make
it worth using a full-fledged parser.

XPath itself is quite a nice language for finding things in XML and although
its features are quite different from regexps it is powerful enough to
usually do the job nicely.
 
__
Michel Rodriguez
Perl &amp; XML
http://xmltwig.com


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

Date: Thu, 13 Mar 2003 12:22:09 -0500
From: Tinky Winky <none@none.com>
Subject: Re: XPATH vs Regular Expressions
Message-Id: <ogf17v8auuj4k42fhosvkfrmr5j397htkb@4ax.com>

Thanks for advice, I think I gonna switch to XPath.





On Thu, 13 Mar 2003 17:51:35 +0100, Michel Rodriguez
<mirod@xmltwig.com> wrote:

>Tinky Winky wrote:
>
>> I usually use 'regular expressions' to extract information from XML
>> tags. I just discovered that I can use XPATH interface to do the same
>> thing using location path like "/plist/dict/key". Is there any
>> advantage using one method over another ?
>
>The main advantage is that using XPath means that you are using a real XML
>parser. Using regexp means that you are not parsing XML, but rather a
>limited subset of it, probably without realizing it.
>
>Do your regexp behave properly when facing nested identical tags, comments,
>processing instructions, '>' in attribute values, entities or CDATA
>sections? If yes then congratulations, you wrote an XML parser in Perl,
>please share it with us! Most likely you did not, and hence you face the
>prospect of you code breaking unexpectedly (and possibly silently) when
>faced with perfectly valid XML. This might never happen, depending on the
>context in which you are working, but the added security, and not having to
>figure out exactly what kind of data you can and cannot handle often make
>it worth using a full-fledged parser.
>
>XPath itself is quite a nice language for finding things in XML and although
>its features are quite different from regexps it is powerful enough to
>usually do the job nicely.
> 
>__
>Michel Rodriguez
>Perl &amp; XML
>http://xmltwig.com





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

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


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