[24997] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7247 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 14 14:12:05 2004

Date: Thu, 14 Oct 2004 11:10:17 -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           Thu, 14 Oct 2004     Volume: 10 Number: 7247

Today's topics:
    Re: HTML::Parser and <p> behaviour? <bigal187@removethis.rx.eastcoasttfc.com>
    Re: HTML::Parser and <p> behaviour? <bigal187@removethis.rx.eastcoasttfc.com>
    Re: HTML::Parser and <p> behaviour? <bigal187@removethis.rx.eastcoasttfc.com>
    Re: HTML::Parser and <p> behaviour? <geoff.cox@removethisplease.freeuk.com>
    Re: HTML::Parser and <p> behaviour? <usenet@morrow.me.uk>
    Re: HTML::Parser and <p> behaviour? <dha@panix.com>
        is there a better way to mkdir? (wana)
    Re: is there a better way to mkdir? <jurgenex@hotmail.com>
    Re: is there a better way to mkdir? <richard@zync.co.uk>
    Re: is there a better way to mkdir? (Anno Siegel)
    Re: is there a better way to mkdir? (Anno Siegel)
    Re: Lagrange Interpolating Polynomial <goofy_headed_punk@msn.com>
    Re: Lagrange Interpolating Polynomial <usenet@morrow.me.uk>
    Re: Perl to monitor server stats <mirak63@carolina.rr.com>
    Re: Perl to monitor server stats <mirak63@carolina.rr.com>
    Re: String and Array Programming in Perl (DeveloperGuy)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 14 Oct 2004 06:46:08 -0700
From: "187" <bigal187@removethis.rx.eastcoasttfc.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2t7e58F1tgftbU1@uni-berlin.de>

Tad McClellan wrote:
> 187 <bigal187@removethis.rx.eastcoasttfc.com> wrote:
>
>> True. I do admit I was quick to judge and I'm sorry for snapping at
>> you.
>
>
> The Posting Guidelines caution against that too.
>
> (but it doesn't work if you don't follow the suggestions it outlines.
> :-)

Agreed. :-)




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

Date: Thu, 14 Oct 2004 06:51:33 -0700
From: "187" <bigal187@removethis.rx.eastcoasttfc.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2t7efdF1pltejU1@uni-berlin.de>

A. Sinan Unur wrote:
> "187" <bigal187@removethis.rx.eastcoasttfc.com> wrote in
> news:2t6oieF1sinaeU1@uni-berlin.de:
>
>> A. Sinan Unur wrote:
>
>>> OTOH, I would think that someone who wishes to appear friendly might
>>> want to avoid the nickname '187'.
>>
>> Why is that? This is how I uniquely identify myself. If "187" means
>> something else that I am not awre of please let me know.
>
> I assumed 'eastcoastttfc.com' indicated that you were US based.

Good guess. Whil I just use that domain for my email, you still lucked
out :-)

> I might have jumped to a conclusion there. FYI, AFAIK, 187 is the
> police code for homicide. You might guess what that name might signal
> to at least some others.

well thanks for the info. Still, I've grown quite accustomed to this
name, and when it comes down to it, would not be just as much dangerous
to post if say you had the same name as a known serial killer (a FBI 10
most wanted perhaps) ? Just because one's name might also mean something
else in another context doesn't mean there is any acossiation.

That said, I really do appreciate being made aware of that, and might
consider using my actual name.




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

Date: Thu, 14 Oct 2004 06:54:33 -0700
From: "187" <bigal187@removethis.rx.eastcoasttfc.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2t7el1F1t31asU1@uni-berlin.de>

Tad McClellan wrote:
> Pinocchio (aka: Fred Canis, aka: 187, aka: krakle...)
>    <spambiat@yahoo.com> wrote:

* removes himself from that list *

I had a bad day, I don't normally type that bad, /please/ don't
associate me with usenet holigans like that *shudders* :-)




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

Date: Thu, 14 Oct 2004 14:09:08 GMT
From: Geoff Cox <geoff.cox@removethisplease.freeuk.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2v1tm0hflv0ug2v8e2mn1m9bh6kadpqodf@4ax.com>

On 14 Oct 2004 12:58:29 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:


>You might want to check all the examples in 
>http://search.cpan.org/src/GAAS/HTML-Parser-3.36/eg/

Thanks - will have a look now. By the way I have used your suggestions
which work fine for <h2> and <p> but am findng that if I use the same
approach for <ul> and <li> to parse <ul> <li> <li> </ul> I get the
text doubled up in the <li> line. Works fine if I leave out the <ul> !

Cheers

Geoff

>But don't just stare at them. Start with the simplest and try to work out 
>what they do.
>
>Also, my inclination would have been not to subclass HTML::Parser, but 
>use the version 3 API instead.
>
>Sinan.



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

Date: Wed, 13 Oct 2004 22:41:49 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <t1k042-e96.ln1@osiris.mauzo.dyndns.org>


Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
> Geoff Cox <geoff.cox@removethisplease.freeuk.com> wrote in
> news:a31rm05784u5g7stoojk2rogj49dfn35t1@4ax.com: 
> 
> > OK - does the code below help? In fact there are 2 questions here. 
> > 
> > 1.  if I have a paragraph of text between <p> and </p> I find that the
> > text is broken into two parts producing
> 
> Here is the relevant part from your code:
> 
<snip>
> 
> I suspect the handler is being called multiple times, each time with a 
> different part of the original text. 

 ...as indeed the HTML::Parser documentation says it will be. You can
prevent this with the ->unborken_text method [typo left because it
amused me :)]

Ben

-- 
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~                   Jorge Luis Borges, 'The Babylon Lottery'


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

Date: Thu, 14 Oct 2004 16:20:18 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <slrncmt9q2.ovg.dha@panix2.panix.com>

On 2004-10-14, A. Sinan Unur <usa1@llenroc.ude.invalid> wrote:
> "187" <bigal187@removethis.rx.eastcoasttfc.com> wrote in 
> news:2t6oieF1sinaeU1@uni-berlin.de:
>
>> A. Sinan Unur wrote:
>
>>> OTOH, I would think that someone who wishes to appear friendly might
>>> want to avoid the nickname '187'.
>> 
>> Why is that? This is how I uniquely identify myself. If "187" means
>> something else that I am not awre of please let me know. 
>
> I assumed 'eastcoastttfc.com' indicated that you were US based. I might 
> have jumped to a conclusion there. FYI, AFAIK, 187 is the police code for 
> homicide. You might guess what that name might signal to at least 
> some others.

Just as a data point:

Last I checked, I live in the US, and I don't actually know any police
codes, and I'm pretty sure most people I know don't either. So those
being offended by this might be a rather small group...

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
At the very least, if there is no law, rule or regulation against using
the public airwaves to knowingly present news that is false and
distorted, it's time the FCC or the Congress write one. - Steve Wilson


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

Date: 14 Oct 2004 08:56:27 -0700
From: ioneabu@yahoo.com (wana)
Subject: is there a better way to mkdir?
Message-Id: <bf0b47ca.0410140756.27b35107@posting.google.com>

I use mkdir in a program which recursively searches through a
directory searching for files of a particular type and recreating the
directory structure elsewhere and the files (which happen to be images
which get manipulated by ImageMagick along the way).

In recreating the directory structure, I sometimes come across the
error:

No such file or directory

which is due to trying to create multiple directory levels at once
which is not allowed.  While this probably is a problem in my program
logic (that is another whole issue, but I didn't want to ask too much
at once), I was wondering, why can't I create a whole path at once
like:

mkdir mouse/cat/dog

where none of the three directories exist yet.

This is what I came up with, but I thought there might be another way
or a better way to do it.

sub SuperMkdir
{
        my $path = shift;
        my $hold = $path;
        while (mkdir($path) == 0)
        {
                do
                {
                        $path =~ s/[^\/]+\/*$//;
                }
                while (mkdir($path) == 0);
                $path = $hold;
        }
}


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

Date: Thu, 14 Oct 2004 16:24:02 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: is there a better way to mkdir?
Message-Id: <CKxbd.77$u6.58@trnddc06>

wana wrote:
[...]
> at once), I was wondering, why can't I create a whole path at once
> like:
>
> mkdir mouse/cat/dog
>
> where none of the three directories exist yet.

Please see http://search.cpan.org/~nkuitse/mkpath-1.01/mkpath

jue 




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

Date: Thu, 14 Oct 2004 16:32:24 GMT
From: Richard Gration <richard@zync.co.uk>
Subject: Re: is there a better way to mkdir?
Message-Id: <pan.2004.10.14.16.27.10.193138@zync.co.uk>

On Thu, 14 Oct 2004 08:56:27 -0700, wana wrote:

> I was wondering, why can't I create a whole path at once
> like:
> 
> mkdir mouse/cat/dog
> 
> where none of the three directories exist yet.
> 
> This is what I came up with, but I thought there might be another way
> or a better way to do it.

Dunno about a perl solution but unix mkdir supports a -p flag for this, so

	system 'mkdir -p jerry/tom/spike'

will succeed regardless of whether jerry or tom already exist.

Rich


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

Date: 14 Oct 2004 16:41:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: is there a better way to mkdir?
Message-Id: <ckma8m$ba0$1@mamenchi.zrz.TU-Berlin.DE>

wana <ioneabu@yahoo.com> wrote in comp.lang.perl.misc:
> I use mkdir in a program which recursively searches through a
> directory searching for files of a particular type and recreating the
> directory structure elsewhere and the files (which happen to be images
> which get manipulated by ImageMagick along the way).
> 
> In recreating the directory structure, I sometimes come across the
> error:
> 
> No such file or directory
> 
> which is due to trying to create multiple directory levels at once
> which is not allowed.  While this probably is a problem in my program
> logic (that is another whole issue, but I didn't want to ask too much
> at once), I was wondering, why can't I create a whole path at once
> like:
> 
> mkdir mouse/cat/dog
> 
> where none of the three directories exist yet.
> 
> This is what I came up with, but I thought there might be another way
> or a better way to do it.
> 
> sub SuperMkdir
> {
>         my $path = shift;
>         my $hold = $path;
>         while (mkdir($path) == 0)
>         {
>                 do
>                 {
>                         $path =~ s/[^\/]+\/*$//;
>                 }
>                 while (mkdir($path) == 0);
                                      ^^
That is wrong.  mkdir returns true on success.

>                 $path = $hold;
>         }
> }

Well, I guess it might work, but it is more convoluted than it has to be.
I wouldn't use pattern substitution to extract the partial path names,
I'd split on the directory separator and build the paths from the parts.
That can be done in a standard for-loop.  

    my $dir;
    for ( split m{/}, $path ) {
        $dir .= '/' if length $dir;
        $dir .= $_;
        mkdir $dir or last;
    }

or even

    my @parts = split m{/}, $dir;
    mkdir join( '/', @$_) for map [ @parts[ 0 .. $_]], 0 .. $#parts;

Anno


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

Date: 14 Oct 2004 16:46:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: is there a better way to mkdir?
Message-Id: <ckmaho$ba0$2@mamenchi.zrz.TU-Berlin.DE>

Richard Gration  <richard@zync.co.uk> wrote in comp.lang.perl.misc:
> On Thu, 14 Oct 2004 08:56:27 -0700, wana wrote:
> 
> > I was wondering, why can't I create a whole path at once
> > like:
> > 
> > mkdir mouse/cat/dog
> > 
> > where none of the three directories exist yet.
> > 
> > This is what I came up with, but I thought there might be another way
> > or a better way to do it.
> 
> Dunno about a perl solution but unix mkdir supports a -p flag for this, so

There is no such thing as "unix mkdir".  Most modern brands of unix
appear to have the -p flag for mkdir, but I wouldn't bet my portability
on it.

> 	system 'mkdir -p jerry/tom/spike'
> 
> will succeed regardless of whether jerry or tom already exist.

On which systems?

Anno


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

Date: Thu, 14 Oct 2004 10:13:04 -0500
From: Brian Troutwine <goofy_headed_punk@msn.com>
Subject: Re: Lagrange Interpolating Polynomial
Message-Id: <pan.2004.10.14.15.13.04.421111@msn.com>

On Wed, 13 Oct 2004 21:13:53 +0100, Ben Morrow wrote:
> use Math::BigRat lib => 'GMP';
> 
> will use Math::BigInt::GMP to do your BigRat stuff (if it's installed).
> 
> Ben

Status report:

Well, It would appear that I have it since diagnostics doesn't spit me out
any warning, but any speed advantage it has is negligible, I've tested
multiple times, sometimes with yours coming out faster, sometimes with the
original.

Thanks anyway.


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

Date: Thu, 14 Oct 2004 18:16:17 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Lagrange Interpolating Polynomial
Message-Id: <1so242-8q4.ln1@osiris.mauzo.dyndns.org>


Quoth Brian Troutwine <goofy_headed_punk@msn.com>:
> On Wed, 13 Oct 2004 21:13:53 +0100, Ben Morrow wrote:
> > use Math::BigRat lib => 'GMP';
> > 
> > will use Math::BigInt::GMP to do your BigRat stuff (if it's installed).
> > 
> > Ben
> 
> Status report:
> 
> Well, It would appear that I have it since diagnostics doesn't spit me out
> any warning, but any speed advantage it has is negligible, I've tested
> multiple times, sometimes with yours coming out faster, sometimes with the
> original.

That's (maybe) because you don't have it :)

Try perl -MMath::BigInt::GMP -e1. If that succeeds, then you *do* have
it. Math::BigRat will automatically and silently fall back to the
pure-perl implementation if the one you ask for doesn't exist.

Ben

-- 
               We do not stop playing because we grow old; 
                  we grow old because we stop playing.
                            ben@morrow.me.uk


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

Date: Thu, 14 Oct 2004 09:55:32 -0400
From: "KWall" <mirak63@carolina.rr.com>
Subject: Re: Perl to monitor server stats
Message-Id: <r-qdnfloErLJGPPcRVn-ig@giganews.com>


"A. Sinan Unur" <usa1@llenroc.ude.invalid> wrote in message 
news:Xns9581CEDAA2917asu1cornelledu@132.236.56.8...
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
> news:Xns95819CC47D80Aasu1cornelledu@132.236.56.8:
>
>> I have not used them, but have you looked at
>>
>> Win32::NetAdmin
>>
>> and
>>
>> Win32::NetResource
>
> On second thought, those modules don't seem to do what you want. Sorry.
>
> Sinan.
>

I 've used them extensivly in the past and they don't provide them. Perflib 
may but it breaks the RAM into each segment. I'm really just looking for the 
overall physical RAM in use. I found a module that takes care of the CPU 
reporting.

KLW 




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

Date: Thu, 14 Oct 2004 09:58:27 -0400
From: "KWall" <mirak63@carolina.rr.com>
Subject: Re: Perl to monitor server stats
Message-Id: <_P2dneMNL66eG_PcRVn-gQ@giganews.com>


<burlo_stumproot@yahoo.se> wrote in message 
news:usm8ha2h7.fsf@notvalid.se...
> "KWall" <mirak63@carolina.rr.com> writes:
>
>> Hello. Has anyone ever used PERL to monitor Windows server statistics? Is
>> there a book or a place to start?
>>
>> Thanks,
>> Kairm
>> karim.wall@acs-inc.com
>
> Have a look at this book by Dave Roth.
>
> "Win32 Perl Programming: The Standard Extensions, Second Edition"
>
> It includes chapters like:
>        Network Administration
>        Administration of Machines
>
> and much more.
>
> The authors web site http://www.roth.net/
>

I've been through it. I can't find anything. However I guess it is version 
one. I've been using it for about 6 years.
KLW
KLW 




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

Date: 14 Oct 2004 10:28:26 -0700
From: Phillip.Small@gmail.com (DeveloperGuy)
Subject: Re: String and Array Programming in Perl
Message-Id: <64f06fa2.0410140928.22605f24@posting.google.com>

krakle@visto.com (krakle) wrote in message news:<237aaff8.0410131502.36df7008@posting.google.com>...
> Phillip.Small@gmail.com (DeveloperGuy) wrote in message news:<64f06fa2.0410121120.4b777d7c@posting.google.com>...
> > I am very very new to Perl and am trying automate a process in my AIX
> > Unix box.  I issed the command ps -aef and sent it to a file.  How do
> > I get how many different users running programs, the total time for
> > each user in hours:minutes format, and who is running the longest
> > process and the program name?  I am not familiar with using the loops.
> >  I know that I can probably use the date command to specify the date. 
> > This is where I am stuck thus far. Please help anyone...
> > 
> > #! /usr/bin/perl
> > 
> > use strict;
> > use warnings;
> > 
> > @users;
> > @tmpfile = OPEN(DataFileHandle, /home/smallp/data.txt);
> > 
> > $tmpfile[0];
> > $users[0];
> > 
> >    for ($count= 0; $count <= $#users; $count++;) {
> >      If $tmpline[0] eq $users[i] 
> >       if TRUE then exit
> >     push(@users, $users[0]);
> > }
> 


Okay, I finally got the script to read the file.  

#! /usr/bin/perl
#This program reads a file based on the command ps -aef called data.txt
  #and the following questions have to be answered
  #how many users are running programs?
  #what is the total time used by each user in hours: minutes?
  #who is running the longest process, list user, time and name of program
#use strict;
#use warnings;

open(DataFileHandle, "/home/smallp/data.txt");

@tmpfile = <DataFileHandle>;
@users;
$users[0];

foreach $i (@tmpfile)
{
print "$i\n"; 
}
close DataFileHandle;


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7247
***************************************


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