[12428] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6028 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 17 04:07:15 1999

Date: Thu, 17 Jun 99 01:00:24 -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           Thu, 17 Jun 1999     Volume: 8 Number: 6028

Today's topics:
    Re: Afraid to ask about Y2K! (Larry Rosler)
    Re: CGI:pm error message (David Efflandt)
    Re: Help me I'm a dummy <vincent_vanbiervliet@be.ibm.com>
        How can I get fork to work (in NT)? <phlippy@bellatlantic.net>
    Re: How to extract emails from Outlock Express <founder@pege.org>
    Re: How to extract emails from Outlock Express <founder@pege.org>
    Re: IO::Pipe question... (Ronald J Kimball)
    Re: Is it better perl than awk ? (Bart Lateur)
    Re: Is it better perl than awk ? (Ilya Zakharevich)
    Re: my and interpolation? (Abigail)
    Re: my and interpolation? (Abigail)
    Re: newbie learning "my" declarations (Bart Lateur)
    Re: newbie questions re conditional operators (Ronald J Kimball)
    Re: Odd syntax in hash subscript (Abigail)
    Re: pattern matching question (Abigail)
    Re: pattern matching question (Bart Lateur)
    Re: Probably simple, but pulling hair out <JFedor@datacom-css.com>
    Re: Problems creating Text file. <vincent_vanbiervliet@be.ibm.com>
    Re: Problems creating Text file. <vincent_vanbiervliet@be.ibm.com>
        program execution meter???? <wolfgang.goetzinger@siemens.at>
        Rank HoH by sub-sub-key? <bjornsvensson@geocities.com>
    Re: regexp trouble.. <office@asc.nl>
    Re: regexp trouble.. (brian d foy)
    Re: regexp trouble.. <office@asc.nl>
    Re: saving uploaded file (David Efflandt)
    Re: simple quesiotn about array (Ronald J Kimball)
        splitting an array into two arrays <snapperhead_420@hotmail.com>
    Re: splitting an array into two arrays (brian d foy)
    Re: SQL statement in Perl (Abigail)
    Re: Surprise with .. operator in list context (Ronald J Kimball)
    Re: Surprise with .. operator in list context (Anno Siegel)
    Re: what does this crypto script do? (Ronald J Kimball)
    Re: What is functional difference between .pm and .pl? (Bart Lateur)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 16 Jun 1999 22:50:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <MPG.11d22c89c8eade0a989bf6@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <B38DE1899668E9DBB@204.112.166.88> on Wed, 16 Jun 1999 
23:19:37 -0500, Lee <rlb@intrinsix.ca> says...
 ...
> POSIX declares that leap seconds shall not be reckoned.

I believe that this is a correct statement.  But when asked to, I was 
unable to come up with an authoritative reference for it.  Please post 
your reference.

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


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

Date: 17 Jun 1999 00:45:33 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: CGI:pm error message
Message-Id: <slrn7mgh5d.hp.efflandt@efflandt.xnet.com>

On Wed, 16 Jun 1999 15:51:57 -0700, Mahlon Smith
<reich@pants.internetcds.com> wrote:
>At least, I think it's CGI:pm that is giving me this.
>
>A script I've been screwing with has suddenly died, but only when accessed
>via the web.
>No 500 error, just an internal error.
>
>Running it from the command line works perfectly, no errors, even with
>the -w switch.

Are you testing it as './scriptname.cgi' or 'perl scriptname.cgi'?  The
former will give you clues that the latter will not.  For example, the
first method will choke with incorrect #!/path/to/perl or carriage
returns [can't find perl^M, but ^M (\r) is invisible], and the second
method may not reveal those problems.

>Running perl -cw [scriptname] gives an error, however.
>( I have had yet to see a script execute, but not verify via -c.)
>
>The error is
>Args must match #! line at [scriptname] line 1.
>
>I of course know what the #! line is....
>However the rest of the error message is not ringing a bell for me.

You might try a simple $!/bin/sh CGI to see if perl -v is what you think
it is on the web.  Some systems have different perl versions in different
paths (possibly including the old perl4).

CGI.pm is old (v2.36) on one of my vhosts.  I do not have write access to
the main libs, but do have access to site_perl, so I installed my own
CGI.pm v2.42 in site_perl and shuffled @INC to find it first.  So you
might also want to try a simple test:

use CGI;
print "Content-type: text/plain\n\n";
$cgiver = $CGI::VERSION;
print "CGI.pm version is $cgiver\n";

-- 
David Efflandt   efflandt@xnet.com   http://www.xnet.com/~efflandt/
http://www.de-srv.com/   http://cgi-help.virtualave.net/


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

Date: Thu, 17 Jun 1999 09:40:14 +0200
From: "Vincent Vanbiervliet" <vincent_vanbiervliet@be.ibm.com>
Subject: Re: Help me I'm a dummy
Message-Id: <37689775@news.uk.ibm.net>

Being ignorant about something doesn't mean you don't have to read
documentation that comes with perl.
Being ignorant about something doesn't mean you shouldn't buy a book that
teaches you on perl.
Being a dummy does.
Start being ignorant about perl instead of being dummy.

Bill & Carrie <woof@thegrid.net> wrote in message
news:37687AC7.56DEAA19@thegrid.net...
> I am using a perl script that "prints" out a html file.
> All works fine except I would like to edit out some of the body of the
> html file
> The script forms the <head></head>
> then the <body>
> then prints a variable that contains the entire text of the html file
> $text
> $text is set by the line ($text="finger $info")
>
> I would like to know how to search $text until I match a certain string
> then
> only print what comes after that string (or line)
>
> Any help will be greatly appreciated





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

Date: Thu, 17 Jun 1999 05:03:03 -0300
From: Philip DiFalco <phlippy@bellatlantic.net>
Subject: How can I get fork to work (in NT)?
Message-Id: <3768ABB6.C8B812DA@bellatlantic.net>

I'm porting some of my UNIX perl to NT.
I'm running version 5.005_03
Of course, fork doesn't work.
How can I get fork to work?

email me at either (or both): phlippy@bellatlantic.net and/or
difalcop@csosa.fed.us

Thanks,
Phiip DiFalco




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

Date: Wed, 16 Jun 1999 23:22:15 +0200
From: "Mosl Roland" <founder@pege.org>
Subject: Re: How to extract emails from Outlock Express
Message-Id: <7ka067$jlk$1@orudios.magnet.at>

Tom Phoenix <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.02A.9906161353580.26850-100000@user1.teleport.com...

> If you think there might be a module made for working with these files
> from Perl, check the Module List on CPAN.

CPAN is so search engine unfriednly designed,
that I stoped even to try to find there something


--
Mosl Roland - http://www.pege.org
clear targets for a confused civilization





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

Date: Thu, 17 Jun 1999 07:20:19 +0200
From: "Mosl Roland" <founder@pege.org>
Subject: Re: How to extract emails from Outlock Express
Message-Id: <7ka0jk$jpa$1@orudios.magnet.at>

David Cassell <cassell@mail.cor.epa.gov> wrote in message
news:37681F7B.71600544@mail.cor.epa.gov...
> [courtesy cc sent to poster]
>
> Mosl Roland wrote:
> >
> > I would like to extract all emails from
> > Outlock Express 5 and store the
> > messages in an own database system.
>
> Isn't that 'Outlook' Express?  Although I usually
> call it Lookout! Express or Outlook Distress.  :-)

I changed the name after I detected after a system
crash, that Outlock had suddenly forgotten about
15 mail folders. I had to use some tricks, to put
this mail folders back into Outlock Expess.

> > First step: how to extract from the
> > Outlock Express files?
>
> I think that you'll want to look in the ActivePerl FAQ at
> the section entitled "Using OLE with Perl".  There's
> even a specific example on working with OE.
>
> Then you can get more help from the Perl-Win32-users
> listserv, to which you can subscribe at
> http://www.activestate.com/support/mailing_lists.htm .
> The folks there have a lot of experience in Perl and
> OLE.  In fact, the author of Win32::OLE is a regular
> reader of the list.

I will look fort it


--
Mosl Roland - http://www.pege.org
clear targets for a confused civilization




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

Date: Thu, 17 Jun 1999 01:12:39 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: IO::Pipe question...
Message-Id: <1dtip0i.1d9vzqggcn0foN@p207.tc2.state.ma.tiac.com>

Chris Ice <chris.ice@cisco.com> wrote:

> 2) How can I tell that the piped command is STILL there?  Say for some
> reason piped command dies (drops core, etc)...how can I test to ensure
> it's still a valid handle to read from?

If that happens, your code should get a SIGPIPE next time it tries to
use the handle, so you could set up a handler for that signal.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 17 Jun 1999 06:30:03 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Is it better perl than awk ?
Message-Id: <37688f2e.2722302@news.skynet.be>

Harlan Grove wrote:

>awk can run on MS-DOS systems, perl can't.

Rubbish. I use GNU Perl for MS-DOS, under Win3.1, all the time.

	Bart.


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

Date: 17 Jun 1999 07:10:15 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Is it better perl than awk ?
Message-Id: <7ka70n$kpa$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Bart Lateur
<bart.lateur@skynet.be>],
who wrote in article <37688f2e.2722302@news.skynet.be>:
> >awk can run on MS-DOS systems, perl can't.
> 
> Rubbish. I use GNU Perl for MS-DOS, under Win3.1, all the time.

There is no GNU Perl, thus you cannot run it.

Hope this helps,
Ilya


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

Date: 16 Jun 1999 19:38:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: my and interpolation?
Message-Id: <slrn7mghd5.ejb.abigail@alexandra.delanet.com>

Nenad Vidovic (nenad@halcyon.ca) wrote on MMCXV September MCMXCIII in
<URL:news:3767E8AC.C800E851@halcyon.ca>:
%% Hi!
%% 
%% So I have this and it works:
%% 
%% $compression = "gz";
%% $file_size_gz = "3";
%% $file_size = ${"file_size_$compression"};
%% print "$file_size\n";
%% 
%% However this does not:
%% 
%% $compression = "gz";
%% my $file_size_gz = "3";
%% $file_size = ${"file_size_$compression"}
%% print "$file_size\n";
%% 
%% Anybody have any ideas why this doesn't work. Thanks for helping out?


That's in the manual. Look up symbolic references, my() and symboltables.



Abigail
-- 
perl -wlne '}for($.){print' file  # Count the number of lines.


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 16 Jun 1999 19:45:49 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: my and interpolation?
Message-Id: <slrn7mghq1.ejb.abigail@alexandra.delanet.com>

Nenad Vidovic (nenad@halcyon.ca) wrote on MMCXV September MCMXCIII in
<URL:news:376801C5.E1A513D4@halcyon.ca>:
__ Hi again,
__ 
__ Thanks for answering. But I am not clear about this, but I guess I'll have
__ to read about it more. Still in my mind the question: how then to create a
__ dynamicly create variables. Isn't this supposed to be an advantage of Perl.

Yes, it's an advantage. That doesn't mean it should be misused though.

__ Look at this:
__ 
__ @variables = ( "city", "country", "first_name", "last_name");
__ foreach $var (@variables) {
__     ${$var} = &query("$var");
__ }
__ 
__ query is some function. Is it wrong to write in this way. What is the
__ alternative?


You haven't been reading much here, have you?
You haven't read the FAQ either, have you?

Perl has another advantage: hashes. Hashes are your friends. Use them.



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Thu, 17 Jun 1999 06:30:07 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: newbie learning "my" declarations
Message-Id: <376a9027.2971003@news.skynet.be>

Lee wrote:

>It's nasty when your script breaks because you change $me++ to $me += 2.

It doesn't break. "+=" is warning immune if the target is undef, just
the same as with "++".

	#! perl -w
	my $x; $x++; # no warning
	my $y; $y += 2; # no warning
	my $z; $z = $z + 3 ; # WARNING! 

	Bart.


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

Date: Thu, 17 Jun 1999 01:12:40 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: newbie questions re conditional operators
Message-Id: <1dtipn9.1xhp2w815qogsgN@p207.tc2.state.ma.tiac.com>

Rory C-L <'x'campbell-lange@easynet.co.uk> wrote:

> Quote from perlop.pod:
> "...It works much like an if-then-else.  If the argument before the ? is
> true, the argument before the : is returned, otherwise the argument after
> the : is returned..."

If you're using a more recent version of Perl (i.e. 5.005_02 or later),
perlop.pod goes on to say:

    The operator may be assigned to if both the 2nd and 3rd arguments
    are legal lvalues (meaning that you can assign to them):

        ($a_or_b ? $a : $b) = $c;

    This is not necessarily guaranteed to contribute to the readability
    of your program.

    Because this operator produces an assignable result, using
    assignments without parentheses will get you in trouble.  For
    example, this:

        $a % 2 ? $a += 10 : $a += 2

    Really means this:

        (($a % 2) ? ($a += 10) : $a) += 2

    Rather than this:

        ($a % 2) ? ($a += 10) : ($a += 2)


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 16 Jun 1999 20:05:28 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Odd syntax in hash subscript
Message-Id: <slrn7mgius.ejb.abigail@alexandra.delanet.com>

John Nolan (nolanj00@mh.us.sbphrd.com) wrote on MMCXV September MCMXCIII
in <URL:news:3767B3E5.15E3F082@mh.us.sbphrd.com>:
() 
() 
() This code:
() #-------------------------------------
()    my @list = qw( a b c );
()    my (%hash1, %hash2, %hash3, %hash4);
() 
()    $hash1{     @list     } = 1;
()    $hash2{ scalar @list  } = 1;
()    $hash3{ qw( a b c )   } = 1;
()    $hash4{ "a", "b", "c" } = 1;
() 
()    print keys %hash1; print "\n";
()    print keys %hash2; print "\n";
()    print keys %hash3; print "\n";
()    print keys %hash4; print "\n";
() 
() #-------------------------------------
() Prints out the following:
() 
()    Use of implicit split to @_ is deprecated at ./testme line 12.
()    3
()    3
()    3
()    abc
() #-------------------------------------
() 
() Line 12 is the assignment to %hash3.  I don't understand
() the warning,

If you look up qw, you'll find a reference to another function. Look up
that function, and all will be clear. Alternatively, look up the warning
in perldiag.

()              and I also don't understand why the elements
() in the list are concatenated in the assignment to %hash4. 

That's a bit more tricky, and has to do with compatability of pre-perl5s.
Before perl5, there were no references, and hence, no way of making hashes
of hashes. To fake multilevel hashes, indexing of the form $hash {"a",
"b", "c"} really means $hash {join $;, "a", "b", "c"}, with $; by default
"\034", an unprintable character. Hence, the key is really "a\034b\034c",
but that will show up as "abc" on your screen.

AFAIK, this behaviour is only documented in perlvar, not in perldata, perlsyn
or perldsc. It probably should, as perlvar is an unlikely place to look up
such unexpected behaviour.

() Shouldn't all four assignments be equivalent? 
() 
() Is this behavior documented somewhere?  I've been searching
() for it, but so far I have not found it.  

Yes, but in the case of %hash4, you have to know where to look.

() In the first three assignment statements, the list is
() evaluated in scalar context.  But what context is used
() in the subscript to %hash4? 

Scalar, since a join is done.



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 16 Jun 1999 20:08:41 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: pattern matching question
Message-Id: <slrn7mgj4v.ejb.abigail@alexandra.delanet.com>

Eric The Read (emschwar@rmi.net) wrote on MMCXV September MCMXCIII in
<URL:news:xkfemjblvx0.fsf@valdemar.col.hp.com>:
'' gbacon@itsc.uah.edu (Greg Bacon) writes:
'' > If you're determined to use a regular expression
'' > 
'' >     ($path = $url) =~ s,^.*?//.*?/,,;
'' 
'' It's entirely possible that those are the ugliest delimiters I've ever
'' seen for s///.


Oh, you like this better?

    s s^.*?//.*?.ss;


Of course, the regex only works for certain classes of URLs, and it might
be hopelessly wrong for certain relative URLs.


Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Thu, 17 Jun 1999 06:30:19 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: pattern matching question
Message-Id: <376c935c.3792022@news.skynet.be>

Eric The Read wrote:

>>     ($path = $url) =~ s,^.*?//.*?/,,;
>
>It's entirely possible that those are the ugliest delimiters I've ever
>seen for s///.

Oh yeah?

	($path = $url) =~ s;^.*?//.*?/;;;

	Bart.


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

Date: Thu, 17 Jun 1999 03:14:58 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Probably simple, but pulling hair out
Message-Id: <7ka5h7$fem$1@plonk.apk.net>


Michael Hill wrote in message <37682736.285DFBC2@lmtas.lmco.com>...
>In my perl script I am trying to pass the value that is being stored to
>my variable.
>print '<input type=hidden name="myfield" value=$myvalue>';


Michael,

        Perl does not parse the print line if not "double quoted".

        All browsers will allow you to use 'single quote'.  If you've ever
done any javascripting, you need to use single quotes all the time within
double quotes.

        <IMG SRC='gif/picture.gif' ALT='This is a great picture'>  will work
fine.

        Using :   print "<input type=hidden name='myfield'
value=$myvalue>\n";

        will therefore work fine.

Jody




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

Date: Thu, 17 Jun 1999 09:57:27 +0200
From: "Vincent Vanbiervliet" <vincent_vanbiervliet@be.ibm.com>
Subject: Re: Problems creating Text file.
Message-Id: <37689b7e@news.uk.ibm.net>

news.boeing.com <jim.ray@west.boeing.com> wrote in message
news:FDFFJw.DBM@news.boeing.com...
> I am converting my UNIX PERL to NT.  I am using IIS4 and all the data
files
> are on the same area.  For some reason my OPEN staement does not work
> anymore.  Her eis the code
>
>    open(CONFG, ">$dataname");
>    foreach $arg(@Save)
>
>
>      print CONFG ("$arg");
>    }
>
> PERL goes through the motions of writing the file, but the file never gets
> created.  Am I missing some here>  I am using Activestate PERL 5.3, NT 4.0
> sp5 with IIS4.

As the file doens't get created, it's probably a perl problem.
Aparently you never read this newsgroup before, or you would have noticed
that people get flamed for not checking the result of an open statement. So
always use

          open CONFG, ">$dataname" or die "Can't create $dataname: $!\n";

As you may know, the special variable $! contains the operating system error
string (when used in a string context, which it is in this case). When the
open statement fails, at least you'll know why. You may have to use CGI::pm
to redirect STDERR to STDOUT (you should check what statement exactly to
use, but I believe it's something like
         use CGI::Carp(fatalsToBrowser);
)
Also always use the -w switch, and 'use diagnostics', this will help a lot.


Vincent

>
> Thank you for the help.
>
> --
> Jim Ray
> Delta Program NT Administrator
> The Boeing Company
> 714-896-2038
> jim.ray@west.boeing.com
>
>




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

Date: Thu, 17 Jun 1999 10:00:35 +0200
From: "Vincent Vanbiervliet" <vincent_vanbiervliet@be.ibm.com>
Subject: Re: Problems creating Text file.
Message-Id: <37689c39@news.uk.ibm.net>


Vincent Vanbiervliet <vincent_vanbiervliet@be.ibm.com> wrote in message
news:37689b7e@news.uk.ibm.net...

> As the file doens't get created, it's probably a perl problem.

Actually, it is NOT a perl problem. The problem is with your file ($dataname
doesn't exist, the file it's refering to doesn't exist, you don't have
permissions in the directory you want to write...), but what I wanted to say
is: it's not a problem with the OS or IIS.

Vincent




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

Date: Thu, 17 Jun 1999 09:27:12 +0200
From: Wolfgang =?iso-8859-1?Q?G=F6tzinger?= <wolfgang.goetzinger@siemens.at>
Subject: program execution meter????
Message-Id: <3768A350.3986FB97@siemens.at>

Hi!

I programmed a script, that starts the program myProgr and prints the
stdout of this program:

    open OUTPUT,"myProgr|";
    while (<OUTPUT>) {
          print;
    }
    close OUTPUT;

myProgr takes several minutes to execute and return a stdout.
the question is:
How can i print out a "." every 10 seconds until myProgr has finished?
(to indicate that myProgr is still executing)

I think i could be done with select(RBITS,WBITS,EBITS,TIMEOUT)

thanx a lot for help!
gonzo



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

Date: Thu, 17 Jun 1999 09:20:11 +0200
From: "Bjvrn Svensson" <bjornsvensson@geocities.com>
Subject: Rank HoH by sub-sub-key?
Message-Id: <3768A1AB.59209239@geocities.com>

Rank list for Hash of hashes?

I read some county-level statistics (population,area etc) thru DBI
and I'd like to rank the counties in order from highest to
lowest value (for each and every variable).

>From the DBI I create a hash of hash looking something like this:
%stats = (
    "01" => { variable_1  => "1000",
              variable_2  => "44000",
              variable_3  => "2",  },
    "02" => { variable_1  => "2000",
              variable_2  => "33000",
              variable_3  => "2", },
    "03" => { variable_1  => "2500",
              variable_2  => "22000",
              variable_3  => "10", }, );
Note that values can be identical like variable_3 in the
first two counties above.

How do I add a ranking to each variable?  So that I end up with
something more like:
%stats = (
    "01" => { variable_1  => "1000",    rank_1 => '1'
              variable_2  => "44000",   rank_2 =>     '3'
              variable_3  => "2",  },   rank_3 => '1'
    "02" => { variable_1  => "2000",    rank_1 =>   '2'
              variable_2  => "33000",   rank_2 =>   '2'
              variable_3  => "2", },    rank_3 => '1'
    "03" => { variable_1  => "2500",    rank_1 => '1'
              variable_2  => "22000",   rank_2 => '1'
              variable_3  => "10", },   rank_3 =>     '3' );

Or is there any alternative way of later being able to say:
1) County "02" has a variable_2 value of 33000 which is ranked 2
(second highest)?
2) Top 10 variable_1

I hope this makes sense...
Any suggestions greatly appreciated (as usual)!

======================================================
Bjvrn Svensson             bjornsvensson@geocities.com
SE-165 60 Hdsselby; Sweden
======================================================


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

Date: Thu, 17 Jun 1999 08:38:48 +0200
From: "Bastiaan S van den Berg" <office@asc.nl>
Subject: Re: regexp trouble..
Message-Id: <7ka597$70h$1@zonnetje.NL.net>

hiya

i've changed it into this now :

$HTML =~ s/\$(\w+)/${$1}/g;

it works on my system , but it still won't work on my isp's server
, so i started checking what version my server has

it's 5.002 , so is it resonable to ask for an update?

secondly , could i find this version somewhere for win32 , so i can at least
build programs that work?


tnx in advance
--
Bastiaan v/d Berg ; aka buZz
Internet Specialist
Account Software Consultancy
-[ http://www.asc.nl/ ]-[ office@asc.nl ]-
-[ http://huizen.ddsw.nl/bewoners/buzz/ ]-[ buzz@ddsw.nl ]-
M.J.T. Guy heeft geschreven in bericht
<7k8n0h$3ti$1@pegasus.csx.cam.ac.uk>...
>Abigail <abigail@delanet.com> wrote:
>>Bastiaan S van den Berg (office@asc.nl) wrote on MMCXIV September
>>MCMXCIII in <URL:news:7k5nu7$4ea$1@zonnetje.NL.net>:
>>..
>>.. the regexp that causes the error is :
>>.. $HTML =~ s/$(\w+)/$\1/g;
>>
>>Wasn't this discussed recently?
>>
>>$( is a variable.
>
>Not since perl5.005.   Watch:
>
>   /$(/;
>/$(/: unmatched () in regexp at    ...
>
>$|, $) and $( are treated specially and not interpolated (unless you write
>${(} of course).    The third of these doesn't appear to be documented.
>
>
>Mike Guy




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

Date: Thu, 17 Jun 1999 03:12:05 -0400
From: brian@pm.org (brian d foy)
Subject: Re: regexp trouble..
Message-Id: <brian-ya02408000R1706990312050001@news.panix.com>

In article <7ka597$70h$1@zonnetje.NL.net>, "Bastiaan S van den Berg" <buzz@ddsw.nl> posted:

> it's 5.002 , so is it resonable to ask for an update?

it's almost obligatory in this case.  it's morally wrong to be that
far behind in the versions ;)

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Thu, 17 Jun 1999 09:35:54 +0200
From: "Bastiaan S van den Berg" <office@asc.nl>
Subject: Re: regexp trouble..
Message-Id: <7ka8k7$9kv$1@zonnetje.NL.net>

>> it's 5.002 , so is it resonable to ask for an update?
>
>it's almost obligatory in this case.  it's morally wrong to be that
>far behind in the versions ;)

hehe , well , i called my isp just now , and told them about my troubles ..

he was going to ask it to someone if he could update it , but when i started
about regexp's , he lost it . so i quickly switched back to 'non-perl' mode
, and asked if he thought they were going to update , he gave me 50% chance
 ..

isn't there a way to get perl 5.002 for win32? just to be on the save side?

--
Bastiaan v/d Berg ; aka buZz
Internet Specialist
Account Software Consultancy
-[ http://www.asc.nl/ ]-[ office@asc.nl ]-
-[ http://huizen.ddsw.nl/bewoners/buzz/ ]-[ buzz@ddsw.nl ]-




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

Date: 17 Jun 1999 01:31:55 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: saving uploaded file
Message-Id: <slrn7mgjsb.hp.efflandt@efflandt.xnet.com>

On Wed, 16 Jun 1999 22:21:26 GMT, Ryan Corder <uucon@my-deja.com> wrote:
>I'm new to perl, how do i use this?

In the shell try typing 'perldoc File::Basename' (without quotes) or on a
unix system you can read the same thing with 'man File::Basename'.

If both of those fail try:  perl -e "print @INC;"
and if you can figure out where each path ends, search those paths and
read the dir/file:  File/Basename.pm

The same technique can be used to find info on any module.  You might even
want to look through those files for other helpful modules.

So far I have not seen a full path returned for a file uploaded to CGI.pm,
but I have not tried it with MSIE, so I do not know if it still munges the
filename with useless (or hacker friendly) local dir info.

>ryan
>
>In article <Pine.GSO.4.02A.9906161340230.26850-100000@user1.teleport.com>,
>  Tom Phoenix <rootbeer@redcat.com> wrote:
>> On Wed, 16 Jun 1999, Ryan Corder wrote:
>>
>> > Now, how do i strip the path from $filename so i can specify the file
>> > to be saved in a specific directory?
>>
>> Use File::Basename. Cheers!
>>
>> --
>> Tom Phoenix       Perl Training and Hacking       Esperanto
>> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>>
>>
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.


-- 
David Efflandt   efflandt@xnet.com   http://www.xnet.com/~efflandt/
http://www.de-srv.com/   http://cgi-help.virtualave.net/


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

Date: Thu, 17 Jun 1999 01:12:41 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: simple quesiotn about array
Message-Id: <1dtiqde.xkfiwn1lvo4apN@p207.tc2.state.ma.tiac.com>

sydney qiu <sydney@netwave.ca> wrote:

> Hi, I am a beginner of perl. I basiclly teach myself from 
> -- 
> Time to get up and have a walk outside

When you get back, maybe you can post the rest of your message.

Enjoy your walk!

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Wed, 16 Jun 1999 21:25:19 -0800
From: John Iyezack <snapperhead_420@hotmail.com>
Subject: splitting an array into two arrays
Message-Id: <929597121.8474@www.remarq.com>

This is a dumb question.  I just got back into programming
two weeks ago.  The last time I programed was using Turbo
Pascal 5 :)

Ok, i'll get to the point.

I have a array index of about 40 values.  That are read in
from a file.  They have a - to split the differant parts of
it.  ie. part#-part descripation.  Now I would like to take
the array and split it into two separte arrays.  I thought
about multi-demensional arrays.  But, they wouldn't work
right.  I was going to put it into a loop becuase there are
over 40. It could even get up to around 200.  I am reading
it from a text file.  Becuase the contents of the file are
changing daily.
All help is appercaited!



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: Thu, 17 Jun 1999 03:10:35 -0400
From: brian@pm.org (brian d foy)
Subject: Re: splitting an array into two arrays
Message-Id: <brian-ya02408000R1706990310350001@news.panix.com>

In article <929597121.8474@www.remarq.com>, John Iyezack <snapperhead_420@hotmail.com> posted:

> I have a array index of about 40 values.  That are read in
> from a file.  They have a - to split the differant parts of
> it.  ie. part#-part descripation.  Now I would like to take
> the array and split it into two separte arrays.  I thought
> about multi-demensional arrays.  But, they wouldn't work
> right.

not sure what the end goal is, so this might not help you much:

   %hash = map { split /-/, $_, 2 } @parts;

   @numbers      = keys %hash;
   @descriptions = values %hash;

or something like

   @parts_is_parts = 
      map { [split /-/, $_, 2] } @parts;

   @numbers      = map { $_->[0] } @parts_is_parts;
   @descriptions = map { $_->[1] } @parts_is_parts;

or soemthing like

   foreach my $part (@parts)
      {
      my($number,$desc) = split /-/, $part, 2;

      push @numbers, $number;
      push @descriptions, $desc;
      }

or something like ...

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: 16 Jun 1999 20:34:47 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: SQL statement in Perl
Message-Id: <slrn7mgki1.ejb.abigail@alexandra.delanet.com>

paulm@dirigo.com (paulm@dirigo.com) wrote on MMCXV September MCMXCIII in
<URL:news:7k87td$joa$1@nnrp1.deja.com>:
 .. Not sure what your talking about, but a Perl script will run SQL if
 .. writen correctly!
 .. 
 .. I've used 1000 different SQL strings to try and get this working and
 .. none has worked.  I've tried brackets, quotes, I've even looked at how
 .. my queries are formatted in Access 97 and used the EXACT same string,
 .. but it still will not work.


This kind of contradicts your first statement, doesn't it?



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Thu, 17 Jun 1999 01:12:42 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Surprise with .. operator in list context
Message-Id: <1dtiqi2.1vua0sy1v8loyhN@p207.tc2.state.ma.tiac.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

> Why does 
> 
> ( chr( 0) .. chr( 26) )
> 
> produce a list of length 1, only containing chr( 0)?  Probably the
> ++ operator is a work behind the scenes, which doesn't work for
> non-alphanumerics.  Would someone know for sure?

You are absolutely correct.  The range operator .. uses the same magic
as auto-increment ++, which only works on alphanumeric characters.  This
is confirmed in the perlop documentation.

map chr($_), 0 .. 26


> -- 
> $_ = lc 'Trojan slut? Heck, rape her!'; tr/ .,;:'"?!()//d;
> print +( ' ', sort split '')
> [(9,21,18,19,0,1,12,13,20,7,4,15,0,14,5,16,11,0,8,2,3,10,6,17)], "\n";

How wonderfully tasteless.


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
perl -e '$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'


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

Date: 17 Jun 1999 07:17:27 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Surprise with .. operator in list context
Message-Id: <7ka7e7$9pt$1@lublin.zrz.tu-berlin.de>

Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote in comp.lang.perl.misc:
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
>> Why does 
>> 
>> ( chr( 0) .. chr( 26) )
>> 
>> produce a list of length 1, only containing chr( 0)?  Probably the
>> ++ operator is a work behind the scenes, which doesn't work for
>> non-alphanumerics.  Would someone know for sure?
>
>You are absolutely correct.  The range operator .. uses the same magic
>as auto-increment ++, which only works on alphanumeric characters.  This
>is confirmed in the perlop documentation.

Yes, Greg Bacon pointed this out too.  Sorry.

>map chr($_), 0 .. 26

Or, if you eventually want them in a string

pack 'C*', 0 .. 26

>> -- 
>> $_ = lc 'Trojan slut? Heck, rape her!'; tr/ .,;:'"?!()//d;
>> print +( ' ', sort split '')
>> [(9,21,18,19,0,1,12,13,20,7,4,15,0,14,5,16,11,0,8,2,3,10,6,17)], "\n";
>
>How wonderfully tasteless.

Agreed.

Anno


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

Date: Thu, 17 Jun 1999 01:12:43 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: what does this crypto script do?
Message-Id: <1dtir0b.1qlay6u1hnkds9N@p207.tc2.state.ma.tiac.com>

Simon Wistow <simon@profero.com> wrote:

> # this line has been commented out because I get a 
> # compile error but as far as I can see it's verbatim
> #$o=~s/.chr(($f*&e+ord($&)-13)%26+65)/eg;

'Tis verbatim.  That's a typo in the book, unfortunately.


Anyway, you must have missed the thread on this topic last month.
Here's the first post:

http://www.deja.com/getdoc.xp?AN=479746203


And here's the URL for the explanation of the code:

http://www.counterpane.com/solitaire.html

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 17 Jun 1999 06:30:11 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: What is functional difference between .pm and .pl?
Message-Id: <376b912b.3230743@news.skynet.be>

Abigail wrote:

>|| >I use .pl because that makes my editor jump into the appropriate mode. :)

>|| You did write, some while ago, that you "refused to program a christmas
>|| tree" (my paraphrase), didn't you?
>
>
>Yes, I did. What's your point?

Er, "syntax highlighting"?

	Bart.


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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