[8873] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2490 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 4 11:06:35 1998

Date: Mon, 4 May 98 08: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           Mon, 4 May 1998     Volume: 8 Number: 2490

Today's topics:
    Re: 'C' command "TOUPPER" or "TOLOWER". <barnett@houston.Geco-Prakla.slb.com>
    Re: 'C' command "TOUPPER" or "TOLOWER". <barnett@houston.Geco-Prakla.slb.com>
    Re: 'each' and recursion, do they mix? (Mark-Jason Dominus)
    Re: 1701 days hath September (was: Re: rename funciton) <flavell@mail.cern.ch>
    Re: ANSI Colour in Perl (John Porter)
    Re: Any way to flush Perl output buffer <barnett@houston.Geco-Prakla.slb.com>
    Re: Any way to flush Perl output buffer <tchrist@mox.perl.com>
    Re: Apache Logfile Parser? <tony@blackstar.co.uk>
    Re: Apache Logfile Parser? <ag-ho@students.uiuc.edu>
    Re: Apache Logfile Parser? <tchrist@mox.perl.com>
    Re: Bidirectional pipe filehandles? <merlyn@stonehenge.com>
    Re: cd with a perl-script (Frank van Beek)
    Re: cd with a perl-script <tchrist@mox.perl.com>
    Re: Complete Newbie - Where do I start? <barnett@houston.Geco-Prakla.slb.com>
        ctime.pl (Max)
    Re: Directory usage in Perl for win32 <jdf@pobox.com>
    Re: How can I delete a file from my perl program <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
    Re: How can I delete a file from my perl program (Alex Dong Li)
    Re: How do I print a string that is in a certain format (John Porter)
    Re: How many files can I open? (Mark-Jason Dominus)
    Re: Max length of a string (Kjetil Skotheim)
    Re: need help with hashtable size/memory (Kjetil Skotheim)
        Off-topic (Re: Perl/Wall lingo question) (John Porter)
    Re: Perl/Wall lingo question (John Porter)
        Regex Question <tthomas@chubb.com>
        Splain a regex to me kathryn.nelson@usa.net
    Re: Y2K and Perl (Mark Manning)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 04 May 1998 09:03:54 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
To: University Student <i_hate_spam@spam-sucks.com>
Subject: Re: 'C' command "TOUPPER" or "TOLOWER".
Message-Id: <354DCACA.C4CA757@houston.Geco-Prakla.slb.com>

University Student wrote:
> 
> Does anyone know what the alternative to the "C" command
>         toupper (x);
> is in Perl?
> 
> TOUPPER meaning concert all alphabet letters to uppercase... or
perldoc -f uc

> TOLOWER meaning concert all alphabet letters to lowercase...
perldoc -f lc

> 
> reason being I would like to restric some users from
> registering TWICE with the same e-mail address, but in
> different low/upper case.... ie. I want to equate
> 
> username@AOL.COM     and          UseRnaMe@aol.COM
> 
<snip>

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

----------------------------------------------------------------------
Dave Barnett                 U.S.: barnett@houston.Geco-Prakla.slb.com
DAPD Software Support Eng    U.K.: barnett@gatwick.Geco-Prakla.slb.com
Schlumberger Geco-Prakla     (281) 596-1434 (Office Number)           
1325 S. Dairy Ashford #7051  (281) 556-7615 (Fax)                     
Houston, TX 77077                                                     
----------------------------------------------------------------------


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

Date: Mon, 04 May 1998 09:04:18 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: 'C' command "TOUPPER" or "TOLOWER".
Message-Id: <354DCAE2.29019A94@houston.Geco-Prakla.slb.com>

University Student wrote:
> 
> Does anyone know what the alternative to the "C" command
>         toupper (x);
> is in Perl?
> 
> TOUPPER meaning concert all alphabet letters to uppercase... or
perldoc -f uc

> TOLOWER meaning concert all alphabet letters to lowercase...
perldoc -f lc

> 
> reason being I would like to restric some users from
> registering TWICE with the same e-mail address, but in
> different low/upper case.... ie. I want to equate
> 
> username@AOL.COM     and          UseRnaMe@aol.COM
> 
<snip>

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

----------------------------------------------------------------------
Dave Barnett                 U.S.: barnett@houston.Geco-Prakla.slb.com
DAPD Software Support Eng    U.K.: barnett@gatwick.Geco-Prakla.slb.com
Schlumberger Geco-Prakla     (281) 596-1434 (Office Number)           
1325 S. Dairy Ashford #7051  (281) 556-7615 (Fax)                     
Houston, TX 77077                                                     
----------------------------------------------------------------------


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

Date: 4 May 1998 09:54:29 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <6ikhal$bga$1@monet.op.net>
Keywords: fractious Grayson multiplication pug


In article <6iip7i$c8u$1@cyprus.atlantic.net>,
Chip Salzenberg <chip@mail.atlantic.net> wrote:
>Yes, scalar '..' does have the same problem as //o.

The p5p discussion from February-March says otherwise.
I didn't understand the explanation, unfortunately.



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

Date: Mon, 4 May 1998 14:16:42 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <Pine.A41.3.95a.980504140623.114148C-100000@rsplus14.cern.ch>

On 4 May 1998, John Stanley wrote:

> >One doesn't have to even write software to deal with this problem. 
> >There's a whole range of solutions.  If you want to, you could create an
> >email address exclusively for your usenet activities, 

> You apparently missed the part where it involves paying for
> another account.

Yes, I certainly did.  Ridiculous idea, when I could get low-cost
accounts from a choice of providers, that allow either several email
addresses, or as many as one cares to create. 

But this is the wrong place to discuss email abuse, as I already said:
f'ups set.



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

Date: Mon, 04 May 1998 14:18:41 GMT
From: jdporter@min.net (John Porter)
Subject: Re: ANSI Colour in Perl
Message-Id: <MPG.fb799bea332451e98969e@news.min.net>

On Fri, 1 May 1998 22:31:25 +0100,
in article <oA1d4UAt8jS1EwIa@dozyrosy.demon.co.uk>,
Rosie@dozyrosy.demon.co.uk (Rosemary I H Powell) wrote:
>
> ICK!! You mean the AMERICAN spelling - the correct way in this country
> is coloUr.

wadr, the correct spelling is the one which finds the package, if
you're doing a text-based search.  'color' finds it, 'colour' does
not.

> Just Another Micro$oft Idiot

Well said. (;-)

John Porter



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

Date: Mon, 04 May 1998 08:34:28 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Any way to flush Perl output buffer
Message-Id: <354DC3E4.2FED60D9@houston.Geco-Prakla.slb.com>

Les Woolsey wrote:
> 
> I have a Perl script that's making system calls in a loop.  Just before the
> call I put out a message to the console.  But the message seems to be
> buffered by Perl and don't appear before the output of the system call.  Is
> there some way (short of open & close of SYSOUT) to flush the Perl buffer?
> 
> Les
Have a look at the $| variable.

HTH.

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

----------------------------------------------------------------------
Dave Barnett                 U.S.: barnett@houston.Geco-Prakla.slb.com
DAPD Software Support Eng    U.K.: barnett@gatwick.Geco-Prakla.slb.com
----------------------------------------------------------------------


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

Date: 4 May 1998 14:27:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Any way to flush Perl output buffer
Message-Id: <6ikj8n$15i$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    "Les Woolsey" <lwoolsey@innovative.ca> writes:
:I have a Perl script that's making system calls in a loop.  Just before the
:call I put out a message to the console.  But the message seems to be
:buffered by Perl and don't appear before the output of the system call.  Is
:there some way (short of open & close of SYSOUT) to flush the Perl buffer?

Perl FAQ, section five, question 1:

    "What is buffering and why do I care?"

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
"A ship then new they built for him/of mithril and of elven glass" 
    --Larry Wall in perl.c from the v5.0 perl distribution,
	citing Bilbo from Tolkien's LOTR


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

Date: Mon, 04 May 1998 13:04:27 GMT
From: Tony Bowden <tony@blackstar.co.uk>
Subject: Re: Apache Logfile Parser?
Message-Id: <894290676.340773@sparc.tibus.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:
: :I'm helping a friend of mine with a few scripts for his new server... 
: :what he needs is an Apache logfile parser

: Was wondering why you didn't look at CPAN.
: http://www.perl.com/CPAN/modules/by-module/Apache/Apache-LogFile-0.11.tar.gz

Actually, this is a module for interfacing with Apache's logging routines, 
rather than parsing logfiles ...

I'm unsure however what the original poster is actually looking for: it's
not too difficult to make a regexp that matches lines from a logfile, but
what a module would do with the info after that is an entirely different
matter... there are just too many questions I would want to ask of that
logfile for any module to cope!

Tony (who logs to a database, rather than a file...)

-- 
-----------------------------------------------------------------------------
 Tony Bowden |  tony@tmtm.com / NooNoo@teletubbies.org / http://www.tmtm.com/
 Belfast, NI |                       you are a free moth - go chase the light
-----------------------------------------------------------------------------


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

Date: Mon, 4 May 1998 08:46:30 -0500
From: Andrew Ho <ag-ho@students.uiuc.edu>
Subject: Re: Apache Logfile Parser?
Message-Id: <Pine.SOL.3.96.980504084253.17847A-100000@ux9.cso.uiuc.edu>

Hello,

TB>Actually, this is a module for interfacing with Apache's logging routines, 
TB>rather than parsing logfiles ...
TB>
TB>I'm unsure however what the original poster is actually looking for: it's
TB>not too difficult to make a regexp that matches lines from a logfile, but
TB>what a module would do with the info after that is an entirely different
TB>matter... there are just too many questions I would want to ask of that
TB>logfile for any module to cope!

I would conjecture that the most common reason for parsing webserver
logfiles is to capture web access metrics. I would recommend a friendly web
search on "common logfile format," "wwwstat," and--for those with a
commercial bent--WebTrends as well. wwwstat is free and Perl-based and I
used it successfully at Motorola. WebTrends is real expensive and
Windows-based and we use it here at NCSA. 

Humbly,

Andrew

-------------------------------------------------------------------------
'Twas brillig, and the slithy toves                            Andrew Ho
 Did gyre and gimble in the wabe.                         ag-ho@uiuc.edu
 All mimsy were the borogroves,
 And the mome raths outgrabe.           http://www.uiuc.edu/ph/www/ag-ho
-------------------------------------------------------------------------



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

Date: 4 May 1998 14:37:48 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Apache Logfile Parser?
Message-Id: <6ikjrs$15i$3@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Tony Bowden <tony@blackstar.co.uk> writes:
:: http://www.perl.com/CPAN/modules/by-module/Apache/Apache-LogFile-0.11.tar.gz
:
:Actually, this is a module for interfacing with Apache's logging routines, 
:rather than parsing logfiles ...

Right.  What I meant is in

    http://www.perl.com/CPAN/modules/by-module/Logfile/Logfile-0.115.tar.gz

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    X-Windows: The Cutting Edge of Obsolescence.
	--Jamie Zawinski


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

Date: Mon, 04 May 1998 14:10:23 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: lwp@mail.msen.com
Subject: Re: Bidirectional pipe filehandles?
Message-Id: <8cvhrmqg9k.fsf@gadget.cscaper.com>

>>>>> "Lou" == Lou Poppler <lwp@flenser.ibm.net> writes:

Lou> I did not write the text quoted below.

Yes.  We can tell.  How come you couldn't?  It's plain to me that you
*quoted* that from another article, and didn't write it.  I might
infer something from the fact that you *quoted* it, but as far as
writing is concerned, no biggy.

Lou> Please be more careful with your attributions.

I'd say tigger@io.com was already pretty careful.  Please be careful
with your complaints. :-)

Lou> On 1 May 1998 16:52:20 GMT, tigger@io.com.nospaam wrote:
Lou> : Check out the open2() command, and the Comm.pl module.


Lou> : Lou Poppler <lwp@flenser.ibm.net> wrote:
Lou> :> : Now, on page 163 of the 1st Edition camel book (the "open" reference),
Lou> :> : Larry and Randal tell me that an open command which pipes both in and out
Lou> :> : should be easy to build. How, though? I've been poring over the pipe() and
Lou> :> : fork() man pages and function references for a couple hours now, and I'm
Lou> :> : not seeing it.

Lou> :> : Alik


print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 120 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
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, 4 May 1998 12:49:27 GMT
From: frank@neogeo.nl (Frank van Beek)
Subject: Re: cd with a perl-script
Message-Id: <EsFnMF.Iy2@neogeo.nl>

art@flying.broomstick.com (Arthur Hagen) writes:


>In article <354D7446.250CD97A@stk.co.at>, Michael Pokerschnig <michael.pokerschnig@stk.co.at> writes:
>
>> Can anybody tell me how i can change the directory of the shell from
>> wich I'm starting the perl script ?
>
>Short answer:  You can't.
>

If you are able to write a small C-program it might be possible. It is
possible to write a command to your controlling terminal. What you
might do is:

#include <unistd.h>

void toterminal(char * cmd)
{
	long len, i;
	char nl2;
	
	/* send the command */
	len = strlen(cmd);
	for(i = 0 ; i< len; i++) ioctl(0,TIOCSTI,&cmdi);

	/* send a newline */
	sprintf(nl, "\n");
	ioctl(0,TIOCSTI,&nl0)
	
}

main(int argc, char ** argv)
{
	if (argc < 3) {
		printf("%s delay command\n", argv0);
		exit(1);
	}
	
	sginap(atoi(argv1));
	toterminal(argv2);
}

The syntax of the program would be:

	foo 100 "cd /directory/where/you/would/like/to/cd/to"
	
The program would wait 1 second before sending the cd command to its
controlling terminal. If the perl script has ended by that time the
command would be executed by the shell.

I don't know anything about programming in perl, but it should be
possible to do something like:

	foo 100 "cd ..." &
	exit

to have the program execute about 1 second after the perl script has
ended.

**WARNING**

This command can be very dangerous. If you start it with a delay long
enough and someone else logs in on the terminal (root for instance)
the command would be executed in root's shell with root permissions.

Frank.
-- 
| Frank van Beek          -            NeoGeo / Enji |
| frank@neogeo.nl         -     http://www.neogeo.nl |
| voice: (+31) 40 2126588 -    fax: (+31) 40 2125776 |


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

Date: 4 May 1998 14:15:01 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: cd with a perl-script
Message-Id: <6ikih5$15i$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, frank@neogeo.nl (Frank van Beek) writes:
:If you are able to write a small C-program it might be possible. It is
:possible to write a command to your controlling terminal. What you
:might do is:

    #!/usr/bin/perl -w
    require 'sys/ioctl.ph';
    die "no TIOCSTI" unless defined &TIOCSTI;
    sub jam {
        local $SIG{TTOU} = "IGNORE"; # "Stopped for tty output"
        local *TTY;  # make local filehandle
        open(TTY, "+</dev/tty") || die "no tty: $!";
        for (split(//, $_[0])) {
            ioctl(TTY, &TIOCSTI, $_) || die "bad TIOCSTI: $!";
        } 
        close(TTY);
    } 
    jam("@ARGV\n");

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

I'm a programmer: I don't buy software, I write it.
    --Tom Christiansen


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

Date: Mon, 04 May 1998 09:15:40 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
To: Arch <brian.archer@mailexcite.com>
Subject: Re: Complete Newbie - Where do I start?
Message-Id: <354DCD8C.A3BB8400@houston.Geco-Prakla.slb.com>

Arch wrote:
> 
> I hope someone can point me in the right direction....
> 
North/North-west has always worked well for me (:-)

> I want to learn Perl primarily to use at work.The only person where I
> work who knows Perl is leaving, but isn't replaced. A lot of Perl
> programs will be left behind, and I've been given the job of taking
> over.
Several options:
1)  Hire Randal Schwartz and/or Tom Christiansen to train you.
2)  Buy 'Learning Perl 2nd Ed.' (The Llama Book) by Randal Schwartz. 
Excellent starting point.
3)  Buy 'Programming Perl 2nd Ed.' (The Camel Book) by Schwartz, Larry
Wall, and Tom Christiansen.  Great reference, but I had trouble reading
& understanding this book as a relative newbie to programming in
general, and C/C++/sed/awk/shell specifically.
4)  Read them.
5)  Re-read them
6)  Learn about perldoc (perldoc perldoc is a good starting point)
7)  Learn about perlfaq (perldoc perfaq is a great starting point)
8)  Have a look at the FAQ you got in response to your post.
9)  Learn about CPAN (Comprehensive Perl Archive Network)
http://www.perl.com
10)  If you don't understand what you have read, play.
11)  If playing doesn't help, post example code to c.l.p.misc seeking
assistance.  Read the FAQ's first (perldoc perlfaq)

> 
> My programming skills are a little rusty - I was a decent "hobbyist"
> machine code programmer a few years ago, but the need and the interest
> wore thin.
> 
> Can anyone please tell me a good book to buy, or offer me any other good
> advice?
See above.

Read lots.  Play.  Playing is both fun & informative.  I can read books
until I fall asleep from exhaustion, but nothing truely hits home for me
unless I can play with the code while I am trying to learn.

> I need to be up to speed in about three weeks!
I'm sorry.  :-(

I've been at this for roughly 8-10 months, and am just now getting
pretty comfortable with the 'basics' of Perl.  Some of the advanced
stuff (object-oriented, signals, threads, etc.) is still rather
elusive.  That may be because I'm trying to learn C++ now, and not
concentrating on Perl at this point.  *shrug*

> 
> Many thanks in anticipation.
> 
> Brian Archer.
'May the force be with you.'

Cheers,
Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

----------------------------------------------------------------------
Dave Barnett                 U.S.: barnett@houston.Geco-Prakla.slb.com
DAPD Software Support Eng    U.K.: barnett@gatwick.Geco-Prakla.slb.com
----------------------------------------------------------------------


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

Date: 4 May 1998 09:42:43 -0400
From: pyz@panix.com (Max)
Subject: ctime.pl
Message-Id: <6ikgkj$64h@panix2.panix.com>

Greetings, 

Where can I find a copy of ctime.pl?

Much tanks in advance!!

Max Pyziur
pyz@panix.com


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

Date: 04 May 1998 10:46:17 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Directory usage in Perl for win32
Message-Id: <7m4282eu.fsf@mailhost.panix.com>

Mike Marziani <marz@tamu.edu> writes:

> But what is the best way to read in the list of directories and apply this
> function to each directory in turn?

Go ahead and purchase _Learning Perl_.  Your first hour's reading will
take you through enough Perl syntax to construct a loop that gives you
each element of an array in turn.  Here's a very broad hint:

   foreach my $file (@ARGV) {
      next unless -e $file and -d _;
      # $file is a directory.  Do something with it.
   }

Since you're already an experienced programmer, you should also buy
the Camel book.  Enjoy it!

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Mon, 4 May 1998 06:31:27 -0700
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: How can I delete a file from my perl program
Message-Id: <6ikfvf$dpt@bgtnsc03.worldnet.att.net>


ananta@w-o-i.com wrote in message <6ik5c1$brm$1@nnrp1.dejanews.com>...
>I am using IIS3.0 (NT4.0) with Perl for win32. On of my programs(see
below)
>is supposed to accept the filenames to delete in $value[$i] and delete
them.
>I tried using the system function for this purpose but it didnt work. I
am
>desperately seeking a solution. You are most welcome to send me email
>directly : ananta@w-o-i.com :-) Thanx Ananta


It might just be a problem of rm vs. del or erase, but you also have to
remember that if you're running this as a server process, it may have
different permissions than you yourself do, so it may not be able to
delete the file unless you give the process that permission.

HTH,

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl





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

Date: Mon, 04 May 1998 16:34:37 GMT
From: ali@genet.sickkids.on.ca (Alex Dong Li)
Subject: Re: How can I delete a file from my perl program
Message-Id: <6ikg0e$jv3$1@resunix.sickkids.on.ca>

Why use OS-dependent command, and why not use the build-in delete function:
unlink( ($filename));

??????????????

Alex


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

Date: Mon, 04 May 1998 14:13:55 GMT
From: jdporter@min.net (John Porter)
Subject: Re: How do I print a string that is in a certain format?
Message-Id: <MPG.fb798a4eca274e898969d@news.min.net>

On 1 May 1998 20:25:05 GMT,
in article <6idb31$8ra$0@206.165.146.151>,
alpaca@iname.com (Allan M. Due) wrote:
> 
> John Porter wrote in message ...
> ># parse it up into a table (2-d array):
> >@dd = map { /^\((.*)\)$/ ? [split(/:\s*/,$1)] : [$_] } split(/,\s*/,$a);
> 
> Yoeks!

O.k., first, let's reformat it to make it more legible:

$a = '231, Hello, 43, (big: medium: small), (right: wrong)';

@dd = 
map
  {
    /^\((.*)\)$/
    ?
      [split(/:\s*/,$1)]
    :
      [$_] 
  }
split( /,\s*/, $a );

The split says to parse the line on commas.  Remember that the
text which matches the regex in the split is discarded, so
in this case we're also taking out any spaces which may occur
after the commas.  This leaves us with a list containing the
following strings:
( '231', 'Hello', '43', '(big: medium: small)', '(right: wrong)' );
So it contains five strings.

Now the map does some regex test, and returns one of two possible
values, both of which are array-references.  map is allowed to
return any number of values, and the all get appended to the
resultant list (which in this case is assigned to @dd).  But
since in this case map only ever returns one single value (an
array-ref), the resultant list is exactly the same length as
the input list.  That means @dd will have five elements, one
for each of the strings in
( '231', 'Hello', '43', '(big: medium: small)', '(right: wrong)' )

Now, what's going on inside the map?
The idea is to take strings such as '231', 'Hello', and '43', and
return them as is, in an array of length one.  That's the
second (false) branch of the ternary operator.
Strings which start with left-paren and end with right-paren are
parsed on colons, into another list.  (The parens are first
removed, and any spaces after the colons are dropped, just as
with the commas, above.)  That means that
'(big: medium: small)' becomes ( 'big', 'medium', 'small' ).
And an anonymous array-ref is returned by map in the first (true)
branch of the ternary operator.

So, @dd end up looking like this:
@dd = (
  [ '231'                      ],
  [ 'Hello'                    ],
  [ '43'                       ],
  [ 'big',   'medium', 'small' ],
  [ 'right', 'wrong'           ]
);

We want to invert that, so that it looks like this:

@d = (
  [ '231', 'Hello', '43', 'big',    'right' ],
  [                       'medium', 'wrong' ],
  [                       'small'           ]
);

The code to do the inversion is pretty straightforward.

hth,
John Porter


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

Date: 4 May 1998 09:59:28 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: How many files can I open?
Message-Id: <6ikhk0$bhh$1@monet.op.net>
Keywords: cupidity EST legacy librettist


In article <6ijs0d$i6_001@its.csiro.au>,
Hans Xie <hans.xie@its.csiro.au> wrote:
>It looks like I can only open 60 files for writing.  When I try to open more, 
>the file is not created, and no complain information send back!

Hard to believe.  You probably forgot to check for an error.  When I
try this:

	open (FILE, ...) or warn "Couldn't open file: $!\n";


it says

	Couldn't open file: Too many open files

>How to get beyond this limits?  I need to open about 200 files for writing.

On some systems, including yours, you can use the `limit' or `rlimit'
commands to change the limit.

You can also use the `cacheout.pl' library to pretend that you have
more open files than you really have.  Before each write, you do
`cacheout($file)'.  If the file is still open, it does nothing; if
it's closed, it opens the file, possibly closing some other file if
necessary.



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

Date: 4 May 1998 13:23:39 GMT
From: kjetil.skotheim@usit.uio.no (Kjetil Skotheim)
Subject: Re: Max length of a string
Message-Id: <6ikfgr$7vj$1@ratatosk.uio.no>

In article <354DA092.1D9E9E1C@hp.com>, Dieter_Stolpmann@hp.com says...
>
>I need to analyse a huge file (up to 50MByte or more) which I have
>to read from STDIN. To make working/passing the file more easy to me,
>I would like to read it into a single string at the beginning of my program 
insteat of reading it
>line by line.
>
>Is there a limit in the string size, or any other major performance hit
>doing so? Anything else to watch out for?
>


Watch out for:
On the unix-system I use there is a per process limit at about 65MB.


Strange phenomenon:

perl5 -e '$a=('K' x 20000000)'
Results in 'Out of memory!'.

But:
perl5 -e 'for(1..50){ push(@a, ('K' x 1000000)) }'
 ...works fine.

In short: Using one 20MB string fails, but 50 1MB strings is ok.

Any explaination to this?



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

Date: 4 May 1998 14:25:54 GMT
From: kjetil.skotheim@usit.uio.no (Kjetil Skotheim)
Subject: Re: need help with hashtable size/memory
Message-Id: <6ikj5i$7vj$2@ratatosk.uio.no>
Keywords: Bantu blastula septate voice

In article <6idasf$nb7$1@monet.op.net>, mjd@op.net says...
>
>In article <3549E32B.803D4B0A@globin.bio.warwick.ac.uk>,
>Caroline Hadley  <hadley@globin.bio.warwick.ac.uk> wrote:
>>I'm creating 3 hashtables in my program, 2 of which have about 450,000
>>'keys' and associated values. The other one is smaller. I'm having huge
>>problems with the size of the program - most of the time it just crashes
>>after reaching about 120+Mb. I can't understand why it's getting this
>>big when the hashtables aren't that large.
>
>Me neither.  I just tested it by loading in a file with 270,000 keys
>and about 2.8MB of real data, and the perl process only got to consume
>about 40MB of VM.  I think there must be something going on here
>that's relevant that you didn't think to mention.
>
>>I'm trying to incorporate the Tie::SubstrHash module, but so far
>>haven't managed to get it to work.
>
>That will probably make the problem worse, not better.
>


Tie::SubstrHash works fine if the hash have constant length keys and
values. I found a bug thou, in SubstrHash.pm, that occurs when using
keys longer than 13(?) chars. But it was easily fixed by adding this:

$hash = substr($hash,-8) if length($hash)>13;

 ...just below $hash = $hash * 33 + $_; in sub hashkey


Ex.:
use Tie::SubstrHash;
tie %hash, Tie::SubstrHash, 28, 2, 450000; #28 char keys, 2 char values.
$hash{sprintf("%028d",$i)}=sprintf("%02d",$i%100) while ++$i<450000;



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

Date: Mon, 04 May 1998 14:39:57 GMT
From: jdporter@min.net (John Porter)
Subject: Off-topic (Re: Perl/Wall lingo question)
Message-Id: <MPG.fb79eba8c7a5bf198969f@news.min.net>

On Sat, 02 May 1998 01:11:48 -0400,
in article <354AAB16.16D1A506@coos.dartmouth.edu>,
rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:
> John Porter wrote:
> > 
> > Followup-To: jdport@min.net
> 
> Isn't that header supposed to refer to a list of newsgroups?

Sorry!  This Gravity newsreader is like a soldering iron in
the hands of a programmer.


> > () would represent zero dimensions,
> > but there's no place for the magnitude.  Thats why a 0d vector
> > is effectively no vector at all.  And that's why we can say that
> > scalars are dimensionless.
> 
> So scalars don't have magnitude?  That doesn't make sense.

You're right, that doesn't make any sense. Fortunately, that's
not what I said.  Or at least, not what I meant.

A scalar is like a vector, with zero slots to put the magnitude.
So what do we do?  Don't call it a vector.  It's just a 
magnitude.  O.k., maybe it's a poor analogy.  :-/

But hopefully we're now all straight that a scalar is not the
same as a 1d vector.

John Porter


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

Date: Mon, 04 May 1998 14:53:19 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Perl/Wall lingo question
Message-Id: <MPG.fb7a1de2e98f8ee9896a0@news.min.net>

On Sat, 2 May 1998 15:31:28 +0200,
in article <354b30d0.0@care4all.nursing.nl>,
jmuris@igr.nl (Jeroen Muris) wrote:
> 
> Let me add to the confusion.
> 
> In mathematics I was told:
> * A point is dimensionless.
> * A line is 2-dimensional.
> * A plane is 3-dimensional.

I think you've got about as much confusion as you can handle, Jeroen.
I would recommend, if possible, suing your math instructor or institution
for fraud.  Here's the real deal:
  Point: 0 dimensions
  Line:  1 dimension
  Plane: 2 dimensions
  Space: 3 dimensions

This corresponds to the number of legs of a vector needed to specify
the location of a point from some origin point.  (x,y), (x,y,z), etc.
Since this looks like an array, arrays are sometimes called vectors,
in computer lingo.

>...
> But if you start thinking of variables, things become ugly:

Things all already ugly enough, thanks.

John Porter


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

Date: Mon, 04 May 1998 10:00:32 -0400
From: Tod Thomas <tthomas@chubb.com>
Subject: Regex Question
Message-Id: <354DCA00.4C05261B@chubb.com>

I have a string value that contains special characters.  I want to pull
out all of the characters up to the first special character, excluding
it and any character following.  For example:

String contains:  Test User (this is a test) 

I want to end up with Test User only.  It looks easy but I've tried
everything.  Any help would be greatly appreciated.

Tod Thomas
The Chubb Corporation


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

Date: Mon, 04 May 1998 09:30:12 -0600
From: kathryn.nelson@usa.net
Subject: Splain a regex to me
Message-Id: <6ikjdn$u0j$1@nnrp1.dejanews.com>

I have been learning Perl for about a month now and while reading a lot of
code from various places, it would be very helpful if there was a script
which would take as input a regex and output a sentence describing what
this regex would match.

i.e. /[ab].+:(\s*)/
"starts with the letter a or b followed by one or more characters followed
by a colon and zero or more whitespaces which are remembered as $1..."

Has anyone seen something like this?

Kathy.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Mon, 04 May 1998 10:00:34 -0600
From: markem@flash.net (Mark Manning)
Subject: Re: Y2K and Perl
Message-Id: <markem-0405981000340001@houasc24-167.flash.net>

In article <354CB52F.5447857F@fccjmail.fccj.org>, bill@astro.fccj.cc.fl.us
wrote:

> Yes.  I have been using Perl to find 'problem spots' in other
> peoples COBOL code.  Which is where MOST of the Y2k issues lay.
> 
> Those blasted 'packed' data elements keep getting in the way...

Has it been helpful in making the changes too?  I wouldn't think so but on
the other hand - it might make it easier to create a new program with the
changes already in place.

Also, has there been quite a demand for this?  From the Y2K list it looks
like there is a really big demand for conversion.  But the recruiters I've
talked to seem to be sort of "Ho-hum, yeah, we do have some stuff for
that."

Very confusing.  :-/


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.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 2490
**************************************

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