[11819] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5419 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 19 13:12:34 1999

Date: Mon, 19 Apr 99 10:00:19 -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           Mon, 19 Apr 1999     Volume: 8 Number: 5419

Today's topics:
    Re: Adding TCPIP # (Randal L. Schwartz)
    Re: Any software convert html code into perl code?? (Randal L. Schwartz)
        Can i use  Apache HTTP Server v1.3.6   to run cgi and A (Kevin !;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;)
    Re: Can i use  Apache HTTP Server v1.3.6   to run cgi a <gellyfish@gellyfish.com>
    Re: FAQ 3.7: Is there a pretty-printer (formatter) for  (Mike Wescott)
    Re: How to execute script on server startup <cassell@mail.cor.epa.gov>
    Re: Making a hash of 2-D and 3-D Associative Arrays (Mike Stok)
    Re: Need example <gellyfish@gellyfish.com>
    Re: Need example <dgris@moiraine.dimensional.com>
        New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
        newbie help need on environment variables <lee@old-chapel.demon.co.uk>
    Re: newbie help need on environment variables (Larry Rosler)
        Number of elements of a hash table <fabascal@gredos.cnb.uam.es>
    Re: Number of elements of a hash table <tchrist@mox.perl.com>
    Re: Number of elements of a hash table <gellyfish@gellyfish.com>
    Re: pack format control string help <Michael.Cameron@no.spam.technologist.com>
        Perl pipe under OS/2 broken? <ibelgaufts@gfc-net.de>
        Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
    Re: strange problem with fork() (M.J.T. Guy)
    Re: TPJ still shipping? <revjack@radix.net>
    Re: umask <arnee@geocities.com>
    Re: Using a Regexp <renfro@i-55.com>
    Re: VB and Perl <aqumsieh@matrox.com>
    Re: Viewing a spreadsheet? (Leo Schalkwyk)
    Re: why won't this statement work @array=<*.*> <haakon.alstadheim@sds.no>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 19 Apr 1999 08:49:50 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Adding TCPIP #
Message-Id: <m1d810lie9.fsf@halfdome.holdit.com>

>>>>> "Matthew" == Matthew Bafford <dragons@dragons.duesouth.net> writes:

Matthew> On Mon, 19 Apr 1999 14:21:27 +0930, Wyzelli <wyzelli@yahoo.com>
Matthew> lucked upon a computer, and thus typed in the following:
Matthew> ) A sample of the file to be parsed is below.
Matthew> ) 
Matthew> ) Wed Mar 31 18:10:17 1999
Matthew> )  Acct-Session-Id = "0F00007B"
Matthew> )  User-Name = "user"
Matthew> )  NAS-IP-Address = 203.39.3.130
Matthew> )  NAS-Port = 5
Matthew> )  NAS-Port-Type = Async
Matthew> )  Acct-Status-Type = Stop
Matthew> )  Acct-Session-Time = 12
Matthew> )  Acct-Authentic = RADIUS
Matthew> )  Connect-Info = "48000 MNP/NONE"
Matthew> )  Acct-Input-Octets = 2329
Matthew> )  Acct-Output-Octets = 8
Matthew> )  Called-Station-Id = "89461300"
Matthew> )  Acct-Terminate-Cause = User-Request
Matthew> )  Vendor-Specific = ""
Matthew> )  Service-Type = Framed-User
Matthew> )  Framed-Protocol = PPP
Matthew> )  Framed-IP-Address = 203.39.3.170
Matthew> )  Acct-Delay-Time = 0
Matthew> )  Timestamp = 922869617
Matthew> )  Request-Authenticator = Unverified

Matthew> Having just had to work with this same log file, here's what I used:

Matthew> $/="";
Matthew> while (<>) {
Matthew>     chomp;
Matthew>     my ($date, $rest) = split /\n/, $_, 2;
Matthew>     my(%fields) =
Matthew>         map { s{^"}{};   s{"$}{};   $_ }
Matthew>         map { s{^\s+}{}; s{\s+$}{}; $_ }
Matthew>         map { split /=/                }
Matthew>         split /\n/, $rest;              

Matthew>     # ...
Matthew> }

Matthew> This lets you access each field using the hash.

Matthew> my $user = $fields{'User-Name'};

This is wayyyy too much work.  How about instead:

$/ = "";
while (<>) {
  s/(.*)\n// or die;
  my $date = $1;
  my %fields = /^\s*(\S+) = (".*"|\S+)/gm; # parse lines
  for (@fields{keys %fields}) { s/"(.*)"/$1/; } # pop quotes
  # ...
}

Hmm.  That'd be a good upcoming magazine column.  Cool!
>>todo

print "Just another Perl hacker (and columnist),"

-- 
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: 19 Apr 1999 08:39:39 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Any software convert html code into perl code??
Message-Id: <m1hfqcliv8.fsf@halfdome.holdit.com>

>>>>> "Kevin" == Kevin !;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!; <austin95002887@yahoo.com> writes:

Kevin> Any software convert html code into perl code??

Well, one of my recent WebTechniques columns (archived at
<URL:http://www.stonehenge.com/merlyn/WebTechniques/>) shows how to
convert HTML to an equivalent CGI.pm HTML-generator calls.  That might
be what you are looking for. Then again, maybe it won't be. :)

print "Just another Perl hacker,"

-- 
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: Mon, 19 Apr 1999 15:16:08 GMT
From: austin95002887@yahoo.com (Kevin !;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;)
Subject: Can i use  Apache HTTP Server v1.3.6   to run cgi and ASP in Win 95 ??
Message-Id: <1103_924534968@austin>



Can i use  Apache HTTP Server v1.3.6   to run cgi and ASP in 
Win 95 ??

HE and SHE - %L )M &o  :
======================
http://start.cgirealm.com/heshe1/



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

Date: 19 Apr 1999 16:54:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Can i use  Apache HTTP Server v1.3.6   to run cgi and ASP in Win 95 ??
Message-Id: <371b51c5@newsread3.dircon.co.uk>

Kevin !;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!; <austin95002887@yahoo.com> wrote:
> 

You appear to have some strange characters in your header.
> 
> Can i use  Apache HTTP Server v1.3.6   to run cgi and ASP in 
> Win 95 ??
> 

Yes,No ask in comp.infosystems.www.servers.ms-windows

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: 19 Apr 1999 11:12:23 -0400
From: wescott@cygnus.ColumbiaSC.NCR.COM (Mike Wescott)
Subject: Re: FAQ 3.7: Is there a pretty-printer (formatter) for Perl?  
Message-Id: <x4n204hcfc.fsf_-_@cygnus.ColumbiaSC.NCR.COM>

In article <37196578@cs.colorado.edu> Tom Christiansen <perlfaq-suggestions@perl.com> writes:
> Tom swears by the following settings in vi and its clones:
>     set ai sw=4
>     map ^O {^M}^[O^T

Make that

      map! ^O {^M}^[O^T

-- 
	-Mike Wescott
	 mike.wescott@ColumbiaSC.NCR.COM


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

Date: Mon, 19 Apr 1999 09:47:56 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to execute script on server startup
Message-Id: <371B5E3C.15CBE8EF@mail.cor.epa.gov>

Did you know that you send duplicate posts to the newsgroup?  Please be 
more careful next time.  Thank you.

kellykross@my-dejanews.com wrote:
> 
> I have a site that runs on a Apache/1.3.1 Cobalt (Unix) server. I would like
> to know if it is possible to have a CGI script execute on startup and remain

This really isn't a Perl question as stated.  Have you asked in one of 
the Apache newsgroups?  Or in one of the CGI newsgroups?

That said, you have not given us enough information to answer your
question.

Do you want to run a daemon on someone else's machine?  That can 
certainly be done in Perl.  But *should* you be running such a thing on
someone else's machine without their explicit permission?  Let me put
that
another way.  Would you let someone you didn't know come over and run a
secret program on your machine, running all the time, with only his/her
word that: (1) it wasn't harmful; (2) it wouldn't capture passwords or
violate your privacy in any way; and (3) it was so well-written that you
would never have to worry about it crashing your system or corrupting
your
data?  I thought not.

Or do you want to arrange it so that Perl is running 'continuously' on
that server, for better performance of a website?  That *is* a Perl
question.  But it is site-specific.  The answer is 'yes'.  But the
details depend on the OS and the web-server.

> present. I share space on this server. The site Admin isn?t the helpful type

Running stuff behind his/her back will certainly not make your sysadmin
any more helpful in future.  Instead, try buying him/her a coffee and
talking to him/her as if you were interfacing with a human.

> if possible I would like to enable this myself. I?ve tried to execute the
> program from browser and telnet command line but it appears to terminate when

Yes, it's supposed to do that.  You have to write a program that can
detach from your shell.  But that can be done in *any* decent language.

> exiting or logging off. P.S The script is designed to continuously monitor
> files in a directory.

Why?  Wouldn't it be enough to check now and then?
 
> Thanks in advance for any help.
> Kelly Kross

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Mon, 19 Apr 1999 15:20:16 GMT
From: mike@mike.stok.co.uk (Mike Stok)
Subject: Re: Making a hash of 2-D and 3-D Associative Arrays
Message-Id: <QQHS2.104$by.6855@typhoon.austin.rr.com>

In article <924525588.22136.1.nnrp-07.9e98e5bc@news.demon.co.uk>,
Clyde Ingram <cingram@pjocs.demon.co.uk> wrote:
>awk provides a simple mechanism for building and traversing
>multi-dimensional associative arrays.  I would like to do the same in perl.

>where SUBSEP is a built-in variable defaulting to "\034", a value unlikely
>to appear in normal text.
>
>So looping over the array is as simple as:
>
>    for (k in peopleArr) {
>        split(k, x, SUBSEP)
>        name = x[1]
>        town = x[2]
>        ...

Perl has a way of doing what awk does,

  $peopleArr{$name, $town} = 'whatever';

will generate a key value pair in %peopleArr where the key is
"$name\034$town" and the value is 'whatever'.  The \034 is kept in the
perl variable $; (which is called $SUBSEP amongst other things if you use
the English module, check out the perlvar manual page using perldoc or man
for more info)

Perl 5 introduced references to perl, so you could store references to
other data structures in array and hash elements.  This allows the
reasonable emulation of multidimensional arrays.

A way to make things which act like multidimensional arrays might be

  $peopleArr{$name}{$town} = $value;

and then iterate over it using something like

  foreach $name (sort keys %peopleArr) {
      foreach $town (sort keys %{$peopleArr{$name}}) {
          print "value for $name $town is $peopleArr{$name}{$town}\n";
      }
  }

One thing you might find helpful is to use perl's debugger to examine data
structures from the perldsc documentation.  The debugger is described in
the perldebug docs.

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
                                   |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 19 Apr 1999 17:03:48 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Need example
Message-Id: <371b53e4@newsread3.dircon.co.uk>

Uri Guttman <uri@home.sysarch.com> wrote:
>>>>>> "J" == Jim  <jim@newglobal.net> writes:
> 
>   J> In the mean time, KMA!
> 
> sorry, we are unable to comply with your request since your rectum is
> being occupied by your cranium.
> 

I was wondering what he meant by that ;-}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: 19 Apr 1999 10:45:11 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Need example
Message-Id: <m3pv50d0fc.fsf@moiraine.dimensional.com>

Jim <jim@newglobal.net> writes:

> Well, let's see...Forms > cgi > perl.

No.  forms > cgi > any damn language you want

That automatically means that it isn't a perl question.

> Interesting how that works!

Yes, very.

> Do you need any more help understanding my question, Mr. Perl
> Programming man?

No, but you apparently need help understanding basic rules of
socialization.  Watch a group of 5 year olds at a daycare for
a few days if you need tips on how to interact with others.

> In the mean time, KMA!

*plonk*

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 19 Apr 1999 15:20:02 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <7ffhj2$nqm$2@info2.uah.edu>

Following is a summary of articles from new posters spanning a 7 day
period, beginning at 12 Apr 1999 14:25:35 GMT and ending at
19 Apr 1999 17:23:37 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 1999 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Totals
======

Posters:  232 (46.6% of all posters)
Articles: 373 (25.0% of all articles)
Volume generated: 558.6 kb (22.7% of total volume)
    - headers:    266.6 kb (5,420 lines)
    - bodies:     287.3 kb (9,204 lines)
    - original:   213.2 kb (7,014 lines)
    - signatures: 4.3 kb (138 lines)

Original Content Rating: 0.742

Averages
========

Posts per poster: 1.6
    median: 1.0 post
    mode:   1 post - 171 posters
    s:      2.0 posts
Message size: 1533.5 bytes
    - header:     732.0 bytes (14.5 lines)
    - body:       788.8 bytes (24.7 lines)
    - original:   585.3 bytes (18.8 lines)
    - signature:  11.7 bytes (0.4 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   20    31.0 ( 13.8/ 16.5/  7.6)  therzog@knotech.com (Tim Herzog)
   17    22.8 ( 10.5/ 12.2/  5.0)  danbeck@scott.net (Daniel Beckham)
    6     8.8 (  4.2/  4.6/  2.7)  "Doug Crabtree" <not@gonna.tell>
    6    12.8 (  4.2/  8.6/  5.9)  markaw2091@my-dejanews.com
    6    10.1 (  4.2/  5.8/  3.0)  ajeet@my-dejanews.com
    5     7.3 (  3.5/  3.8/  1.4)  Neil Sandow <rx@rxlist.com>
    5     6.6 (  4.4/  1.8/  1.2)  Ken Robbins <puyrebel@prodigy.net>
    5     9.2 (  4.0/  5.2/  3.1)  "Wyzelli" <wyzelli@yahoo.com>
    5     7.2 (  3.8/  3.4/  3.4)  Mats Pettersson <mats.pettersson@falukuriren.se>
    5     6.3 (  3.6/  2.7/  1.8)  splice@videotron.ca ([sp-])

These posters accounted for 5.4% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  31.0 ( 13.8/ 16.5/  7.6)     20  therzog@knotech.com (Tim Herzog)
  22.8 ( 10.5/ 12.2/  5.0)     17  danbeck@scott.net (Daniel Beckham)
  12.8 (  4.2/  8.6/  5.9)      6  markaw2091@my-dejanews.com
  10.1 (  4.2/  5.8/  3.0)      6  ajeet@my-dejanews.com
   9.5 (  2.5/  7.1/  2.7)      3  Ron Reidy <rereidy@uswest.net>
   9.2 (  4.0/  5.2/  3.1)      5  "Wyzelli" <wyzelli@yahoo.com>
   8.8 (  4.2/  4.6/  2.7)      6  "Doug Crabtree" <not@gonna.tell>
   7.9 (  3.0/  4.9/  3.5)      4  e_broyles@yahoo.com
   7.4 (  3.2/  4.2/  3.5)      4  chatswood@my-dejanews.com
   7.3 (  3.5/  3.8/  1.4)      5  Neil Sandow <rx@rxlist.com>

These posters accounted for 5.1% of the total volume.

Top 10 Posters by OCR (minimum of three posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

1.000  (  0.7 /  0.7)      3  austin95002887@yahoo.com (Kevin !;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;!;)
1.000  (  0.9 /  0.9)      5  "Brad Hilton" <bhilton@kc.net>
1.000  (  0.2 /  0.2)      3  WizeGuy@nettaxi.com
1.000  (  0.9 /  0.9)      3  "Kevin" <mpajot@club-internet.fr>
1.000  (  3.4 /  3.4)      5  Mats Pettersson <mats.pettersson@falukuriren.se>
0.993  (  2.0 /  2.0)      4  haytounet@my-dejanews.com
0.906  (  0.9 /  1.0)      3  jewing@eng.utoledo.edu
0.838  (  1.6 /  1.9)      3  "Steve Springett" <sspringett@cwe2.com>
0.824  (  3.5 /  4.2)      4  chatswood@my-dejanews.com
0.773  (  2.8 /  3.6)      3  NOSPAMcrstlblu@planet.eon.net

Bottom 10 Posters by OCR (minimum of three posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.636  (  1.2 /  1.8)      5  Ken Robbins <puyrebel@prodigy.net>
0.602  (  3.1 /  5.2)      5  "Wyzelli" <wyzelli@yahoo.com>
0.598  (  2.7 /  4.6)      6  "Doug Crabtree" <not@gonna.tell>
0.508  (  3.0 /  5.8)      6  ajeet@my-dejanews.com
0.458  (  7.6 / 16.5)     20  therzog@knotech.com (Tim Herzog)
0.453  (  2.0 /  4.4)      4  spg@quokka.com (Gus)
0.411  (  5.0 / 12.2)     17  danbeck@scott.net (Daniel Beckham)
0.385  (  2.7 /  7.1)      3  Ron Reidy <rereidy@uswest.net>
0.358  (  1.4 /  3.8)      5  Neil Sandow <rx@rxlist.com>
0.334  (  0.7 /  2.1)      3  "john gury" <gury@interaccess.com>

24 posters (10%) had at least three posts.


Top 10 Crossposters
===================

Articles  Address
--------  -------

       6  "PofPof98" <pofpof98@yahoo.com>
       3  thorsten.dittmar@debitel.net
       3  mbk@cbr.dit.csiro.au (Martin Kuchlmayr)
       3  "Jim Kangosjdrvi" <Jim.Kangosjarvi@Abc.se>
       2  yanek@cs.wm.edu
       2  amacleod@altavista.net
       2  Don't Spam Me <nobody@raptor.com>
       2  "Scott W" <swolfington@home.com>
       2  "Scott Stolpmann" <hy3na@ispchannel.com>
       2  "Greg Waugh" <bigbird@pol.com>


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

Date: Mon, 19 Apr 1999 17:02:35 +0100
From: Lee Bennett <lee@old-chapel.demon.co.uk>
Subject: newbie help need on environment variables
Message-Id: <371B539B.D1DA2623@old-chapel.demon.co.uk>

Hi

How do I source environment variables from an OS file. With unix shell
scripting I would simply use the syntax:

 . variable_file

What is the perl equivalent?

Thanks

Lee Bennett



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

Date: Mon, 19 Apr 1999 09:43:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie help need on environment variables
Message-Id: <MPG.1184fcfd711a822a9898dc@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <371B539B.D1DA2623@old-chapel.demon.co.uk> on Mon, 19 Apr 
1999 17:02:35 +0100, Lee Bennett <lee@old-chapel.demon.co.uk> says...
> How do I source environment variables from an OS file. With unix shell
> scripting I would simply use the syntax:
> 
> . variable_file
> 
> What is the perl equivalent?

Read the file; parse out name/value pairs using a regex or split(); set 
them up in the %ENV hash.

Don't forget that these variables disappear when the perl process 
terminates.

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


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

Date: Mon, 19 Apr 1999 17:28:50 +0200
From: Federico Abascal <fabascal@gredos.cnb.uam.es>
Subject: Number of elements of a hash table
Message-Id: <371B4BB1.AF257E3A@gredos.cnb.uam.es>

Please, how can I know the number of elements of a hash in a fast way.
Thanks,
Fede



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

Date: 19 Apr 1999 09:33:50 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Number of elements of a hash table
Message-Id: <371b4cde@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Federico Abascal <fabascal@gredos.cnb.uam.es> writes:
:Please, how can I know the number of elements of a hash in a fast way.

The answer is in section 4 of the Perl Frequently Asked Questions list,
which is included Perl itself.

    % man perlfaq4

    ...

    How can I know how many entries are in a hash?

    If you mean how many keys, then all you have to do is...

Happy researching.

--tom
-- 
 "VAX. For those who care enough to steal the very best."
     -- A microscopic message on the silicon chip inside
	one of Digital Equipment's often stolen computer designs.


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

Date: 19 Apr 1999 16:55:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Number of elements of a hash table
Message-Id: <371b5201@newsread3.dircon.co.uk>

Federico Abascal <fabascal@gredos.cnb.uam.es> wrote:
> Please, how can I know the number of elements of a hash in a fast way.

sure its a FAQ but anyhow keys in a scalar context.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Mon, 19 Apr 1999 15:14:49 +0000
From: Michael Cameron <Michael.Cameron@no.spam.technologist.com>
To: Keith P <picardk@runnymede.gov.uk>
Subject: Re: pack format control string help
Message-Id: <371B4869.35BE914D@no.spam.technologist.com>

Keith P wrote:

>
> CPlease, could someone who has more experience with unpack and/or Solaris
> structures tell me what is necessary?

You will probably find the answers in the Solaris header files (try utmp.h &
time.h ? ) but I would suggest getting out of the guts of Solaris files and
concentrating on some of the more interesting (and less system dependent) aspects
of learning Perl instead.

I had a whole heap of bother with pack/unpack under Solaris which I eventually
solved by poring over hexdumps.   The functions work, its the file format that is
difficult.

Or you could always install Linux ;-)

Michael Cameron





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

Date: Mon, 19 Apr 1999 17:46:02 +0200
From: =?iso-8859-1?Q?J=FCrgen?= Ibelgaufts <ibelgaufts@gfc-net.de>
Subject: Perl pipe under OS/2 broken?
Message-Id: <371B4FBA.E524165F@gfc-net.de>

Hi,

Is there possibly anybody out there who still works with OS/2??

unfortunately I have to migrate a Perl program which works well
under Windows NT and Unix to OS/2. Here I find the stupid
problem that piping the output of a command into perl does not
work. The source code is as simple as this (and works fine under
Windows NT):


  $cmd = "dir | ";

  open ( F, $cmd);
  while (<F>) {
    print STDOUT "Pipe: $_";
  }

Under Windows NT, it will print out the output of the dir
command. 

Under OS/2 I first get the message SYS0002, The file cannot be
found, and the header of the dir command, but no files. 

Obviously the pipe sign | is interpreted as a file name, because
if I say

  $cmd = "dir xyz |"

in my program, I get the sys0002 twice.

What happens here? And how can I work around? I am completely
stuck, please someone help.

Thanks in advance

Juergen Ibelgaufts


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

Date: 19 Apr 1999 15:20:02 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <7ffhj2$nqm$1@info2.uah.edu>

Following is a summary of articles spanning a 7 day period,
beginning at 12 Apr 1999 14:25:35 GMT and ending at
19 Apr 1999 17:23:37 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 1999 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Excluded Posters
================

perlfaq-suggestions\@(?:.*\.)?perl\.com

Totals
======

Posters:  498
Articles: 1491 (612 with cutlined signatures)
Threads:  467
Volume generated: 2465.3 kb
    - headers:    1097.1 kb (22,328 lines)
    - bodies:     1275.8 kb (40,898 lines)
    - original:   848.1 kb (29,400 lines)
    - signatures: 91.0 kb (2,203 lines)

Original Content Rating: 0.665

Averages
========

Posts per poster: 3.0
    median: 1.0 post
    mode:   1 post - 315 posters
    s:      7.5 posts
Posts per thread: 3.2
    median: 2 posts
    mode:   1 post - 145 threads
    s:      3.6 posts
Message size: 1693.1 bytes
    - header:     753.5 bytes (15.0 lines)
    - body:       876.2 bytes (27.4 lines)
    - original:   582.4 bytes (19.7 lines)
    - signature:  62.5 bytes (1.5 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   78   161.2 ( 63.9/ 80.1/ 36.9)  David Cassell <cassell@mail.cor.epa.gov>
   71   108.3 ( 57.6/ 45.7/ 21.3)  Jonathan Stowe <gellyfish@gellyfish.com>
   64   102.2 ( 40.4/ 54.8/ 31.2)  lr@hpl.hp.com (Larry Rosler)
   55    90.5 ( 42.4/ 39.0/ 35.2)  abigail@fnx.com
   53   102.6 ( 43.3/ 52.9/ 44.4)  tchrist@mox.perl.com (Tom Christiansen)
   50    76.4 ( 28.1/ 48.2/ 30.6)  tadmc@metronet.com (Tad McClellan)
   37    55.4 ( 29.8/ 25.6/ 17.1)  bart.lateur@skynet.be (Bart Lateur)
   30    55.5 ( 24.1/ 27.8/ 13.2)  sholden@cs.usyd.edu.au
   23    33.4 ( 20.6/ 12.0/  7.4)  Rick Delaney <rick.delaney@home.com>
   23    49.3 ( 18.7/ 23.6/ 12.5)  Uri Guttman <uri@home.sysarch.com>

These posters accounted for 32.5% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

 161.2 ( 63.9/ 80.1/ 36.9)     78  David Cassell <cassell@mail.cor.epa.gov>
 108.3 ( 57.6/ 45.7/ 21.3)     71  Jonathan Stowe <gellyfish@gellyfish.com>
 102.6 ( 43.3/ 52.9/ 44.4)     53  tchrist@mox.perl.com (Tom Christiansen)
 102.2 ( 40.4/ 54.8/ 31.2)     64  lr@hpl.hp.com (Larry Rosler)
  90.5 ( 42.4/ 39.0/ 35.2)     55  abigail@fnx.com
  76.4 ( 28.1/ 48.2/ 30.6)     50  tadmc@metronet.com (Tad McClellan)
  55.5 ( 24.1/ 27.8/ 13.2)     30  sholden@cs.usyd.edu.au
  55.4 ( 29.8/ 25.6/ 17.1)     37  bart.lateur@skynet.be (Bart Lateur)
  49.3 ( 18.7/ 23.6/ 12.5)     23  Uri Guttman <uri@home.sysarch.com>
  34.9 ( 16.9/ 12.8/  5.8)     23  rjk@linguist.dartmouth.edu (Ronald J Kimball)

These posters accounted for 33.9% of the total volume.

Top 10 Posters by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

1.000  (  3.4 /  3.4)      5  Mats Pettersson <mats.pettersson@falukuriren.se>
1.000  (  0.9 /  0.9)      5  "Brad Hilton" <bhilton@kc.net>
0.904  ( 35.2 / 39.0)     55  abigail@fnx.com
0.840  ( 44.4 / 52.9)     53  tchrist@mox.perl.com (Tom Christiansen)
0.817  (  9.7 / 11.9)      5  mitiaNOSPAM@nwu.edu.invalid (Dmitry Epstein)
0.812  (  3.2 /  3.9)      5  Aidan Rogers <aidan@salvador.blackstar.co.uk>
0.736  (  2.7 /  3.7)      5  agniora@usa.net
0.716  (  1.1 /  1.6)      5  Ken Mar <kenmar@ihug.co.nz>
0.700  (  6.0 /  8.6)      7  Ronny <ronald_f@my-dejanews.com>
0.679  (  5.9 /  8.6)      6  markaw2091@my-dejanews.com

Bottom 10 Posters by OCR (minimum of five posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.476  (  4.6 /  9.6)     14  merlyn@stonehenge.com (Randal L. Schwartz)
0.472  (  6.0 / 12.8)     10  ruben@llinderman.dental.nyu.edu (Sys Adm 89806 Manager of programing development and Intranet Resources)
0.466  ( 21.3 / 45.7)     71  Jonathan Stowe <gellyfish@gellyfish.com>
0.460  ( 36.9 / 80.1)     78  David Cassell <cassell@mail.cor.epa.gov>
0.458  (  7.6 / 16.5)     20  therzog@knotech.com (Tim Herzog)
0.449  (  5.8 / 12.8)     23  rjk@linguist.dartmouth.edu (Ronald J Kimball)
0.420  (  2.2 /  5.3)      5  efflandt@xnet.com
0.411  (  5.0 / 12.2)     17  danbeck@scott.net (Daniel Beckham)
0.395  (  1.5 /  3.8)      5  ilya@math.ohio-state.edu (Ilya Zakharevich)
0.358  (  1.4 /  3.8)      5  Neil Sandow <rx@rxlist.com>

50 posters (10%) had at least five posts.

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

   23  Q: Convert two newlines to \n<p>
   17  Books
   16  flocking question - worried
   14  New FAQ: How can I read in an entire file all at once?
   14  Problem with my & local declarations
   14  How to write a format to an array instead of a filehandle?
   14  Hash symbol '%' a stylized what?
   13  $variables in <FILES>
   12  TPJ still shipping?
   12  How do I delete text in a file?

These threads accounted for 10.0% of all articles.

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

  33.1 ( 19.8/ 12.2/  7.6)     23  Q: Convert two newlines to \n<p>
  30.3 (  8.5/ 20.8/ 16.1)     12  How do I delete text in a file?
  30.2 ( 11.6/ 16.8/ 11.2)     14  New FAQ: How can I read in an entire file all at once?
  29.7 (  9.3/ 19.8/ 11.3)     13  $variables in <FILES>
  28.4 ( 10.9/ 16.5/  8.8)     14  Problem with my & local declarations
  27.6 ( 12.0/ 15.0/  8.7)     16  flocking question - worried
  27.2 ( 14.2/ 10.8/  7.4)     17  Books
  25.6 ( 11.5/ 12.4/  6.2)     14  How to write a format to an array instead of a filehandle?
  23.9 (  4.9/ 17.9/  8.8)      8  { } question/problem
  23.7 (  8.6/ 13.9/  9.1)     11  FREE Certifications Offered Online to perl programmers

These threads accounted for 11.3% of the total volume.

Top 10 Threads by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

1.000  (  0.9/   0.9)      5  VB and Perl
0.921  (  2.7/   2.9)      5  How Should I begin Perl?
0.818  (  2.5/   3.0)      5  Core
0.807  (  5.4/   6.7)      9  Splitting length instead of delimiting character?
0.786  (  1.7/   2.1)      6  how can i send perl -c output to a file instead of STDERR
0.786  (  2.0/   2.6)      5  Dummy Question about Perl Licence
0.782  (  4.3/   5.5)     10  getting mm/dd/yy from localtime()
0.774  ( 16.1/  20.8)     12  How do I delete text in a file?
0.766  (  4.1/   5.4)      5  Can Perl implement a state machine?
0.765  (  7.8/  10.2)      5  array names same as file names

Bottom 10 Threads by OCR (minimum of five posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.462  (  5.4 / 11.7)      6  Delete Line Feed/Carriage Return
0.457  (  1.8 /  3.9)      5  Pragma docs
0.441  (  2.0 /  4.5)      6  Newbie Question: String Manipulation
0.440  (  1.6 /  3.6)      5  Writing Binary Files
0.426  (  4.0 /  9.3)     14  Hash symbol '%' a stylized what?
0.387  (  2.6 /  6.8)     10  Stripping out all but the first word
0.382  (  1.9 /  4.9)      6  Q: Hash tables!!!
0.374  (  1.4 /  3.7)      5  Password encryption
0.363  (  1.3 /  3.7)      6  Perl rmdir
0.344  (  1.4 /  4.2)      5  TZ not used in winnt Date/Time routines

93 threads (19%) had at least five posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      35  comp.lang.perl.modules
      18  comp.lang.perl
      14  alt.perl
       5  comp.lang.perl.moderated
       4  comp.security.firewalls
       3  borland.public.delphi.winapi
       3  comp.lang.pascal.delphi
       3  comp.os.ms-windows.nt.misc
       3  alt.lang.delphi
       2  comp.lang.perl.module

Top 10 Crossposters
===================

Articles  Address
--------  -------

       8  David Cassell <cassell@mail.cor.epa.gov>
       6  "Andrew Branson" <a_branson_1998@yahoo.com>
       6  "PofPof98" <pofpof98@yahoo.com>
       6  sholden@cs.usyd.edu.au
       4  Jonathan Stowe <gellyfish@gellyfish.com>
       3  mbk@cbr.dit.csiro.au (Martin Kuchlmayr)
       3  Greg Griffiths <greg2@surfaid.org>
       3  linberg@literacy.upenn.edu (Steve Linberg)
       3  bart.lateur@skynet.be (Bart Lateur)
       3  "Jim Kangosjdrvi" <Jim.Kangosjarvi@Abc.se>


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

Date: 19 Apr 1999 15:45:08 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: strange problem with fork()
Message-Id: <7ffj24$gr6$1@pegasus.csx.cam.ac.uk>

[Oops  -  try to paste the right paragraph this time.]

Dennis Wetzig  <dennis@bilbo.iok.net> wrote:
            ... of problems with fork.

You seem to have overlooked this paragraph from 'perldoc -f fork':

Note: unflushed buffers remain unflushed in both processes, which means
you may need to set C<$|> ($AUTOFLUSH in English) or call the C<autoflush()>
method of C<IO::Handle> to avoid duplicate output.


Mike Guy


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

Date: 19 Apr 1999 16:49:41 GMT
From: Len Bolivia <revjack@radix.net>
Subject: Re: TPJ still shipping?
Message-Id: <7ffmr5$s36$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Jon Orwant explains it all:

:I do have a Brobdingnagian inbox, and most of my messages take
:me longer to reply to than I'd like, but there's nothing there
:from either /wappinger/i or /revjack/i.  

Jon,

The order I placed was from a completely different address, not this one.
I'll e-mail you directly and explain. 

__END_THREAD__

-- 
  /~\  beet cottonseed hide lenticular felony Catherwood obese infesta
 C oo  embeddable allyl Annette octet Charles ajar associable epidemic
 _( ^) 1 , 0 0 0 , 0 0 0   m o n k e y s   c a n ' t   b e   w r o n g
/___~\ http://3509641275/~revjack  04/19/99 12:48:12 revjack@radix.net


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

Date: Mon, 19 Apr 1999 08:43:44 -0700
From: arnee <arnee@geocities.com>
Subject: Re: umask
Message-Id: <371B4F2F.FF40CEB0@geocities.com>



Martin wrote:

> Hi, can anyone please help?
>
> I need to make all files produced by a script have properties 0777.
> The problem is that I wrote the (very long) script for an NT server
> so did not chmod files after making them. I'm hoping I can use the
> umask command to make new files have 0777 properties. I couldn't
> find any info on the Perl manpages and I just found a puzzling footnote
> in the Llama book. I did man umask from linux and couldn't understand
> the manpage.
>
> Will umask(00) at the top of my script cause new files made to have
> default properties of 0777?
>
> Martin

one might say, umask may be the opposite of chmod. think of it this way,
chmod is
ADDING the protection mode and umask is just the opposite, SUBTRACTING (or
pulling out the protection mode) e.g.
                    umask 022 is (777 - 022 = 755)
                    chmod 755 = 755 and 022 = 022





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

Date: Mon, 19 Apr 1999 11:52:19 -0500
From: "Tom Renfro" <renfro@i-55.com>
Subject: Re: Using a Regexp
Message-Id: <7ffmf8$gqj$1@nntp.gulfsouth.verio.net>

>if (/User-Name = "([^"]+)"/) {
>    $user = $1;
>    if (/Acct-Session-Time = (\d+)/) {
>        $elapsed = $1;
>         /Acct-Input-Octets = (\d+)/;
>         $input = $1;
>         /Acct-Output-Octets = (\d+)/;
>         $output = $1;
>         $used{$user} += $elapsed;
>         $input{$user} += $input;
>         $output{$user} += $output;
>     }
>}
>
>Can anyone tell me what regexp I should use to extract the IP number from
>the appropriate field (Framed-IP-Address)?  I cannot find any reference to
>IP address in the regexp FAQ (perlfaq6) and am still very much a newbie at
>this.
>
>Framed-IP-Address = 203.39.3.170


just use
if (/Framed-IP-Address =(.+)$/) {
    $ip = $1;
}

Basically just find the first bit, then grab everything else on the line
until the end of
the line.

TOM.




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

Date: Mon, 19 Apr 1999 10:53:19 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: VB and Perl
Message-Id: <x3y7lr8hdb5.fsf@tigre.matrox.com>


"Brad Hilton" <bhilton@kc.net> writes:

> How can I integrate Perl into VB?  Is it possible to program entirely in
> Perl but use VB for screens?  Where can I go for information on this?

Use VB for screens? What screens?
You mean create GUI's using VB? Maybe you should look into Perl/Tk
(search CPAN for it).



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

Date: 19 Apr 1999 16:35:09 GMT
From: schalkwy@minnie.RZ-Berlin.MPG.DE (Leo Schalkwyk)
Subject: Re: Viewing a spreadsheet?
Message-Id: <7fflvt$5ao$1@fu-berlin.de>

vivekvp@yahoo.com wrote:
: Hello,

: I am looking to display a spreadsheet via html.  I would like to take the
: contents of an excel spreadsheet and be able to dump them to a web page.

: How do I go about doing this?  Any help - please email me at
: vivekvp@spliced.zzn.com

: Thank you!

It's not clear that this is a perl question, but a nice perl
solution exists: the program herbert by Martin Schwartz robustly 
turns excel binaries into html tables. 
See http://wwwbs.cs.tu-berlin.de/~schwartz/perl
(taken from the comments, I haven't checked whether it's still current)

Leo

--
------------------------------------------------------------
   schalkwy@mpimg-berlin-dahlem.mpg.de


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

Date: 19 Apr 1999 18:04:23 +0100
From: hals <haakon.alstadheim@sds.no>
Subject: Re: why won't this statement work @array=<*.*>
Message-Id: <ulnfo4k4o.fsf@sds.no>


Depending on how you compile your perl executable, it might
need an external program (perlglob.exe or perlglob.bat) to perform
the globbing. If this program is not found in the path-list, it 
might fail. Experiment with C<use File::Dosglob;>  or with 
something like C<$ENV{PATH} .= "path to a copy of dosglob.exe";>


George <dscapin@harris.com> writes:
[snip]
> Now, when I put the perlscript on the server this statement doesn't
> work.  The server is an NT server.  It doesn't work because the number
[snip]


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

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

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