[19592] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1787 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 21 11:05:51 2001

Date: Fri, 21 Sep 2001 08:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001084710-v10-i1787@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 21 Sep 2001     Volume: 10 Number: 1787

Today's topics:
    Re: a question about comments in perl <mark.riehl@agilecommunications.com>
    Re: ANNOUNCE: grepmail 4.51 released (Anno Siegel)
        converting 20010921 into 21-09-2001 (Martin)
        dead image links <chuck.kahn@sympatico.ca>
    Re: Deleting variables <bkennedy99@Home.com>
    Re: Hash problem... (Eric Bohlman)
    Re: How to get the path of current directory in perl news@roaima.demon.co.uk
    Re: How to get the path of current directory in perl <comdog@panix.com>
    Re: i feel i miss some important knowledge !! <Laocoon@eudoramail.com>
        Newbie trying to use Twig... <patrick_breithaupt-at-mentor.com>
        perl code compatibility <Peterca@btopenworld.com>
    Re: Perl English only?????? (Rafael Garcia-Suarez)
    Re: perl, lvalues, rvalues, and operators nobull@mail.com
    Re: perl, lvalues, rvalues, and operators <aflow@mail.com>
    Re: perl, lvalues, rvalues, and operators (Eric Bohlman)
    Re: Pre spawning in perl (Gary Cub)
    Re: pretty printing a web page <benoitd@americasm01.nt.com>
    Re: Problem with Object Oriented Perl (Anno Siegel)
    Re: Reading cookies from a different path (Jonadab the Unsightly One)
    Re: Schwartzian Transform problem <matthew.garrish@sympatico.ca>
    Re: select() timeout problem <bkennedy99@Home.com>
        Storable, and Tk::fileevent, help Please (Stan Brown)
    Re: strip links out of html (Eric Bohlman)
    Re: strip links out of html <comdog@panix.com>
    Re: using a variable to call a function (Andy)
        win32 stat in directory with 4682 files <peter_korman@lotus.com>
    Re: win32 stat in directory with 4682 files (Eric Bohlman)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 21 Sep 2001 13:16:40 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Re: a question about comments in perl
Message-Id: <Y4Hq7.904$ee4.69156@typhoon1.gnilink.net>

One other suggestion, use XEmacs in Perl mode.  It allows you to comment
(M-x comment-region) and uncomment (M-x uncomment-region) highlighted
portions of your Perl file.

Mark

"Rene Scheibe" <Rene.Scheibe@gmx.net> wrote in message
news:9oeq43$d387v$1@ID-65612.news.dfncis.de...
> Can someone tell me how to not just comment
> out one line with # but a whole section?
>
> Thanx
>
>




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

Date: 21 Sep 2001 13:54:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: ANNOUNCE: grepmail 4.51 released
Message-Id: <9ofgqk$j9h$2@mamenchi.zrz.TU-Berlin.DE>

According to Edward Avis  <epa98@doc.ic.ac.uk>:
> David Coppit <newspost@coppit.org> writes:
> 
> >>There's no real point, IMHO, to a collection of programs with no
> >>common feature other than that they are written in Perl.  Except as
> >>a source of examples and inspiration.
> 
> >I think "examples and inspiration" is a good enough reason.
> 
> >Unfortunately, modules have a lot of extra cruft that can get in the
> >way of a beginner's learning experience.
> 
> True; but so would any large application.  The cruft associated with a
> module is _usually_ not any worse than the infrastructure of a big
> app, and if anything it's a bit clearer what is doing what.  Still,
> any example code is useful, especially if you are looking for an
> example of one specific technique.
> 
> I don't think that CPAN should be the official home of Perl
> applications in the same way it is for modules; but a listing of
> 'useful apps which just happen to be written in Perl' would be good
> publicity.
> 
> Ideally the source code for all these programs would be searchable, so
> if you're looking for examples of using HTTP::Response, you'd just
> type the module name into a search box and browse through code that
> uses it.

Quite.  A repository of (mostly simple) applications that use mainly
one specific module, associated with that module, would be a good idea.
The problem I see is, who would make and/or approve of this association.

Anno


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

Date: 21 Sep 2001 07:50:12 -0700
From: martin.van.den.berg@rivm.nl (Martin)
Subject: converting 20010921 into 21-09-2001
Message-Id: <2a468b35.0109210650.5797a870@posting.google.com>

There must be an easy way to convert a date string like 20010921 into
a readable string like 21-09-2001 (european format).
Please help me out!

Thanks


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

Date: Fri, 21 Sep 2001 10:26:52 -0400
From: "Chuck Kahn" <chuck.kahn@sympatico.ca>
Subject: dead image links
Message-Id: <M6Iq7.38841$Aa7.2359934@news20.bellglobal.com>

I'm trying to use LWP::UserAgent to detect dead image links (jpg files
that are no longer at a specific URL):

    $URL[0] = "http://dailynews.yahoo.com/headlines/";
    $URL[1] = "http://dailynews.yahoo.com/headlinezzz/";
    $URL[2] =
"http://images.amazon.com/images/P/0130799807.01.TZZZZZZZ.jpg";
    $URL[3] =
"http://images.amazon.com/images/P/0130895547.01.TZZZZZZZ.jpg";

    foreach $item (@URL)
    {
        $ua = LWP::UserAgent->new;
        $request = HTTP::Request->new('GET', $item);
        $response = $ua->request($request)->status_line();

        print "[$response] $item\n";
    }

In the example above, $URL[1] and $URL[3] are invalid, but $URL[3]
does not come up as invalid:

[200 OK] http://dailynews.yahoo.com/headlines/
[404 Not Found] http://dailynews.yahoo.com/headlinezzz/
[200 OK] http://images.amazon.com/images/P/0130799807.01.TZZZZZZZ.jpg
[200 OK] http://images.amazon.com/images/P/0130895547.01.TZZZZZZZ.jpg

Is there a better way to find invalid image links?





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

Date: Fri, 21 Sep 2001 14:11:16 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: Deleting variables
Message-Id: <8UHq7.36613$5A3.11921209@news1.rdc2.pa.home.com>


"shaz" <ssa1701@yahoo.co.uk> wrote in message
news:23e71812.0109201128.bd7c2af@posting.google.com...

> Because the variable $words contains two words, how would I delete it
> from @store if ONE or BOTH of the words are in @list?

See:

perldoc -q contains

> while (/(\w+)($look)/g)
> {
>   $store{$1}++;
>   delete @store{@list};
> }

You are probably better off with a hash of forbidden words, not an array.
You also probably want to take the delete() out of your loops - either fix
%store at the end, or don't even add the word if if fails the forbidden word
check.

--Ben Kennedy




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

Date: 21 Sep 2001 13:44:36 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Hash problem...
Message-Id: <9ofg84$imq$1@bob.news.rcn.net>

GuaRDiaN <guardian@chello.be> wrote:
> Ok now I have this to store the data

> if ( $event1 = "killed" ) {
>      $$player_name{kills}{count}++; # Player kills
>      $$player_name{kills}{victim}{$player_name2}++;
>      $$player_name{kills}{weapon}{$noun2}++;
>      $$player_name2{death}{count}++; # Player death
>      $$player_name2{death}{killer}{$player_name}++;
>      $$player_name2{death}{weapon}{$noun2}++;
> }

> And this to retrieve data...

> foreach $user ( keys %player ) {
>  print "$user\n";
>  print "### Kills: $$user{kills}{count}\n";
>  print "### Death: $$user{death}{count}\n";
>  print "\n";
> }

> But when I try do get the other infos... I got a syntax error...
> Perl don't accept    keys %player{kills}

That's because keys requires a hash as its argument and $player{kills} is 
a hash *reference*.  You need to dereference it first:

keys %{$player{kills}}

If you haven't already done so, read perlref, perllol, and perldsc.



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

Date: 21 Sep 2001 14:46:25 GMT
From: news@roaima.demon.co.uk
Subject: Re: How to get the path of current directory in perl
Message-Id: <3bab44b1@news.netserv.net>

nobull@mail.com wrote:
> I don't understand why you think the OP needs their code to run under
> Perl4.  (Under Perl5 getcwd.pl is superceeded by Cwd.pm). 

It's in my perl5 distribution, therefore it's quite likely that it's in
theirs too. It happened that I found getcwd first, so suggested that. You
are of course welcome to suggest Cwd.pm (as you've done). Someone else
may prefer $cwd = `/bin/pwd` (which as we both know isn't portable -
but might be satisfactory for the 1OP.

Chris


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

Date: Fri, 21 Sep 2001 09:51:21 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: How to get the path of current directory in perl
Message-Id: <comdog-8BA197.09512121092001@news.panix.com>

In article <b860cf59.0109210154.29bc5244@posting.google.com>, 
merigrace@rediffmail.com (Merina) wrote:

>  I want to get the path of the current directory in a variable using perl?
>  Any idea regarding this?


    use Cwd;
    $dir = cwd;

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: Fri, 21 Sep 2001 15:30:41 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: i feel i miss some important knowledge !!
Message-Id: <Xns91239F2325487Laocooneudoramailcom@62.153.159.134>

Programming Perl..definitely..


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

Date: Fri, 21 Sep 2001 08:59:51 -0500
From: "Patrick" <patrick_breithaupt-at-mentor.com>
Subject: Newbie trying to use Twig...
Message-Id: <3bab47d9$1@solnews.wv.mentorg.com>

My goal is to traverse a variable number of products under group.

From the documentation, within_element($gs) will return the number.
The documentation also says you must use
generate_ns_name(NAME,URI) to define $gs.
I can't find an example of calling generate_ns_name or within_element.

My xml file looks like this:
========company.xml=======
<comany>
<group>
    <name>dev group 1</name>
    <product>product 1</product>
    <product>product 2</product>
    <product>product 3</product>
    <product>product 4</product>
</group>
<group>
    <name>dev group 2</name>
    <product>product 1</product>
    <product>product 2</product>
</group>
</company>

========company.pl========
#!/bin/perl -w

use strict;
use XML::Twig;

my $field= 'group';

my $twig= new XML::Twig;

$twig->parsefile( "company.xml"); # build the twig

my $root= $twig->root;            # get the root of the twig
my @group = $root->children;      # get the list

foreach my $my_group (@group)     # the sorted list
{ 
   print "\nGroup Name: ",$my_group->first_child("name")->text;
   print "\nGroup Name: ",$my_group->first_child("product")->text;
# I would like to find out how many "product" entries exist, and then
# step through them. within_element would return the number of "product" entries.
}
================

Thanks,
Patrick
patrick_breithaupt( at )mentorg.com











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

Date: Fri, 21 Sep 2001 15:42:24 +0100
From: "Peter Cameron" <Peterca@btopenworld.com>
Subject: perl code compatibility
Message-Id: <9ofjjc$8rj$1@uranium.btinternet.com>

We've been developing some Perl code using Perl 5.005. Would there be any
problems running the code with Perl 5.004 and Perl 5.6 and later? We're
wanting to establish the base version of Perl that our clients would need.
On Solaris 2.6, for example, Perl 5.004 is all we've found. My feeling is to
be on the safe side and say 5.005 upwards.

Cheers,
Peter





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

Date: 21 Sep 2001 14:28:20 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Perl English only??????
Message-Id: <slrn9qmjl1.k0d.rgarciasuarez@rafael.kazibao.net>

Damian Conway wrote in comp.lang.perl.misc:
} 
}         - That slot-based parsing techniques deserve more attention
}           and development.

Probably a field of application would be UI design : from command-line
switches processing, to handling of clicks on modal GUI widgets.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
perl -sleprint -- -_='Just another Perl hacker,'


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

Date: 21 Sep 2001 13:49:41 +0100
From: nobull@mail.com
Subject: Re: perl, lvalues, rvalues, and operators
Message-Id: <u9bsk4btei.fsf@wcl-l.bham.ac.uk>

Michael Slass <mikesl@wrq.com> writes:

> $mystring =~ s/regex/subst/
> 
> This assumes that mystring is an lvalue, because it does the
> substitution in place.  Is there any kind of regexp substituion
> operator that can work on rvalues - that is, use of this operator
> doesn't change the value on the left, but instead the entire
> expression returns a value (the string as processed by the
> substitution operator)?
> 
> so if the mystery operator is ##, I could do:
> 
> $mystring = ($some_constant_string ## s/regex/subst/)

There's no builtin mechanism, see thread "Idiom: the expression of a
copied & substituted string" where John Lin asked this exact question
April this year.

In particular see my answer <u97l08ly0o.fsf@wcl-l.bham.ac.uk> [1] where I
show how to construct a function (that I call 'apply') such that you
can say:
		
 $mystring = apply { s/regex/subst/ } $some_constant_string;

> I'm [...] am having a bit of trouble wrapping my mind around a
> particular perl-ish concept.

> Since this is a stylistic as well as syntactic question, suggestions
> for better uses of either are welcome.

I strongly recommend going to Google and reading John's contributions
to this newsgroup as he has clearly and consisely asked many of the
questions you will likely be asking yourself in the next few weeks.

[1] http://groups.google.com/groups?selm=u97l08ly0o.fsf%40wcl-l.bham.ac.uk

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 21 Sep 2001 17:35:17 +0400
From: "aflow" <aflow@mail.com>
Subject: Re: perl, lvalues, rvalues, and operators
Message-Id: <9offla$abi$1@news.sovam.com>


How about passing a regular expression to that sub?

print re(foo($arg, $notherarg), qx/regexp/, qq/subst/);

sub re {
  my ($arg, $re, $subst) = @_;
  $arg =~ s/$re/$subst/;
  return $arg;
}


Alex Protasov
A-Flow development, customer support
A-Flow - Software Applications Visual Designer
http://aflow-designer.com

----- Original Message -----
From: "Simon Oliver" <simon.oliver@umist.ac.uk>
Newsgroups: comp.lang.perl.misc
Sent: Friday, September 21, 2001 5:00 PM
Subject: Re: perl, lvalues, rvalues, and operators


> How about susing a second sub?
>
> print re(foo($arg, $notherarg));
>
> sub re {
>   my $arg = shift;
>   $arg =~ s/regexp/subst/;
>   return $arg;
> }
>
> --
>   Simon
>
>





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

Date: 21 Sep 2001 14:17:05 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: perl, lvalues, rvalues, and operators
Message-Id: <9ofi51$olc$2@bob.news.rcn.net>

aflow <aflow@mail.com> wrote:

> How about passing a regular expression to that sub?

> print re(foo($arg, $notherarg), qx/regexp/, qq/subst/);
                                  ^^
That should be qr/regexp/; qx would try to execute regexp as an external 
command as if it were enclosed in backticks.


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

Date: 21 Sep 2001 07:28:58 -0700
From: gary@irl.com (Gary Cub)
Subject: Re: Pre spawning in perl
Message-Id: <d3786cd7.0109210628.2ce79665@posting.google.com>

mjd@plover.com (Mark Jason Dominus) wrote in message news:<3ba939ee.6532$5c@news.op.net>...
> 
> You don't want to 'pass' incoming connections; it's better if the
> incomming connections are attached to the child automatically.
> 
> I think you will want to follow an outline something like this:
> 
> 
>         use POSIX ":sys_wait_h";
>         socket(S, ...);
>         bind(S, ...);
>         listen(S, ...);
>         my $children = 0;
>         my $MAX_CHILDREN = 10; # This many children active at once
>         my $MAX_SERVICE = 100; # children exit after serving this many clients
> 
>         while (1) {
>           my $dead_child;
>         sub handle_clients {
>           my $clients_served = 0;
>           accept(S, NS);  # wait until a conection comes in
>           # Now deal with the client; it is connected via NS
>           close NS;
>           exit if ++$clients_served == $MAX_SERVICE;  
>         }
> 
> 
> I hope I haven't made any serious errors, and that this is helpful.

Thanks Mark,

  The code you gave me nearly crahed my machine put after a little cut
and paste and a retry it works a treat.  The spawning should be the
first thing in the loop (or at least thats what worked for me).

Thanks for your help
Gary


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

Date: Fri, 21 Sep 2001 09:24:06 -0400
From: "Desrosiers, Benoit [CAR:9F53:EXCH]" <benoitd@americasm01.nt.com>
Subject: Re: pretty printing a web page
Message-Id: <3BAB3F76.CF513632@americasm01.nt.com>

This is a multi-part message in MIME format.
--------------6267130A8F8C3E144CD8989C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Thanks,

but it's not enought. The main content on the page is a table. And some of
its cells are multilines so I can't just print it sequentialy.

If I use the print button on Netscape or on IE, I only get the left part of
the page.
What I would like is something that would reduce the size of what is being
printed and fit it on one page.

thanks,
Benoit
W i l l wrote:

> what kind of content do you want to print ... text and images, just
> text, or is it a page of images ???  If you are only wanting to print
> the text then just run a regex across it , something to strip out the
> tags that just leaves the content behid,  i.e.
>
>  s/(\<(.*?)\>)//sg;
>
> This is not a perfect regex, I'd look at some of the Perl Modules
> specifically intended to parse HTML if this is something you want to
> accurately do.
>
> good luck
>
> Will
>
> On Wed, 19 Sep 2001 16:54:30 -0400, "Desrosiers, Benoit
> [CAR:9F53:EXCH]" <benoitd@americasm01.nt.com> wrote:
>
> >
> >Hi,
> >
> >I would like to know if there are tools to pretty print a web page on a
> >printer.
> >I have a perl program which generate a web page but when I want to print
> >that web page, I only get the left part of it.
> >I have tried everything I can think of to print it: sent it in
> >postscript, reducing the font, changing the paper size, changing the
> >browser size. But everytime, I only get part of the page.
> >
> >any help?
> >
> >thanks,
> >Benoit

--------------6267130A8F8C3E144CD8989C
Content-Type: text/x-vcard; charset=us-ascii;
 name="benoitd.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Desrosiers, Benoit [CAR:9F53:EXCH]
Content-Disposition: attachment;
 filename="benoitd.vcf"

begin:vcard 
n:Desrosiers;Benoit
x-mozilla-html:TRUE
org:DaVinci;9F53
adr:;;;;;;
version:2.1
email;internet:benoitd@americasm01.nt.com
x-mozilla-cpt:;26088
fn:Benoit Desrosiers x57252
end:vcard

--------------6267130A8F8C3E144CD8989C--



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

Date: 21 Sep 2001 13:34:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem with Object Oriented Perl
Message-Id: <9offkv$j9h$1@mamenchi.zrz.TU-Berlin.DE>

According to Tim Hammerquist <timmy@cpan.org>:
> Me parece que Randal L. Schwartz <merlyn@stonehenge.com> dijo:
> > >>>>> "Thomas" == Thomas Bätzler <Thomas@Baetzler.de> writes:

> > Thomas>   my $class = ref( $proto ) || $proto;

Randal replied in part:

> > replace this with
> > 
> >         my $class = shift;

Fully agreed.
 
> Somewhat in line with your statement, I've had the following new() method
> in my ASP::NextLink module:
> 
> sub new {
>     my $class = shift;
>     die "Cannot call class method on an object" if ref $class;
>     ...    
> }
> 
> This sort of verification is done inside all subs that are restricted
> to *only* instance methods or to *only* class methods. Would you
> consider this overkill?  Or would you recommend just doc'ing them as
> class|instance calls and let the user misuse at his/her own peril?

You didn't ask me, but I'll reply anyhow :)

I think it's good programming practice in a class where users call
the new() method themselves.  If they don't, there's no need for such
a test, because the wrong kind of call can only happen in a buggy
version, not in one that is delivered, right?  Of course, then the
new() method should be called _new().

Anno


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

Date: Fri, 21 Sep 2001 14:30:24 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Reading cookies from a different path
Message-Id: <3bab4ed7.8194164@news.bright.net>

mjd@red.seas.upenn.edu (Mark-Jason Dominus) wrote:

> >Maybe it's a system-dependent thing; I'm using the ActiveState
> >Windoze build here.  Your headers don't tell me much about
> >your system, so I'm guessing it's some kind of Unix?
> 
> This program is never going to work on windows; you can tell because
> of the presence of pipe() and fork() in the source code.

Pipes and forks should work on Windows (unlike in plain DOS).

> Also the string 'xinU' may be suggestive.  :)

Ah.  

-- 
$_=$j="(.";s/$/.)/;$o=$_;s/..//;$k=reverse;($a,$b,$c,)="U r bad"=~
"$j$k$j$k$j+)";($f,$d)="lyons"=~"$o.$o";$_=$d;s/s/o/;$;=reverse($c
 ."a$_");s/o/e/ ;$e="O$_";$g="h";s/$/t/;$ := ".$_";($i) =/(.)$/;$,=
"ig$g$i";$\="he $a$d$,$f $e <j$;\@b$b$,$:>$/";print"$/-- $/J$; $i";


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

Date: Fri, 21 Sep 2001 09:33:04 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Schwartzian Transform problem
Message-Id: <kgHq7.32385$Zb4.3194510@news20.bellglobal.com>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9ofdkl$hgm$1@mamenchi.zrz.TU-Berlin.DE...
> Nobody has tried to color you stupid, neither Randal nor Michael.  You
> posted in error, as it happens on Usenet, and got corrected.  Twice, as
> it also happens on Usenet.  There was no intention to rub it in, if that's
> what you are griping about.
>

Neither needed to; I did a good enough job myself. And yes, my gripe was
with seeing (virtually) the exact same post a second time; it's one of my
pet peeves. If you're going to respond to someone, take the time to read the
thread through. I should've posted my reply to Randal rather than send it
privately, but basically I responded to the message only registering that
the first condition was being evaluated and noticing an || in his code. I
should've stopped and read the rest of the post, or even stopped to take a
look at the full piece of code. Had I, however, then we wouldn't be having
this discussion. My annoyance has been vented, as I indicated; so now I'll
return to writing happier posts!

May my advice be better in the future...

Matt




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

Date: Fri, 21 Sep 2001 14:02:52 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: select() timeout problem
Message-Id: <gMHq7.36611$5A3.11915905@news1.rdc2.pa.home.com>


"Philippe PERRIN" <philippe.perrin@sxb.bsf.alcatel.fr> wrote in message
news:3BA88CDD.94299297@sxb.bsf.alcatel.fr...

>     my($rout, $wout, $eout);
>     my ($nfound, $left) = select($rout = $rin, $wout = $win, $eout =
> $ein, 5);

On a side note, you should try the IO::Select module, which takes nearly all
of the pain of this away - makes it very easy to quicly implement
multiplexing sockets of any type

--Ben Kennedy




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

Date: 21 Sep 2001 10:49:41 -0400
From: stanb@panix.com (Stan Brown)
Subject: Storable, and Tk::fileevent, help Please
Message-Id: <9ofk25$5pi$1@panix2.panix.com>

How can I make Storable's fd_retrieve(0 work with Tk::perls fileevent?

It appears that filevent wants to make it's callback whne any data is
availble on the pipe, and fd_retrieve then blocks untill it has recieved a
complete data set. This defeats teh purpose of using fileevent()!

Has anyone made this work?


-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin


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

Date: 21 Sep 2001 14:05:47 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: strip links out of html
Message-Id: <9ofhfr$olc$1@bob.news.rcn.net>

Dav Lam <crud@hongkong.com> wrote:
> i got the following script, i can't discover any thing wrong but it just
> doesn't work out..

Sigh.  The posting guidelines for this group say that people shouldn't say 
something "doesn't work" because that phrase conveys absolutely no 
information.  If you want meaningful help, you need to tell us:

1) What the script is supposed to do
2) What it's actually doing
3) What input you ran it on

> can anyone point out what's wrong in the script?

> thanks in advance

No indication that you've enabled warnings.
No "use strict;"

> require HTML::TokeParser;
> use LWP::Simple;
> $base = '';
> $newspage = '';
> @links;
> $next = 1;

> while($next){
>  $cnt = get($newspage);
>  $next = strip($cnt);
> }

The first time around, you're calling get() with an empty string as the 
argument.  What are you expecting it to fetch.

That loop could be written as

1 while strip(get($newspage));

but that's just a matter of style.

> print join "\n", @links;

> sub strip{
>  my ($tkpr) = HTML::TokeParser->new(\$_);
>  my $href;

>  while($token = $tkpr->get_tag('a')){
>   $href = $token->[1]{href};
>   push @links, $href if $href =~ /^news.fpl/;
>   if ($tkpr->get_text =~ /^next/i){
>    $newspage = $base.$href;
>    return 1;
>   }
>  }
> }

I don't see anything obviously wrong here, but without knowing what you're 
trying to do...



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

Date: Fri, 21 Sep 2001 09:54:33 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: strip links out of html
Message-Id: <comdog-EED708.09543321092001@news.panix.com>

In article <fc25f4f2.0109210114.7ba7b1d8@posting.google.com>, 
crud@hongkong.com (Dav Lam) wrote:

> i got the following script, i can't discover any thing wrong but it just
> doesn't work out..
> 
> can anyone point out what's wrong in the script?
> 
> thanks in advance
> 
> require HTML::TokeParser;
> use LWP::Simple;

if all you would like to do is extract links then HTML::LinkExtor
or HTML::SimpleLinkExtor will save you a lot of hassle. :)

http://search.cpan.org/search?dist=HTML-Parser
http://search.cpan.org/search?dist=HTML-SimpleLinkExtor

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: 21 Sep 2001 08:03:02 -0700
From: ccsam@bath.ac.uk (Andy)
Subject: Re: using a variable to call a function
Message-Id: <e6f95c88.0109210703.125ec9eb@posting.google.com>

Thanks to both of you...

Thomas Bätzler <Thomas@Baetzler.de> wrote in message 
> 
> You shouldn't do that. But if you must, try this:
> 

I don't *have* to, what are the security implications if I do?
Security and robustness is a priority.

I have a .pm of different arrays, given the same names as some users.
My intention was to:

&foo ($user);

With $user having a dual purpose, i.e. as the basis of `ps -fu$user`
and &$user();  Therefore, is it more secure to use.. no that wont
work. Should I have a separate array of valid array names to check
before calling them?


btw does 'no strict "refs";' expire after the closing }?

>   { 
>     no strict "refs";
>     &{$func};
>   }

Security -> to another point. Although all data  being passed to my
pm's *should* be secure, if I run with '-T' it complains when I use
that data as a parameter for a shell command (a perfect example being
`ps -fu$user`).

andrewm$ cat > us
#!/usr/bin/perl -Tw
 
use strict;
 
{
    my $user = shift or die;
    print `ps -fu$user`;
}
^D
andrewm$ chmod +x us
andrewm$ ./us andrewm
Insecure dependency in `` while running with -T switch at ./us line 7.

Regards

Andy


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

Date: Fri, 21 Sep 2001 10:23:15 -0400
From: Peter Korman <peter_korman@lotus.com>
Subject: win32 stat in directory with 4682 files
Message-Id: <3BAB4D53.A820FB65@lotus.com>


--------------1198A42B01A2E1A05A92E55E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

How would one speed this up?
---------------------------------------------------------
use cwd;
@when=localtime();
print $when[2], ":" , $when[1],  ":" , $when[0];
chdir "G:/ENGLISH/WIN2000/ADV_SERV/I386";
opendir D, ".";
@direntries=readdir(D);
foreach $i (@direntries)
{
  @s=stat($i);
  $cnt++;
  if (0 == $cnt %200)
  {
     print ".";
     $blk++;
     if (0 == $blk % 80)
     {
       print "\n";
     }
  }
}
@when=localtime();
print $when[2], ":" , $when[1],  ":" , $when[0];
---------------------------------------------------------

Running NT 4.0 on a 350MHZ pentium II system under perl:

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
Binary build 629 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 12:27:04 Aug 20 2001

This produces the output:

10:15:56.......................10:17:17


Thanks.


--------------1198A42B01A2E1A05A92E55E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
How would one speed this up?
<br>---------------------------------------------------------
<br><font face="Courier New,Courier"><font size=-2>use cwd;</font></font>
<br><font face="Courier New,Courier"><font size=-2>@when=localtime();</font></font>
<br><font face="Courier New,Courier"><font size=-2>print $when[2], ":"
, $when[1],&nbsp; ":" , $when[0];</font></font>
<br><font face="Courier New,Courier"><font size=-2>chdir "G:/ENGLISH/WIN2000/ADV_SERV/I386";</font></font>
<br><font face="Courier New,Courier"><font size=-2>opendir D, ".";</font></font>
<br><font face="Courier New,Courier"><font size=-2>@direntries=readdir(D);</font></font>
<br><font face="Courier New,Courier"><font size=-2>foreach $i (@direntries)</font></font>
<br><font face="Courier New,Courier"><font size=-2>{</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp; @s=stat($i);</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp; $cnt++;</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp; if (0 == $cnt
%200)</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp; {</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;
print ".";</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;
$blk++;</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;
if (0 == $blk % 80)</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;
{</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;
}</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp; }</font></font>
<br><font face="Courier New,Courier"><font size=-2>}</font></font>
<br><font face="Courier New,Courier"><font size=-2>@when=localtime();</font></font>
<br><font face="Courier New,Courier"><font size=-2>print $when[2], ":"
, $when[1],&nbsp; ":" , $when[0];</font></font>
<br>---------------------------------------------------------<font face="Courier New,Courier"><font size=-2></font></font>
<p>Running NT 4.0 on a 350MHZ pentium II system under perl:<font face="Courier New,Courier"><font size=-2></font></font>
<p><tt>This is perl, v5.6.1 built for MSWin32-x86-multi-thread</tt>
<br><tt>Binary build 629 provided by ActiveState Tool Corp. <A HREF="http://www.ActiveState.com">http://www.ActiveState.com</A></tt>
<br><tt>Built 12:27:04 Aug 20 2001</tt><font face="Courier New,Courier"><font size=-2></font></font>
<p>This produces the output:<font face="Courier New,Courier"><font size=-2></font></font>
<p><font face="Courier New,Courier"><font size=-2>10:15:56.......................10:17:17</font></font>
<br><font face="Courier New,Courier"><font size=-2></font></font>&nbsp;<font face="Courier New,Courier"><font size=-2></font></font>
<p>Thanks.
<br>&nbsp;</html>

--------------1198A42B01A2E1A05A92E55E--



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

Date: 21 Sep 2001 14:49:15 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: win32 stat in directory with 4682 files
Message-Id: <9ofk1b$4bu$1@bob.news.rcn.net>

Peter Korman <peter_korman@lotus.com> wrote:
> How would one speed this up?
> ---------------------------------------------------------
> use cwd;
> @when=localtime();
> print $when[2], ":" , $when[1],  ":" , $when[0];
> chdir "G:/ENGLISH/WIN2000/ADV_SERV/I386";
> opendir D, ".";
> @direntries=readdir(D);
> foreach $i (@direntries)
> {
>   @s=stat($i);
>   $cnt++;
>   if (0 == $cnt %200)
>   {
>      print ".";
>      $blk++;
>      if (0 == $blk % 80)
>      {
>        print "\n";
>      }
>   }
> }
> @when=localtime();
> print $when[2], ":" , $when[1],  ":" , $when[0];
> ---------------------------------------------------------

> Running NT 4.0 on a 350MHZ pentium II system under perl:

> This is perl, v5.6.1 built for MSWin32-x86-multi-thread
> Binary build 629 provided by ActiveState Tool Corp.
> http://www.ActiveState.com
> Built 12:27:04 Aug 20 2001

> This produces the output:

> 10:15:56.......................10:17:17

I don't see anything that's likely to be particularly slow in your code.  
You might try putting a time printout right after the readdir() and see 
how much of the time that takes.  It looks like most of your time is being 
spent in readdir() and stat(), and there's not much you can do about them 
(those Perl functions just translate directly into calls to the OS).



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

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


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