[10397] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3990 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 16 10:01:34 1998

Date: Fri, 16 Oct 98 07:00:31 -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           Fri, 16 Oct 1998     Volume: 8 Number: 3990

Today's topics:
    Re: Anyone for a Tyne+Wear.pm ?? <D.M.Barnard@ncl.ac.uk>
    Re: Camel Pub (was Re: Raleigh.pm has registered) <l.brocard@elsevier.nl>
    Re: Compile Perl on As400 ? lars.miettunen@mandator.se
    Re: database, need perl and cgi? jesten@wdynamic.com
    Re: Equivalent of "unload" after "require"? droby@copyright.com
        How can I read HTML file in another host?? <ajou2@hitel.net>
    Re: HOW DO I INCLUDE OTHER LIBRARIES IN PERL FOR NT SER <perlguy@technologist.com>
    Re: HOW DO I INCLUDE OTHER LIBRARIES IN PERL FOR NT SER <new_email@see.web.page>
    Re: Making perl function at all.... HELP! <perlguy@technologist.com>
    Re: Making perl function at all.... HELP! <oeselbek@online.no>
    Re: Mimicing 'tail -f' functionality in Perl (Mike Stok)
    Re: New to programming - New to Perl - LOST!!!! jesten@wdynamic.com
    Re: Newbie Loop Help <ckc@dmi.dk>
    Re: Perl Beautifier Home Page (Paul Murray)
        perl-program binary <dmitri@sw-systemekarlhickl.de>
    Re: perl-program binary <dmitri@sw-systemekarlhickl.de>
    Re: Set up FTP via Perl? <Savage.Ron.RS@bhp.com.au>
    Re: Sorry <ebohlman@netcom.com>
    Re: Sorry (Lee Brandson)
    Re: Sorry (Tad McClellan)
        Sorting hash arrays (John Horne)
    Re: Sorting hash arrays <matt@whiterabbit.co.uk>
    Re: Sorting hash arrays (Matthew Bafford)
    Re: Sorting hash arrays <J.Horne@plymouth.ac.uk>
    Re: The space deletion woes... <perlguy@technologist.com>
    Re: The space deletion woes... <rra@stanford.edu>
    Re: threaded Perl 5.005 on HP-UX 10.20 anyone? (Peter Michalica)
        values out of a routines <cousin@ensam.inra.fr>
        waitpid / crontab problem (Jo Holvoet)
        What are these? <aally@ia.pw.edu.pl>
    Re: What are these? <matt@whiterabbit.co.uk>
    Re: Win32::NetAdmin usage problem  gya@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 16 Oct 1998 13:15:48 +0100
From: David Barnard <D.M.Barnard@ncl.ac.uk>
Subject: Re: Anyone for a Tyne+Wear.pm ??
Message-Id: <707ddl$k5d$1@ucsnew1.ncl.ac.uk>

I am a Newcastle student.

I don't know Perl, but I am trying to change that.

(Actually, I'm an architecture student - don't tell anyone <g>)

Seriously, I am trying to learn what has been described (probably by Larry
Wall) as *the* most complex, hence difficult languages going.

David Barnard
D.M.Barnard@ncl.ac.uk




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

Date: Fri, 16 Oct 1998 12:08:35 +0000
From: Leon Brocard <l.brocard@elsevier.nl>
Subject: Re: Camel Pub (was Re: Raleigh.pm has registered)
Message-Id: <36273743.50C93749@elsevier.nl>

Uri Guttman wrote:

> maybe the menu could have camel burgers? and definitely some good
> cognacs besides the scotches.

Mmmm. Camel burgers. If anyone *does* start up this bar and start
experimenting, please report how the following tastes...

Stuffed Camel

      1 whole camel, medium size
      1 whole lamb, large size
      20 whole chickens, medium size
      60 eggs
      12 kilos rice
      2 kilos pine nuts
      2 kilos almonds
      1 kilo pistachio nuts
      110 gallons water
      5 pounds black pepper
      Salt to taste

Skin, trim and clean camel (once you get over the hump), lamb 
and chicken. Boil until tender. Cook rice until fluffy. Fry nuts 
until brown and mix with rice. Hard boil eggs and peel. Stuff 
cooked chickens with hard boiled eggs and rice. Stuff the cooked 
lamb with stuffed chickens. Add more rice. Stuff the camel with 
the stuffed lamb and add rest of rice. Broil over large charcoal 
pit until brown. Spread any remaining rice on large tray and 
place camel on top of rice. Decorate with boiled eggs and nuts. 
Serves friendly crowd of 80-100.

;-P, Leon

ps that camel bar in San Jose was euuuuuuuuuuuuugh.
-- 
Leon Brocard...............................................Perl Hacker
l.brocard@elsevier.nl...........................http://www.astray.com/

 ... Press any key...NO, NO, NO, NOT THAT ONE!!!!!!


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

Date: Fri, 16 Oct 1998 11:26:21 GMT
From: lars.miettunen@mandator.se
Subject: Re: Compile Perl on As400 ?
Message-Id: <707agt$1rd$1@nnrp1.dejanews.com>

In article <Pine.GSO.4.02A.9810151115350.26848-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@teleport.com> wrote:
> On Thu, 15 Oct 1998 lars.miettunen@mandator.se wrote:
>
> > Have anyone tried to compile Perl 5.004 or higher on an As400 ?
>
> I'm sure someone has tried. If not, then you should. :-)
>

Perhaps, perhaps not. I'm missing a c compiler as it is right now.
So I would have to buy one of those first you know. ( $$$$$$$$$$ )

/Lars

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 16 Oct 1998 13:11:06 GMT
From: jesten@wdynamic.com
Subject: Re: database, need perl and cgi?
Message-Id: <707gla$bri$1@nnrp1.dejanews.com>

In article <36261ABE.5468@csc.liv.ac.uk>,
  Elly <u6el@csc.liv.ac.uk> wrote:
> I wonder if anyone can help me...i am doing a project and I am having
> some
> problems.
>
> the project is for an online questionaire..at the moment the
> questionaire is in
> HTNL...and the information from the questionaire will be inputted into a
> database, I am thinking of using Access to creat the database, but do I
> need
> Perl program and CGI script??? what does perl do? so do i need, CGI,
> Perl amd
> Access to do it? what if I want to retrievel information from teh
> database....what do I use to do that?
>

What you can and want to do will largely be determined by what is available to
you web wise... Perl can interact with Access via the ODBC.pm module.  This
assumes you are webbing on the WinTel server, and have Perl and the ODBC.pm
module installed.

CGI scripts can do most anything you might think of a regular desktop program
doing.

If you don't expect the mass of data to run beyond a few thousand records,
you can probably get away with storing your results in a flat text file. I've
done dozens of low end apps using text files, advantage being they don't
require anything special on the server, so are highly portable. If unlimited
scalability is not a concern, this is probably a quicker option for you.

Jim

--
Jim Esten, Lead Developer, WebDynamic/
Applications Lead, StarQuest Internet Services

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 16 Oct 1998 13:11:50 GMT
From: droby@copyright.com
Subject: Re: Equivalent of "unload" after "require"?
Message-Id: <707gml$brt$1@nnrp1.dejanews.com>

In article <705h7u$iee$1@nnrp1.dejanews.com>,
>
> I'm not familiar with MLDBM... my hands are pretty much tied (I'd be doing
> this in C if my web host allowed it) so I'm trying not to add many "extras"
> and just make it run in out-of-the-box Perl. Is MLDBM something I could
> distribute with releases of my game to other systems?
>

It's a module available from CPAN that can be used to store complex data
structures in dbm files.  Within the constraints of the Artistic License, I
believe it can be redistributed.  You'd also need the Data::Dumper module,
which this module uses.

> At any rate, I found it more efficient to have code write code. If 20 players
> are in the game at the same time, more often than not they won't be directly
> relating to each other (in battle, or whatever) so the only info they need is
> their own info. It made more sense to have a save file "per-player" rather
> than one master file (which is what I'd always done in the BBS versions of
> this game before rewriting it for the web) because I can let one player
> center on one file instead of contantly accessing a master.
>

This one file could still be sensibly setup as a data file rather than code
though.  With this approach you wouldn't need anything as elaborate as MLDBM
- a text file would probably do nicely.

> As for the data coming from a CGI form, what does "-t" do? Is this an option
> for the Perl interpreter? I'm learning as I go. Nothing destructive posted
> through a form is going to end up in the player save files. I have functions
> that strip off HTML codes, reject invalid characters (dollar-signs, quotes,
> @-signs, backticks, tildes, etc) so the player won't be able to enter
> anything that ends up in the player save file that contains anything
> damaging.
>

"-T" turns on taint-checking, which is basically a way to force yourself to do
this kind of parsing of user input of data before using that data in ways that
could be dangerous.

For more info on this, look at the perlsec manpage and the CGI Security FAQ at
http://www.genome.wi.mit.edu/WWW/faqs/www-security-faq.html

> Re-writing the player save code wouldn't be a big deal, if I knew how to make
> it work (it's all centralized). As a (sigh) beginner still, I didn't see a
> way to lock portions of the file (and update only a single portion...
> fread/fwrite) so I opted to use multiple files instead. I bet most of this is
> twice as complicated as it needs to be simply because of my lack of Perl
> experience.
>

To be honest, I don't think there's a good record-locking mechanism available.
You could roll your own in the program if you know no other program will be
using the file, but it's a bit messy.  Locking whole files is at any rate much
easier.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 16 Oct 1998 21:43:04 +0900
From: ajou2 <ajou2@hitel.net>
Subject: How can I read HTML file in another host??
Message-Id: <36273F51.AC462E7C@hitel.net>

Hi~

I am trying to wite perl program that read HTML files in another host.
I heard, I must use 'socket'.... is right?

My first try is....
   open (FILE,"<./http://www.abc.com/~any/index.html")
but failed...  -.- (yes, i'm beginer)

I'll wite the perl-cgi that check the HTML syntex in another host.
Is it impossible? or possible?

Thabks to any information and script!

---
http://www.hitel.net/~ajou2/beta



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

Date: Fri, 16 Oct 1998 10:56:15 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: HOW DO I INCLUDE OTHER LIBRARIES IN PERL FOR NT SERVER???
Message-Id: <3627264F.3D637B79@technologist.com>

Stop shouting! (All caps indicates shouting...)

The easiest way, (for me), is to just put the whole path in the require
statement...

require "c:/inetpub/scripts/cgi-lib.pl";

Will work, or even:

$my_path = "c:/inetpub/scripts";
require "$my_path/cgi-lib.pl";

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


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

Date: 16 Oct 1998 05:51:08 PDT
From: "Phlip" <new_email@see.web.page>
Subject: Re: HOW DO I INCLUDE OTHER LIBRARIES IN PERL FOR NT SERVER???
Message-Id: <707ffs$ftr@journal.concentric.net>

Dan Miller wrote in message <36271395.F083C811@gte.net>...

>hi.  i just recently put perl on our nt server, and was wondering what
>the difference in syntax and keywords are between nt server and unix.
>i've been working with perl in the unix environment, and use the
>following code to include a library to use in the script:
>
>push(@INC, "/cgi-bin");

Everybody, I want you to take a good long look at what direction that /
points. It does not point \.

The above syntax will not work because, to IIS or WebSite Pro, / is the
root of the virtual directory tree. But PERL runs outside the HTTP
service's virtualization system, so it will look at the root of the
physical current drive.

But neither the HTTP service nor Win32 itself require \. The forward
slash / works everywhere except on a command line (and who uses those
any more?)

Put complete paths in your INC, and put them in outside your source so
the source itself is relocatable.

>require("cgi-lib.pl");
>
>&ReadParse(*input);

>could someone please tell me what the code is to include a library in
my
>script under the NT server??

No idea. I just let ActiveState's PPM.pm push PERL modules where it
will.

>one difference i've noticed is that the
>shabang (#!/usr/bin/perl) isn't needed to find the perl interpreter.

This is because the OS registers the PERL extension *.pl as both a
command-line extension and as an HTTP service CGI extension.

The first means if you write this on a command line:

    hello.pl

Or this on Win9x

    start hello.pl

the system will shell to "PERL hello.pl"

The second registration means when HTTP gets a GET for //server/hello.pl
it knows to pipe the .pl through PERL and return the output. That
"shabang" is for CGI that does not know until it reads the file what
will filter it.

  --  Phlip at politizen dot com                  (address munged)
======= http://users.deltanet.com/~tegan/home.html =======
  --  "Hank...your titles do continue to give me a throb of
       esoteric pleasure with their arcane plausibility
       playing in some esoteric pasture between geography
       and metaphysics."  -  Judson Crews  --




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

Date: Fri, 16 Oct 1998 10:32:26 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Making perl function at all.... HELP!
Message-Id: <362720BA.3D798233@technologist.com>

"Xystein Selbekk" wrote:
> 
> I wonder if anyone can help me on this one:
> 
> I am trying to make Perl 5.0 work on a IIS 4 server. This is the message i
> get when i try to execute a .pl script:
> 
> HTTP Error 403
> 
> 403.2 Forbidden: Read Access Forbidden

Try going to http://www.perl.com and click on the Windows NT link. 
There are many useful resources there that will most likely fix your
problem.

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


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

Date: Fri, 16 Oct 1998 13:01:21 +0200
From: "Xystein Selbekk" <oeselbek@online.no>
Subject: Re: Making perl function at all.... HELP!
Message-Id: <70792b$i5a$1@readme.online.no>

I tried that, but i didnt find anything about my problem. Does anyone know
how to find information about this message using www.perl.com?

Oystein





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

Date: 16 Oct 1998 13:42:35 GMT
From: mike@mike.stok.co.uk (Mike Stok)
Subject: Re: Mimicing 'tail -f' functionality in Perl
Message-Id: <707igb$h7n@news-central.tiac.net>

In article <706pgo$bo6$1@nnrp1.dejanews.com>,
 <john_aldiscon@my-dejanews.com> wrote:
>I would like to mimic the functionality of the 'tail -f' command that will
>allow me to view a text file while another process is added entries to it.
>This works great on log files to what is happening in real time. I am working
>on a Perl script that will be parsing through a debug file while it is being
>written to by an application. My problem is that I can't find a way to make
>the open() function keep the file open after reaching the EOF. This is in
>Perl v4. Any ideas?? Thanks!

If you have to use perl 4 then you can still go and look at the FAQ on
http://www.perl.com and see if its solution works under perl 4.  Perl is
amazingly backwards compatible...

perlfaq 5 includes:

  How do I do a tail -f in perl?

  First try

      seek(GWFILE, 0, 1);

  The statement seek(GWFILE, 0, 1) doesn't change the current position, but
  it does clear the end-of-file condition on the handle, so that the next
  <GWFILE> makes Perl try again to read something.

  If that doesn't work (it relies on features of your stdio implementation),
  then you need something more like this:

          for (;;) {
            for ($curpos = tell(GWFILE); <GWFILE>; $curpos = tell(GWFILE)) {
              # search for some stuff and put it into files
            }
            # sleep for a while
            seek(GWFILE, $curpos, 0);  # seek to where we had been
          }

  If this still doesn't work, look into the POSIX module.  POSIX defines the
  clearerr() method, which can remove the end of file condition on a
  filehandle.  The method: read until end of file, clearerr(), read some
  more.  Lather, rinse, repeat.

Perl 4.xxx doesn't have the POSIX module but the other solutions seem like
they might work.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Fri, 16 Oct 1998 13:05:53 GMT
From: jesten@wdynamic.com
Subject: Re: New to programming - New to Perl - LOST!!!!
Message-Id: <707gbh$bll$1@nnrp1.dejanews.com>

In article <hVnV1.16132$Gu6.279@news-reader.bt.net>,
  "Tim Hicks" <tim.hicks@iname.com> wrote:
---snip---

> so on.  I tried to download perl, but ended up getting a file with the
> extension tar.gz.  Unfortunately I have no idea what this is all about.
>
> To conclude, all I really want to do is install perl under win 95 and play
> around and see what I can do.  If anyone could point me in the right
> direction I'd really appreciate it.


Don't worry so much about the unix-isms. For what you are likely to try early
on , there won't be much difference.  As for that .tar.gz file, WinZip knows
all about those and should unpack it nicely. Once unpacked, the install will
walk you through the rest fairly well.	If you are willing to go an extra
mile up front, you may want to invest in the Win32 Perl Resource Kit.. the
price may seem a bit hefty if you aren't sure of yourself yet, but it has a
wealth of info, a completely visual install from CD, and lots of little
goodies you probably wouldn't think to retrieve yourself.

Jim

--
Jim Esten, Lead Developer, WebDynamic/
Applications Lead, StarQuest Internet Services

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 16 Oct 1998 10:45:16 +0100
From: Casper Kvan Clausen <ckc@dmi.dk>
Subject: Re: Newbie Loop Help
Message-Id: <Pine.GSO.3.92.981016104003.29201D-100000@edb>

On Thu, 15 Oct 1998, Matt Knecht wrote:

> Try this instead:
>
> # NOT TESTED

I'll say. I highly doubt that this code is helpful to the asker. (The
answer to his question, BTW, is "Get the cute owls and read it cover to
cover"--much the same as for other regex questions :)

Back to the code you posted:

> 	next if /^[\s#]*$/; # Skip comment and blanks

This should be "Skip lines consisting only of blanks and #'s". What you
wanted to say was this (I've split it out instead of using alternation in
order to improve readability):

next if (/^#/ or /^\s*$/); # Skip comments and blank lines

Kvan.

-------Casper Kvan Clausen------ | 'I haven't seen an Englishman take a
----------<ckc@dmi.dk>---------- |  blow like that since Hugh Grant!
           Lokal  544            |
I do not speak for DMI, just me. |        - Football announcer.



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

Date: 16 Oct 1998 13:20:00 GMT
From: murray-paul@usa.net (Paul Murray)
Subject: Re: Perl Beautifier Home Page
Message-Id: <slrn72ehvv.q0l.murray-paul@unix3.netaxs.com>

On Mon, 13 Jul 1998 16:03:48 -0400, brian d foy <comdog@computerdog.com> wrote:
>In article <35A87D71.1D8DBD36@halcyon.com>, Tim Maher <tim.maher@halcyon.com>
>>I've got my Perl Beautifier running, with a reasonable set
>>of default options, on
>>http://www.consultix.wa.com/yumpy/cgi-pvt/pbeaut.cgi.
>>It's been tested primarily with the 66 modules of the standard
>>Perl distribution, so I'm interested to see what happens when
>>it's confronted with other programming styles.
>>Please help me test it by whipping some of your code at
>>it!  I'll be Emailed any syntax errors that my beautifier
>>introduces, which could help me improve it, prior to making
>>it more generally available.
>some oddities i noticed:
[snip]
>   * it turns $obj->method into $obj -> method.

Worse, it turns:
$global->{'cancelNOW'} = 1 ;
into:
$global ->		
{			
	'cancelNOW'		
}		
= 1;

And even with 'Brace with keyword' on, it turns:
$global->{'mw'}->{'topframe'} = $global->{'mainwindow'}->Frame;
into:
$global -> {	
	'mw'
}-> {
	'topframe'
}
= $global -> {
	'mainwindow'
}
-> Frame;

-Paul Murray


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

Date: Fri, 16 Oct 1998 11:31:57 +0200
From: Dmitri Levitin <dmitri@sw-systemekarlhickl.de>
Subject: perl-program binary
Message-Id: <3627128D.25DD00C5@sw-systemekarlhickl.de>

Hi,

how can I produce a binary file from my perl program? I've heard it must
be possible since version 5.00...
I would like to have a perl script with s-bit set.

Thanks in advance
Dmitri



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

Date: Fri, 16 Oct 1998 14:18:28 +0200
From: Dmitri Levitin <dmitri@sw-systemekarlhickl.de>
Subject: Re: perl-program binary
Message-Id: <36273994.558B5BE0@sw-systemekarlhickl.de>

Dmitri Levitin wrote:

> Hi,
>
> how can I produce a binary file from my perl program? I've heard it must
> be possible since version 5.00...
> I would like to have a perl script with s-bit set.
>
> Thanks in advance
> Dmitri

  May be i have badly explained what i need. (My english isn't very
good...). Once more.
I would like my users on unix SysV to be able to run my Perl-script with
set -UID. This means i must set s-bit to my Perl-script and i can make this
only if the script is compiled to a binary code. That's why i need
something like 'c-compiler' for perl.

Thanks again
Dmitri



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

Date: 16 Oct 1998 06:16:43 GMT
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: Set up FTP via Perl?
Message-Id: <01bdf8cd$54353840$77ea1286@steelres-pcm657.resmel.bhp.com.au>

#!/usr/gnu/bin/perl -w
#
# Name:
#	putBinFromMySite.pl.

use integer;
use strict;

use Net::FTP; 

my($fileName) = $ARGV[0];
die("$fileName: No such file") if (! -e $fileName);

my($ftp) = Net::FTP -> new('ftp.your.site');	# Fix.
print $ftp -> message(), "\n";

$ftp -> login('anonymous','me@my.site');	# Fix.
print $ftp -> message(), "\n";

$ftp -> cwd('incoming');	# Fix.
print $ftp -> message(), "\n";

$ftp -> binary();
print $ftp -> message(), "\n";

print "Putting $fileName\n";
$ftp -> put($fileName);
print $ftp -> message(), "\n";

print join("\n", $ftp -> dir() ), "\n";
print $ftp -> message(), "\n";

$ftp -> quit();

# Success.
exit(0);

-- 
Ron Savage
Home (preferred): rpsavage@ozemail.com.au
Office: Savage.Ron.RS@bhp.com.au
http://www.ozemail.com.au/~rpsavage

mostoc <mostoc@mail.mankato.msus.edu> wrote in article
<7067d6$90k$1@nitrogen.mankato.msus.edu>...
> I know you can do this, I just don't know how.  Can somebody help me?
> 
> Chad Moston
> 
> 
> 


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

Date: Fri, 16 Oct 1998 11:31:03 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Sorry
Message-Id: <ebohlmanF0x3zr.7nt@netcom.com>

Larry Wall <larry@kiev.wall.org> wrote:
: In article <362627ED.C42390AC@min.net>, John Porter  <jdporter@min.net> wrote:
: >Larry Wall wrote:
: >> 
: >> Perl is worse than Python because people wanted it worse.
: >
: >Meaning "wanted it more badly", I take it?

: I intended you to take it however you like.  :-)

A sportscaster once commented about a football player who was playing 
without having adequately recovered from an injury: "He wants to play in 
this game in the worst way possible, and that's exactly what he's doing."



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

Date: Fri, 16 Oct 1998 07:44:13 -0600
From: rlb@intrinsix.ca (Lee Brandson)
Subject: Re: Sorry
Message-Id: <rlb-1610980744300001@204.112.166.151>

In article <1dgyuxt.1s9yanzvwev18N@bos-ip-1-106.ziplink.net>,
rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:

> [posted and mailed]

Why? Posting was sufficient.

> Lee Brandson <rlb@intrinsix.ca> wrote:
> 
> > As an occasional watcher of this ng and its predecessor for some two years
> > now, I would like to ask whether it is strictly necessary to be as rude as
> > possible when answering (or not answering, as the case may be) a question?
> > Is this what it takes to be "in the club?
> 
> If you were more than an "occasional" watcher of this ng and its
> predecessor, then you would know that this very question has been asked
> numerous times.  No, it's not in the FAQ.  That's probably because there
> is no agreed upon answer; instead it just leads to another drawn-out
> debate between people who are unlikely to be convinced to change their
> own opinion on the matter.

The question was not the topic of my comment. I was addressing the nature
of the reply. More generally, I was addressing the general tone of replies
throughout this ng. This is not say that all replies are rude, dismissive,
insulting, quarrelsome... but opportunities for such replies are seldom
overlooked.
 
> > Do you enjoy the unending long threads of justifications for such rudeness?
> 
> Oh, apparently you do know.  No, I don't enjoy the threads.  And thank
> you *so much* for starting yet one more!

I did not start it. I merely jumped in to suggest that a polite reply
would have all of the benefits and none of the unfortunate side effects of
a rude reply.

Lee Brandson


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

Date: Thu, 15 Oct 1998 23:04:46 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Sorry
Message-Id: <ukg607.jio.ln@flash.net>

Will (wcoarseyREMOVETHIS@gate.net) wrote:

: Lee Brandson wrote in message ...
: >In article <ona207.tnf.ln@flash.net>, tadmc@flash.net (Tad McClellan)
: wrote:

   I did not write any of the below.

   The attribution is in error.


: >As an occasional watcher of this ng and its predecessor for some two years
: >now, I would like to ask whether it is strictly necessary to be as rude as
: >possible when answering (or not answering, as the case may be) a question?
: >Is this what it takes to be "in the club?" Do you enjoy the unending long
: >threads of justifications for such rudeness?


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 16 Oct 98 10:05:31 GMT
From: J.Horne@plymouth.ac.uk (John Horne)
Subject: Sorting hash arrays
Message-Id: <36271a6b.0@palantir.pbs.plym.ac.uk>

I'm trying to sort the values of a hash array, but still retain the
'link' between the value and the key. The perl FAQ doesn't say
much about this except that generally there is only sorting the
keys or sorting the values. Sorting the keys will still allow me
access to the values, but vice-versa isn't true. The problem is
actually to do with stats of our web server - I'm trying to
determine which pages have been hit the most, as well as which
domains are doing the hitting(?). These are kept in 2 hash arrays-
one of which basically states: 

   $page_count{$page}++;   whenever an HTML page has been hit

So, how do I find out (and display) which pages have been hit
the most?
The only way I can think of doing this is to create 2 arrays (non-
associative) with a common index. One array contains the page name,
the other the count. Sort the count array, and then loop through
the pages matching the counts - when found pus hon to a new array.
hopefully (it still has to be tested) I'll end up with 2 arrays
in sync with each other, and having a common index.

Before re-inventing the wheel, (a) is there a module for this? I 
couldn't find one, (b) is there a better way? I feel sure there
must be with sort/map or somesuch, or (c) am I being really dumb
here and missing something obvious? (Highly possible! :-))

Any help much appreciated,

John.
-----------------------------------------------------------------------------
John Horne                                     E-mail: J.Horne@plymouth.ac.uk
Academic and Information Services              Phone :  +44 (0) 1752 - 233911
University of Plymouth, UK                     Fax   :  +44 (0) 1752 - 233919


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

Date: Fri, 16 Oct 1998 13:01:54 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: John Horne <J.Horne@plymouth.ac.uk>
Subject: Re: Sorting hash arrays
Message-Id: <362735B2.68D5F5CA@whiterabbit.co.uk>

Hi John,

If you were to store the names of the referring documents in an
associative array using the domain name as a key, separated by a |
delimiter, like so:

$referrers{"mydomain.com"} 	=
"www.microsoft.com|www.netscape.com|www.yahoo.com";

Then you could split them up in turn:

$page_count{"mydomain.com"}++;  # is now 5 zillion
@domains = sort {$b <=> $a} values{%page_count};
foreach (@domains) {
	print "Domain name: $_<BR>";
	print "Total hits: $page_count{$_} - listed below.<BR>";
	@referrers = split (/\|/,$referrers{$_});
	foreach (@referrers) {
		$times{$_}++;
	}
	@referrers = sort ($b <=> $a) values(%times);
	foreach (@referrers) {
		print "$_ : $times{$_} referrals.<BR>";
	}
}

I haven't debugged this, and can't promise there's no typos in it!

I'm also intrigued to know if there is a more efficient way.

Matt
--







John Horne wrote:
> 
> I'm trying to sort the values of a hash array, but still retain the
> 'link' between the value and the key. The perl FAQ doesn't say
> much about this except that generally there is only sorting the
> keys or sorting the values. Sorting the keys will still allow me
> access to the values, but vice-versa isn't true. The problem is
> actually to do with stats of our web server - I'm trying to
> determine which pages have been hit the most, as well as which
> domains are doing the hitting(?). These are kept in 2 hash arrays-
> one of which basically states:
> 
>    $page_count{$page}++;   whenever an HTML page has been hit
> 
> So, how do I find out (and display) which pages have been hit
> the most?
> The only way I can think of doing this is to create 2 arrays (non-
> associative) with a common index. One array contains the page name,
> the other the count. Sort the count array, and then loop through
> the pages matching the counts - when found pus hon to a new array.
> hopefully (it still has to be tested) I'll end up with 2 arrays
> in sync with each other, and having a common index.
> 
> Before re-inventing the wheel, (a) is there a module for this? I
> couldn't find one, (b) is there a better way? I feel sure there
> must be with sort/map or somesuch, or (c) am I being really dumb
> here and missing something obvious? (Highly possible! :-))
> 
> Any help much appreciated,
> 
> John.
> -----------------------------------------------------------------------------
> John Horne                                     E-mail: J.Horne@plymouth.ac.uk
> Academic and Information Services              Phone :  +44 (0) 1752 - 233911
> University of Plymouth, UK                     Fax   :  +44 (0) 1752 - 233919

-- 
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons


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

Date: Fri, 16 Oct 1998 08:02:54 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Sorting hash arrays
Message-Id: <MPG.1090fff7133cd9669896dc@news.scescape.net>

In article <<36271a6b.0@palantir.pbs.plym.ac.uk>>, 
J.Horne@plymouth.ac.uk (John Horne) pounded the following:
=> [SNIP]
=> domains are doing the hitting(?). These are kept in 2 hash arrays-
=> one of which basically states: 
=> 
=>    $page_count{$page}++;   whenever an HTML page has been hit
=> 
=> So, how do I find out (and display) which pages have been hit
=> the most?
=> [SNIP]

I may be misunderstanding you, but how about:

my @sorted = sort {
    $page_count{$b} <=> $page_count{$a}
} keys %page_count;

=> John.

Hope This Helps!

--Matthew


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

Date: Fri, 16 Oct 1998 13:23:38 +0100 (BST)
From: John Horne <J.Horne@plymouth.ac.uk>
Subject: Re: Sorting hash arrays
Message-Id: <XFMail.981016132338.J.Horne@plymouth.ac.uk>

On 16-Oct-98 at 11:44:29 David Alan Black wrote:
> In comp.lang.perl.misc you write:
> 
>>I'm trying to sort the values of a hash array, but still retain the
>>'link' between the value and the key. The perl FAQ doesn't say
> [...snipped...]
> 
>>   $page_count{$page}++;   whenever an HTML page has been hit
> 
>>So, how do I find out (and display) which pages have been hit
>>the most?
> 
> Here's one approach.  Note that the sort routine uses the keys to get
> at the values - pretty much what hashes are best for :-)
> 
> print map { "$_: $pc{$_}\n" } sort { $pc{$a}<=>$pc{$b} } keys %pc;
> 
Thanks for this! I knew there must be a better way :-) I'll give
it a go.

>>The only way I can think of doing this is to create 2 arrays (non-
>>associative) with a common index. One array contains the page name,
>>the other the count. Sort the count array, and then loop through
>>the pages matching the counts - when found pus hon to a new array.
>>hopefully (it still has to be tested) I'll end up with 2 arrays
>>in sync with each other, and having a common index.
> 
> Yikes!  Don't do that.  Keep that one in the "untested" file :-)
> 
Too late. The whole thing boiled down to about 7 or 8 lines of code,
with multiple loops. It worked, but performance was probably a bit
yuck - I only did a small test. Still nice to know that I can do it by
brute force if I have to.

> By the way, there's no such term as "hash array".  There's array,
> associative array, and hash.  The latter two are synonymous, with
> "hash" being more canonical at this point.
> 
Blush :-*  Thanks for the pointer too :-)

John.

-----------------------------------------------------------------------------
John Horne                                     E-mail: J.Horne@plymouth.ac.uk
Academic and Information Services              Phone :  +44 (0) 1752 - 233914
University of Plymouth, UK                     Fax   :  +44 (0) 1752 - 233919



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

Date: Fri, 16 Oct 1998 10:38:58 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: The space deletion woes...
Message-Id: <36272242.DBB8D850@technologist.com>

Ronald J Kimball wrote:
> 
> Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
> 
> > =~ s/\s+?//g;
> 
> Useless use of non-greedy matching.  That will never match more than one
> space, because it never has a reason to.
> 
> Here's a good rule of thumb: non-greedy matching is *never* useful when
> it is the last thing in the regex.
> 
> $_ = 'foo   bar   baz';
> 
> s/\s+?/++$x/ge;
> 
> print;
> __END__
> 
> foo123bar456baz
> 

=~ s/\s+?//g; works fine for me.

I was under the impression that Perl regex's were _greedy_ unless you
used the ?: operator to make them non-greedy...

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


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

Date: 16 Oct 1998 03:54:50 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: The space deletion woes...
Message-Id: <ylsogodbet.fsf@windlord.stanford.edu>

Brent Michalski <perlguy@technologist.com> writes:

> =~ s/\s+?//g; works fine for me.

It's not a question of it not working.  It's a question of it being
completely and absolutely equivalent to =~ s/\s+//g except that it's
slower.

> I was under the impression that Perl regex's were _greedy_ unless you
> used the ?: operator to make them non-greedy...

You're correct, but that's irrelevant in this case since both the greedy
and the non-greedy versions do the same thing.  The greedy version just
whacks a whole sequence of whitespace at once, whereas the non-greedy
version gets one character at a time.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 16 Oct 1998 13:53:26 GMT
From: peter_michalica@hp.com (Peter Michalica)
Subject: Re: threaded Perl 5.005 on HP-UX 10.20 anyone?
Message-Id: <707j4m$rt3$1@ocean.cup.hp.com>

In article <360E4DA3.FE48CF36@signal7.de>, krueger@signal7.de says...
>
>
>--------------2CAEB83C5688059C04357276
>Content-Type: text/plain; charset=iso-8859-1
>Content-Transfer-Encoding: 8bit
>
>Hi,
>
>has anyone managed to compile a threaded Perl 5.005 on HP-UX 10.20 ?
>If so, I would be interested in the steps that were necessary to achieve
>this,
>since I'm having problems getting there.
>
>Robert

Yes, it works fine, although a correction in one HP-UX pthread include
files is required:

Here are the steps I performed:

 ./Configure -Dusethreads

Next add -DOLD_PTHREADS_API to ccflags in "config.sh"
and "-ldce -lc_r" to the end of "libs".

Now when you run "make" the compile fails for source file "utils.c".
The reason is that perl.h includes <pthread.h> which includes <dce/cma.h>
which includes <dce/cma_px.h>. There at line 126 it says:

#define sigaction cma_sigaction

I believe this is a bug, since it will not only replace the sigaction()
function but also all definitions of "struct sigaction ...".
I replaced the above define in <dce/cma_px.h> with the following:

#define sigaction(a,b,c) cma_sigaction(a,b,c)

Now perl compiles without any problems and threads work fine (at least the
few examples I have ;-).

Regards,

Peter Michalica
HP Austria




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

Date: Fri, 16 Oct 1998 10:39:39 +0000
From: Xavier Cousin <cousin@ensam.inra.fr>
Subject: values out of a routines
Message-Id: <3627226B.42522903@ensam.inra.fr>

Hello, first of all sorry for the subject, it's sometimes hard to be
precise in some words...


Here is my problem in the following script "writing 2" allow printing of
the result while "writing 1" does not. I can't find any reason.
Somedbody could give me some indications ?


script :

NB1 I use writing 1 OR 2
NB2 In the original script, there is several routines to call 

open (IN,essai_automat); 
while (<IN>){
    if ($_ !~ /^\"/){
	$une_table = "non";
	$c=0;
    }
    if ($une_table eq "oui"){
        $passe = $_;

	&$rout($passe);				#writing 1 
	&distribution_des_champs1($passe);	#writing 2

    }
    if ($_ =~ /acedb\>/){
	$une_table = "oui";
	$table ++;
	$rout="distribution_des_champs".$table;

	&$rout($premiere_ligne); 			#writing 1
	&distribution_des_champs1($premiere_ligne); 	#writing 2

    }
}

foreach $key (sort keys %Molec){	# OK with writing 2 but
    print STDOUT "Molec $d $key\n";	# not with writing 1 in case
}					# 1 %Molec seams to not exist


sub distribution_des_champs1 {
    my ($entree) = @_;
    ($molec,$kin)=split /\t/,$entree;

    $Molec{$molec} = $molec;
    $kin{$molec} .= "$kin#";
}


Thanks for your answer(s).

Xavier

-- 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Xavier Cousin                     cousin@ensam.inra.fr

    INRA - DCC                        tel. (33) 04 99 61 28 14
    2, place Pierre Viala             fax  (33) 04 67 54 56 94
    34060 Montpellier Cedex 1

    ESTHER URL http://www.ensam.inra.fr/cholinesterase/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Fri, 16 Oct 1998 13:58:54 GMT
From: Jo.Holvoet@barclab.com (Jo Holvoet)
Subject: waitpid / crontab problem
Message-Id: <36274f9d.24815318@192.168.1.151>

Hi all,

I'm having a problem with a problem with a Perl program that behaves
differently when run from crontab than it does when run from the
command line. I've managed to reproduce the problem with the following
code snippet :

#!/usr/bin/perl
use POSIX "sys_wait_h";

print "Forking and waiting for PID:\n";
if (pipe(PR,PW)) {
 $pid = fork();
 if ($pid == 0 ) { #child
    ## call exec of any program ;-)
    exec("/home/ycarlier/crontab/faxcover.pl");
    exit(100);   #not reached
 }
 ##parent
 close(PW);
 while ($line=<PR>) {
    print "PA: read $line";
 }
 close(PR);
 print "PA: waiting for child $pid to finish...\n";
 $waitpid = waitpid($pid,0);
 print "PA: waitpid() exit with $waitpid : $!\n";
 
}
else {
  print STDERR "ERR: unable to open pipe to subprocess!\n";
}
exit 0;

The waitpid call should return the pid of the child but when run from
the crontab it always returns -1.

Any idea what the problem is ?

Many TIA,

Jo

PS : this is on RedHat 5.0 and Perl 5.004_04


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

Date: Fri, 16 Oct 1998 12:20:22 +0100
From: Abdallah Ally <aally@ia.pw.edu.pl>
Subject: What are these?
Message-Id: <36272BF6.7C47DDCC@ia.pw.edu.pl>

What are these foo,qw and how should I use command shift


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

Date: Fri, 16 Oct 1998 12:29:53 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: Abdallah Ally <aally@ia.pw.edu.pl>
Subject: Re: What are these?
Message-Id: <36272E30.9D6A95E9@whiterabbit.co.uk>

Foo is a generic value for a scalar variable.  Part of foobar.
qw precedes a list of Quoted Words in a list context.

shift is used like so as a function:

@list = qw {
	foo
	bar
	pants
	fire
	};

$first = shift(@list);  # $first is now "foo".
It takes out the first element in a list array and returns the value.

If no list is specified, shift works on @_ instead.  Useful for passing
just one argument to a subroutine:

$argument = shift;

HTH

Matt
--





Abdallah Ally wrote:
> 
> What are these foo,qw and how should I use command shift

-- 
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons


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

Date: Fri, 16 Oct 1998 13:35:25 GMT
From: gya@my-dejanews.com
Subject: Re: Win32::NetAdmin usage problem 
Message-Id: <707i2t$eh8$1@nnrp1.dejanews.com>

Hi,
	Thank you Michal for your advice. I have now installed
the ActiveState Perl release ( Build 502 ) on my NT4 P.C. but
unfortunately I still have a problem .. well two actually. Both
problems can be seen in the example given below.

	1: When using NetAdmin as in the first attempt why does
	   the command fail but no error appears in $!

	2: When using the same NetAdmin but with eval as in the
	   second attempt I get a usage error in $@. As far as I
	   can tell I am using the package correctly. If not can
	   anyone see what I am doing wrong and set me right.

Example code follows

	The Perl script is :

use Win32::NetAdmin qw(UserGetAttributes) ;

# Set up parameters
$username = 'gya';

# First attempt Win32::NetAdmin::UserGetAttributes('',$username, $Getpassword
,$Getpasswordage ,$Getprivilege ,$Gethomedir ,$Getcomment ,$Getflags
,$Getscriptpath ); print "The first error returned is \n", $!, "\n";

# Second attempt eval "Win32::NetAdmin::UserGetAttributes('',$username,
$Getpassword ,$Getpasswordage ,$Getprivilege ,$Gethomedir ,$Getcomment
,$Getflags ,$Getscriptpath ) "; print "The second error returned is \n", $@,
"\n";


	And it executes with the following :

C:\PERL\YBS\TEST\NETWORK>net_test
The first error returned is

The second error returned is Usage:
Win32::NetAdmin::UserGetAttributes(server, userName, password, passwordAge,
privile ge, homeDir, comment, flags, scriptPath)

Hopefully gya

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

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

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