[10256] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3850 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 29 13:45:26 1998

Date: Tue, 29 Sep 98 10:02:12 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 29 Sep 1998     Volume: 8 Number: 3850

Today's topics:
    Re: help needed (Larry Rosler)
        How do I capture a Broken Pipe Error? (Daniel Pray)
        mod_perl file closing problem (Ryan McGuigan)
    Re: mod_perl file closing problem <jdf@pobox.com>
        OO: How to make "dual" natured package (Jari Aalto+mail.perl)
        perl and module problem <jduche@creighton.edu>
    Re: perl and module problem <jdf@pobox.com>
    Re: Perl and ODBC? <perlguy@inlink.com>
    Re: Perl Script Running as Root <aperrin@mcmahon.qal.berkeley.edu>
    Re: Perl Script Running as Root <webmaster@fccjmail.fccj.cc.fl.us>
    Re: Perl Script Running as Root droby@copyright.com
    Re: Perl setup (behinds the scenes) <jdf@pobox.com>
    Re: Poll: How Did You Learn Perl? <merlyn@stonehenge.com>
    Re: Poll: How Did You Learn Perl? <jdporter@min.net>
        regex problem cristiana@my-dejanews.com
    Re: regex problem <aperrin@mcmahon.qal.berkeley.edu>
    Re: regex problem <uri@camel.fastserv.com>
        Segmentation Fault with Perl5.00404 on Linux 2.0.35 <jxh@mail.umb.com>
        sort a hash of hashes by value <edalton@heanet.ie>
    Re: sort a hash of hashes by value <nguyend7@msu.edu>
    Re: sort a hash of hashes by value (David A. Black)
    Re: URL & strings searches (Joergen W. Lang)
    Re: URL & strings searches (Abigail)
        Use of XML::Grove::Visitor <schijvenaars@mi.fgg.eur.nl>
        weird mod_perl problem, probably not perl related (Ryan McGuigan)
    Re: weird mod_perl problem, probably not perl related (brian d foy)
    Re: When did you last use AWK (was Re: free book on sh/ <jdporter@min.net>
    Re: Win32::Registry <kairys@mi.sl.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 29 Sep 1998 08:05:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help needed
Message-Id: <MPG.107a9713c1ce9ed298988e@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <F01IJL.6o4@liverpool.ac.uk> on Tue, 29 Sep 1998 10:02:09 GMT, 
bjjgann <bjjgann@liv.ac.uk> says...
> I have a small perl script which opens a file , searches for a string and 
> replaces the string then saves the outcome to another file. This works fine 
> unless the serach string is a + to which i get an error :-
> 
> /+/: ?+* follows nothing in regexp

This is because '+' is a regex metacharacter.  See 'perlre'.

> below is the code:-
> 
> ($infilename = a);
> ($outfilename = b);
> ($search = "+");
> ($replace = "");

Why the parentheses?

One fix to the problem:

$search = quotemeta $search;  See 'perlfunc'.

> open(IN,$infilename) ||		die "cannot open $infilename for reading";
> open(OUT,">$outfilename") || die "cannot create $outfilename";

Good, but include $! in the error message to say why the open failed.
 
> while (<IN>) { 
> 		s/$search/$replace/gie; 

Another fix to the problem (equivalent to the 'quotemeta' shown above):

  		s/\Q$search/$replace/;

No 'g' unless you want to replace every occurrence on the line.
No 'i' unless you want to ignore case in $search.
No 'e', because this is a simple interpolation, not an expression that 
needs to be evaluated.

> 		print OUT $_; # print that line to file $b

  		print OUT;    # print that line to file $b

Cluttering your code with defaults is uncool.

Good luck!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 29 Sep 1998 12:24:39 GMT
From: daniel@intecomp.com (Daniel Pray)
Subject: How do I capture a Broken Pipe Error?
Message-Id: <daniel-2909980525250001@usr5-dialup9.mix1.sacramento.cw.net>

How do I capture a Broken Pipe Error and use it to do an action using the
code provided?

my $name  = "filexxxxx";
open(FILE, $name);  # Here I want to run a Sub "&whatever" if the file
doesn't get downloaded completely.
print "Content-Type: application/x-stuffit\n";
print "Location: $name\n\n";
close FILE;

Thanks,

Daniel


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

Date: Tue, 29 Sep 1998 12:35:40 GMT
From: ryan@mail.ramresearch.com (Ryan McGuigan)
Subject: mod_perl file closing problem
Message-Id: <wu4Q1.283$Fl6.5417136@news.abs.net>

Now that I figured out what my problem was with mod_perl, a simple file
locking problem where if a script was aborted, a file would not get
unlocked and the next time it's run it will just sit and wait for the file
to be unlocked.  I've figured out I need to use register_cleanup, but I
have a question about that.  How can I close all open files that are still
open, if I don't know what files are open? 

thanks
Ryan


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

Date: 29 Sep 1998 15:17:29 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: ryan@mail.ramresearch.com (Ryan McGuigan)
Subject: Re: mod_perl file closing problem
Message-Id: <m3af3joy6u.fsf@joshua.panix.com>

ryan@mail.ramresearch.com (Ryan McGuigan) writes:

> How can I close all open files that are still open, if I don't know
> what files are open?

You can't[*]. Therefore you must *know what files are open*.

Keep track of the files you've opened by pushing their filehandles
onto an array as you open them.  Better yet, use a hash whose keys are
the file names and whose values are the filehandles, to provide for
meaningful error messages. 

See perlfaq5, "How can I make a filehandle local to a subroutine?  How
do I pass filehandles between subroutines?  How do I make an array of
filehandles?"

[*] ...without obscurity.
-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 25 Sep 1998 17:12:46 +0300
From: jari.aalto@poboxes.com (Jari Aalto+mail.perl)
Subject: OO: How to make "dual" natured package
Message-Id: <ptru31wp9gh.fsf@olkikukka.i-have-a-misconfigured-system-so-shoot-me>



	Hi, [CC is fine]

	I've written a regular Module but now I'm wondering how can I
	make it both to support usages like:

		use Module;

		ModuleFunction( "args" );

	And to support

		$object = new Module;

		$object->ModuleFunction( "args" );

	Would someone recommend a simple package that does this.
	Also I tried my first OO, piece but I can't see an obvious
	mistake here. Would you give me a hand?

	jari

package Class;

sub new   { bless {}, $shift  }
sub hello { shift; print @ARG }

package main;

$obj = new Class;
$obj->hello( "world" );

--> Can't locate object method "hello" via package "main" 


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

Date: Tue, 29 Sep 1998 07:53:19 -0500
From: Virtual Joe <jduche@creighton.edu>
Subject: perl and module problem
Message-Id: <Pine.HPP.3.95.980929075227.121B-100000@bluejay.creighton.edu>

I recently compiled perl 5.004_04, and while the ./Configure answered all
the questions automatically, I was assured by the INSTALL file that if my
system (which is HPUX 10.20) had dynamic loading, that it would be smart
enough to compile it as such. Basically, it compiled and installed without
a hitch- or so it would seem. 

Soon after, I compiled/installed the FAST-CGI module for my apache server,
also without incident. 

However, when I run a FCGI script through the "-w switch, I get this
error:

# perl -w the-script
Can't load module FCGI, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the FCGI module statically linked into it.)

I guess my machine does not allow dynamic loading or it would have been
compiled with it. So how might I go about "statically linking" my module? 

Thank you for any help you can provide.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
   Joe Ducharme                    jduche@creighton.edu       
   Creighton University            Omaha, NE USA  68178       
  <<Virtual Joe      http://www.creighton.edu/~jduche/>>
  "Time flies like an arrow, Fruit flies like a banana." 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=






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

Date: 29 Sep 1998 15:22:34 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: Virtual Joe <jduche@creighton.edu>
Subject: Re: perl and module problem
Message-Id: <m37lynoxyd.fsf@joshua.panix.com>

Virtual Joe <jduche@creighton.edu> writes:

> I guess my machine does not allow dynamic loading or it would have
> been compiled with it. So how might I go about "statically linking"
> my module?

Usually a module comes with a README which explains the procedure. It
should be as simple as

  % perl Makefile.PL MAP_TARGET=hacked_perl
  % make hacked_perl
  % make inst_perl

This is documented in ExtUtils::MakeMaker.pm.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 29 Sep 1998 11:31:27 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Perl and ODBC?
Message-Id: <3610C50F.51B1E443@inlink.com>

I've been using Perl on NT and connecting to ODBC databases for over a
year now here at Boeing.  Nobody seems to have a problem with me doing
it and it works great!

We are using both Access databases AND SQL-Server databases.

Brent
-- 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Tue, 29 Sep 1998 09:06:08 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: Perl Script Running as Root
Message-Id: <36110570.1E74436C@mcmahon.qal.berkeley.edu>

I'm partial to spawning a separate process to run setuid root to do whatever has
to be done as root, then getting out of there quickly.  But that's just my
paranoia.

If what you (Benjamin) are asking is how to make the script suid root, you need to
check out the techniques (and the caveats) in the Camel book.

Regards,
Andy Perrin

Julian Gilbey wrote:

> Benjamin wrote:
> >
> > How could I sortof  'su' at run-time in a Perl script?  So that I can change
> > some sensitive files if the script authenticates the
> > session.
>
> su requires a password, so unless you're prepared to put root's
> password in the script, you might find this doesn't work.
>
> One possible way around the problem is for the script to be
> setuid root, and to either drop its privileges (with $>=$<;
> or $EUID=$UID; if you use English;) if the authentication
> fails, or to spawn a setuid-root child process to do the
> sensitive processing, immediately drop privileges in the parent,
> and then get the child to do the sensitive stuff if the
> parent authenticates.  Having the script setuid automatically
> switches on taint checking, which is probably useful too.
>
> HTH,
>
>    Julian
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
>             Julian Gilbey             Email: J.D.Gilbey@qmw.ac.uk
>        Dept of Mathematical Sciences, Queen Mary & Westfield College,
>                   Mile End Road, London E1 4NS, ENGLAND
>       -*- Finger jdg@goedel.maths.qmw.ac.uk for my PGP public key. -*-



--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King
http://socrates.berkeley.edu/~aperrin        to e-mail me)
    e-mail wheres-andy@socrates.berkeley.edu to find me!
-------------------------------------------------------------




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

Date: Tue, 29 Sep 1998 12:01:15 -0400
From: "Bill Jones, FCCJ Webmaster" <webmaster@fccjmail.fccj.cc.fl.us>
Subject: Re: Perl Script Running as Root
Message-Id: <3611044B.79CAF180@fccjmail.fccj.cc.fl.us>

Benjamin wrote:
> 
> How could I sortof  'su' at run-time in a Perl script?  So that I can change
> some sensitive files if the script authenticates the
> session.


By 'session validation' I think CGI?

See http://www.fccj.org/Webmaster/WebPass.cgi for ideas...

HTH,
-Sneex-  :]
__________________________________________________________________
Bill Jones FCCJ Webmaster | http://www.fccj.org/cgi/mail?webmaster
__________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to 
our own... Your thoughts will adapt to service us...
 ...Resistance is futile...


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

Date: Tue, 29 Sep 1998 16:04:49 GMT
From: droby@copyright.com
Subject: Re: Perl Script Running as Root
Message-Id: <6ur0f1$dvi$1@nnrp1.dejanews.com>

In article <3610ACCF.4A4E4521@qmw.ac.uk>,
  Julian Gilbey <J.D.Gilbey@qmw.ac.uk> wrote:
> Benjamin wrote:
> >
> > How could I sortof  'su' at run-time in a Perl script?  So that I can change
> > some sensitive files if the script authenticates the
> > session.
>
> su requires a password, so unless you're prepared to put root's
> password in the script, you might find this doesn't work.
>
> One possible way around the problem is for the script to be
> setuid root, and to either drop its privileges (with $>=$<;
> or $EUID=$UID; if you use English;) if the authentication
> fails, or to spawn a setuid-root child process to do the
> sensitive processing, immediately drop privileges in the parent,
> and then get the child to do the sensitive stuff if the
> parent authenticates.  Having the script setuid automatically
> switches on taint checking, which is probably useful too.
>

You should be afraid.  You should be very afraid.

Do not do this unless you're sure the script is safe.

Read the www security faq at

	http://www.w3.org/Security/faq/www-security-faq.html

and do turn on taintchecks and parse out dangerous characters from any user
input.

Otherwise you may one day see Zenin logging in as root.  ;-)

Of course we should be doing this stuff anyway (I confess I have not always,
but I'm older and wiser now).  You don't really want Zenin logging in as
nobody either, but it's not quite so scary.

--
Don Roby

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 29 Sep 1998 14:59:20 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: jscar@my-dejanews.com
Subject: Re: Perl setup (behinds the scenes)
Message-Id: <m3emsvoz13.fsf@joshua.panix.com>

jscar@my-dejanews.com writes:

> Does anyone know of a book or FAQ or web site that has information
> about the installation setup that occurs behinds the scenes with
> Perl.

You might start with

  perldoc lib
  perldoc ExtUtils::MakeMaker.pm
  perldoc AutoLoader

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 29 Sep 1998 12:20:09 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <8ck92ndsaw.fsf@gadget.cscaper.com>

>>>>> "Phinneas" == Phinneas G Stone <phinneas@eskimo.com> writes:

Phinneas> I've noticed a few comments regarding Matt's scripts, and as
Phinneas> a relative newbie who has recently implemented Matt's
Phinneas> guestbook for a customer, I wonder if someone could clue me
Phinneas> in as to how to fix this problem.

You fix it by writing your own stuff, inspired by Matt's scripts.
There's not much you can do to patch Matt's scripts to work right.
That's like patching a Yugo to make it a real car. :)

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 29 Sep 1998 12:57:56 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <36111194.13B6ECD7@min.net>

Patrick Timmins wrote:
> 
> In addition to this, I've been receiving Perl patches encrypted on
> the bottom of 'Snickers' candy bars for the past two years now.

I get notifications of CPAN updates via rye bread.

For some reason, fresh loaves of rye bread don't carry the info;
I have to leave them on top of the fridge for a couple weeks.
I make a nice reuben, with extra hot mustard, and chow down.
Within a few minutes later, I'm surfing CPAN in my head.

I usally use rye with caraway, since that seems to automatically
install any modules which have changed.

-- 
John "Many Jars" Porter


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

Date: Tue, 29 Sep 1998 15:19:36 GMT
From: cristiana@my-dejanews.com
Subject: regex problem
Message-Id: <6uqtq7$arq$1@nnrp1.dejanews.com>

I was writing a perl script and i used the regex $value=~s/\s*$//g and when
perl (5.00502) got to that line it gave me a core dump, but when i changed it
to $value=~s/\s+$//g it worked fine.  Does anyone know why the first regex
died? cristiana

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 29 Sep 1998 09:10:58 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: regex problem
Message-Id: <36110692.708589D5@mcmahon.qal.berkeley.edu>

Hmmm, I'm no expert, but wouldn't your first regex match all of any string
(i.e.,  it's 0 or more whitespace characters followed by the end of the string)?
In which case wouldn't $value always end up empty?

Not that that explains a core dump, but maybe someone else could do that :).

Regards,
Andy Perrin

cristiana@my-dejanews.com wrote:

> I was writing a perl script and i used the regex $value=~s/\s*$//g and when
> perl (5.00502) got to that line it gave me a core dump, but when i changed it
> to $value=~s/\s+$//g it worked fine.  Does anyone know why the first regex
> died? cristiana
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum



--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King
http://socrates.berkeley.edu/~aperrin        to e-mail me)
    e-mail wheres-andy@socrates.berkeley.edu to find me!
-------------------------------------------------------------




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

Date: 29 Sep 1998 12:26:59 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: cristiana@my-dejanews.com
Subject: Re: regex problem
Message-Id: <sarpvcevq98.fsf@camel.fastserv.com>

>>>>> "c" == cristiana  <cristiana@my-dejanews.com> writes:

  c> I was writing a perl script and i used the regex $value=~s/\s*$//g
  c> and when perl (5.00502) got to that line it gave me a core dump,
  c> but when i changed it to $value=~s/\s+$//g it worked fine.  Does
  c> anyone know why the first regex died? cristiana

i don't know why it core dumped but there is a big clue in your regex.
you don't need the ending anchor $ and the /g modifier in the same
regex (unless you are using the /m modifier to handle internal
newlines). so just doing

$value =~ s/\s+$// ;

will trim trailing whitespace just fine. there is no need to repeat the
operation as /g would do.

the + is better than the * since you don't care to delete whitespace
unless you have some. 

and maybe you should report the core dump with perlbug. if it is
repeatable on a simple s/// like this it is definitely a bug.

hth,

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Tue, 29 Sep 1998 10:57:46 -0500
From: "Jerry Henderson" <jxh@mail.umb.com>
Subject: Segmentation Fault with Perl5.00404 on Linux 2.0.35
Message-Id: <6ur01s$6fg@news9.noc.netcom.net>

I am trying to run some basic Perl programs on a local ISP's
( www.mwis.net )  web server .
This server is using Perl5.00404 on Linux 2.0.35 .
The perl exe resides in /usr/bin/perl according to whereis and which command
on telnet.

I can't even do a  Perl -v without getting a segmentation fault.
So it appears that Perl is not getting out of the starting blocks.

Does anyone know what's up with that?

Thanks in advanced.

Jerry Henderson




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

Date: Tue, 29 Sep 1998 16:11:37 +0100
From: Eamon Dalton <edalton@heanet.ie>
Subject: sort a hash of hashes by value
Message-Id: <3610F8A8.A2CB1E59@heanet.ie>

Hi.

Has anybody got any idea of how to sort a hash of hashes by value.

The structure is a follows

%sites = (
       "site name1" => {
           "ipaddress1"     => "no of bytes",
           "ipaddress2"     => "no of bytes",
       },
       "site name2"     => {
            "ipaddress3"   => "no of bytes ",
       },
     );


I first want to be able to sort by site name and then by the number of
bytes.

Thanks,
            Eamon.




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

Date: 29 Sep 1998 15:28:47 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: sort a hash of hashes by value
Message-Id: <6uqubf$l64$1@msunews.cl.msu.edu>

Eamon Dalton <edalton@heanet.ie> wrote:
: Has anybody got any idea of how to sort a hash of hashes by value.

: The structure is a follows

: %sites = (
:        "site name1" => {
:            "ipaddress1"     => "no of bytes",
:            "ipaddress2"     => "no of bytes",
:        },
:        "site name2"     => {
:             "ipaddress3"   => "no of bytes ",
:        },
:      );


: I first want to be able to sort by site name and then by the number of
: bytes.

here's a simpilied example:
%hash = ( foo => 2, bar => 1 );

so $hash{foo} == 2 and $hash{bar} == 1;

lets say you want to sort them by their value.
so you want 1 to go before 2

lets call my magical function called
my_magical_super_sorting_function(%hash);

and poof its sorted.  so how do you access the first one on the list.
You don't because hashes aren't in any particular order.

This is true with hashes of hashes as well.  So think up a new data structor.


-- 
           Dan Nguyen            | There is only one happiness in
        nguyend7@msu.edu         |   life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 |                   -George Sand



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

Date: Tue, 29 Sep 1998 12:13:09 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: sort a hash of hashes by value
Message-Id: <6ur0ul$nor$1@earth.superlink.net>

Hello -

Dan Nguyen <nguyend7@msu.edu> writes:

>Eamon Dalton <edalton@heanet.ie> wrote:
>: Has anybody got any idea of how to sort a hash of hashes by value.

>: The structure is a follows

>: %sites = (
>:        "site name1" => {
>:            "ipaddress1"     => "no of bytes",
>:            "ipaddress2"     => "no of bytes",
>:        },
>:        "site name2"     => {
>:             "ipaddress3"   => "no of bytes ",
>:        },
>:      );


>: I first want to be able to sort by site name and then by the number of
>: bytes.

>here's a simpilied example:
>%hash = ( foo => 2, bar => 1 );

>so $hash{foo} == 2 and $hash{bar} == 1;

>lets say you want to sort them by their value.
>so you want 1 to go before 2

>lets call my magical function called
>my_magical_super_sorting_function(%hash);

>and poof its sorted.  so how do you access the first one on the list.
>You don't because hashes aren't in any particular order.

>This is true with hashes of hashes as well.  So think up a new data structor.


What are you talking about?  What programming language are you talking about?
What exactly do you *do* with Perl, if you think it is not capable of this
kind of thing?

No - don't answer.  I don't want to know.

But do look at this:

#!/usr/local/bin/perl -w

use strict;
my %hash = ( foo => 2, bar => 1 );

print "In ascending numerical order by value: \n";
print map { "key: $_, value: $hash{$_}\n" }
      sort { $hash{$a} <=> $hash{$b} } keys %hash;


And a possible answer to Eamon's question (though I think there are better
answers, including questioning whether perhaps there should be a "name" key,
but ANYWAY, to (re-)establish the fact that you CAN sort deep hashes....)

#!/usr/local/bin/perl -w

use strict;

my %sites = (
        "Some site"         => { "123.567" => "20", "123.456" => "10", },
        "Some earlier site" => { "123.234" => "30", },
);

foreach my $k (sort keys %sites) {
   print "site: $k\n",
   map  { "address: $_, bytes: " . $sites{$k}{$_} . "\n" }
         sort { $sites{$k}{$a} <=> $sites{$k}{$b} }
         keys %{$sites{$k}}
}


David Black
dblack@saturn.superlink.net


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

Date: Tue, 29 Sep 1998 17:40:41 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: URL & strings searches
Message-Id: <1dg4nvv.1ia2d6etghz3tN@host028-210.seicom.net>

I think someone wrote a thing called the "rules-sucks-o-meter" which
does similar things AFAIK. Should be somewhere on CPAN.

hth, Joergen

meyrick <meyricklouiseNOJUNK@btinternet.com> wrote:

> I start by admitting I am a complete newbie as far as Perl is
> concerned - apologies to all gurus :-)
> 
> Can anyone help with the following challenge?
> 
> I want a script that will:
> 
> 1/ access  defined URLs on the internet (say www.ft.com, www.wsj.com,etc)
> 
> 2/  search all public pages on the root address (www.wsj.com) for strings
> (say "bonds" or "Greenspan") as defined at the programme's initiation.
> 
> 3/ return the number of times the defined string occurs in the complete
> site.
> 
> A script called WebPluck has been suggested to but on closer inspection does
> not specifically return the string hit rate and also only searches defined
> pages.
> 
> Any help would be very much appreciated.
> 
> Tks
> 
> Meyrick


-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
print pack q,h52,,unpack q,H52,,join q,,,map chr,split q, ,,q,164 87 55
71 2 22 230 246 71 134 86 39 2 5 86 39 198 2 132 22 54 182 86 39 2 18,;


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

Date: 29 Sep 1998 16:50:18 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: URL & strings searches
Message-Id: <6ur34a$ol1$5@client3.news.psi.net>

meyrick (meyricklouiseNOJUNK@btinternet.com) wrote on MDCCCLV September
MCMXCIII in <URL:news:6uq8ks$f7f$1@mendelevium.btinternet.com>:
++ I start by admitting I am a complete newbie as far as Perl is
++ concerned - apologies to all gurus :-)
++ 
++ Can anyone help with the following challenge?
++ 
++ I want a script that will:


Perhaps you should hire a programmer.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Tue, 29 Sep 1998 17:25:25 +0200
From: "Bob J.A. Schijvenaars" <schijvenaars@mi.fgg.eur.nl>
Subject: Use of XML::Grove::Visitor
Message-Id: <3610FBE5.C0E0C5A1@mi.fgg.eur.nl>

Hi,

I'm trying to use the package XML::Grove::Visitor on my own XML
files. I tried the example visitor.pl which works perfectly.

When I try to extend that script by adding subroutines
'visit_entity' and 'visit_comments', in the same way as
in the routine 'visit_pi', they don't seem to be executed,
while there are entities and comments in my XML file.

Since I am a newbie at perl-parsing of XML files I guess I am
doing something completey wrong. If not: see below for parts of
the sourcecode of the extended visitor.pl example:

--------------------------------------------------------------------------
#!/usr/bin/perl -w
use diagnostics;
#
# Copyright (C) 1998 Ken MacLeod
# See the file COPYING for distribution terms.
#
# $Id: visitor.pl,v 1.2 1998/09/20 18:48:01 kmacleod Exp $
#
use XML::Parser;
use XML::Parser::Grove;
use XML::Grove;
use XML::Grove::Visitor;

my $doc = shift;
my $parser = XML::Parser->new(Style => 'grove');
my $visitor = new MyVisitor;
my $grove = $parser->parsefile ($doc);
my @context;
$grove->accept ($visitor, \@context);

package MyVisitor;

sub new {
    my $class = shift;
    return bless {}, $class;
}
sub visit_grove {
    my $self = shift; my $grove = shift;
    $grove->children_accept ($self, @_);
}
sub visit_element {
    my $self = shift; my $element = shift; my $context = shift;
    push @$context, $element->name;
    my @attributes = %{$element->attributes};
    print STDERR "@$context \\\\ (@attributes)\n";
    $element->children_accept ($self, $context, @_);
    print STDERR "@$context //\n";
    pop @$context;
}
sub visit_pi {
    my $self = shift; my $pi = shift; my $context = shift;
    my $target = $pi->target;
    my $data = $pi->data;
    print STDERR "@$context ?? $target($data)\n";
}
####### NEW !!!!!
sub visit_comment {
    my $self = shift; my $comment = shift; my $context = shift;
    my $data = $comment->data;
    print STDERR "@$context !! $data\n";
}
##################
sub visit_scalar {
    my $self = shift; my $scalar = shift; my $context = shift;
    ....
}
--------------------------------------------------------------------------
Bob
-- 
________________________________________________________________________
 Bob J.A. Schijvenaars                email...schijvenaars@mi.fgg.eur.nl
 Dept. of Medical Informatics,        Talk....+31-(0)10 408 7045
 Faculty of Medicine and Health Sciences, Erasmus University Rotterdam


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

Date: Tue, 29 Sep 1998 13:36:42 GMT
From: ryan@mail.ramresearch.com (Ryan McGuigan)
Subject: weird mod_perl problem, probably not perl related
Message-Id: <Kn5Q1.284$Fl6.5438317@news.abs.net>

I don't know if anyone here can help with this, or if this is even a good
place to post this question, but...

I have a script I'm trying to port to mod_perl, I just got it to work
without dying or killing anything, but there is still this weird problem.
Every once in a while, the PATH_INFO env var gets set to / or // for no
reason at all.  I use that env var in my script, it doesn't work right
when it does this.  Anyone else ever have a similar problem?

thanks,
Ryan


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

Date: Tue, 29 Sep 1998 10:57:09 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: weird mod_perl problem, probably not perl related
Message-Id: <comdog-ya02408000R2909981057090001@news.panix.com>
Keywords: from just another new york perl hacker

In article <Kn5Q1.284$Fl6.5438317@news.abs.net>, ryan@mail.ramresearch.com (Ryan McGuigan) posted:

>I have a script I'm trying to port to mod_perl, I just got it to work
>without dying or killing anything, but there is still this weird problem.
>Every once in a while, the PATH_INFO env var gets set to / or // for no
>reason at all. 

well, it's unlikely that it gets set to anything for no reason at all.
examine the situations in which that happens and find the correlation.

other than that, it's difficult to happen you with so little information.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: Tue, 29 Sep 1998 13:00:52 -0400
From: John Porter <jdporter@min.net>
Subject: Re: When did you last use AWK (was Re: free book on sh/sed/awk)
Message-Id: <36111244.1C63E05@min.net>

Kiril wrote:
> 
> I "tend" to use awk for one-liners, not because they are better/worse
> then perl, just that my fingers sorta go ahead and type them.
> 
> Then again, I first met awk, oh, (c.f. G.Reese) ~10 years ago, and
> perl ~2 years ago, so that might be it.

Well, since you're trying to justify your use of awk, I'm guessing
that you learned awk 7 years ago and perl 4 years ago.  :-)

-- 
John "Many Jars" Porter


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

Date: Tue, 29 Sep 1998 09:39:11 -0400
From: "Michael Kairys" <kairys@mi.sl.com>
Subject: Re: Win32::Registry
Message-Id: <3610e1c7.0@news.ic.net>

You need to do some research about what is in the Registry.
What the script shows you is what is in fact there. You won't
find a list of running applications in the registry.

The quickest way for you to get there would be to use tlist.exe
from the NT Resource Kit -- run it in backticks and parse its output.

>Hi,
>
>I'm trying to get the list of running applications from WinNT/95.
>Here's the script that I have, but it seems to list all the software
>that I have and some other stuff:
>
>use Win32::Registry;
>my $Register = "";
>my ($hkey, @key_list, $key);
>
>$HKEY_LOCAL_MACHINE->Open($Register,$hkey)|| die $!;
>$hkey->GetKeys(\@key_list);
>foreach $key (@key_list)
>        {
>        print "$key\n\n";
>        }
>$hkey->Close();
>
>Please help,
>
>Alex




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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3850
**************************************

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