[18823] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 991 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 26 06:05:32 2001

Date: Sat, 26 May 2001 03:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990871507-v10-i991@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 26 May 2001     Volume: 10 Number: 991

Today's topics:
    Re: -w and Text::Wrap <somewhere@in.paradise.net>
    Re: -w and Text::Wrap <godzilla@stomp.stomp.tokyo>
    Re: -w and Text::Wrap <somewhere@in.paradise.net>
    Re: Any d20 Gamers here? I'm building a GM aid... <goldbb2@earthlink.net>
    Re: archieve newsgroups (Eric Bohlman)
    Re: Base 6 sieve. <goldbb2@earthlink.net>
    Re: hash array <gisle@ActiveState.com>
    Re: hash array (Eric Bohlman)
        How to delete dupicate elements in array? <cadmcse@hotmail.com>
    Re: I don't want global variables ? <pne-news-20010526@newton.digitalspace.net>
    Re: I don't want global variables ? <uri@sysarch.com>
    Re: I don't want global variables ? <godzilla@stomp.stomp.tokyo>
        Long names are doom ? <00001111@aol.com>
    Re: Newbie: how can I shorten a repetitive regular expr <goldbb2@earthlink.net>
        ntemacs and cperl mode (Chris)
    Re: Perl script error during testing (Eric Bohlman)
    Re: Perl script error during testing <godzilla@stomp.stomp.tokyo>
    Re: random numbers <uri@sysarch.com>
    Re: random numbers <godzilla@stomp.stomp.tokyo>
    Re: random numbers <godzilla@stomp.stomp.tokyo>
    Re: random numbers <goldbb2@earthlink.net>
    Re: Sorting data file on numerical field <goldbb2@earthlink.net>
        split'ing a pipe (|) delimited file <toxlists@canada.com>
    Re: split'ing a pipe (|) delimited file <krahnj@acm.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 26 May 2001 16:00:52 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: -w and Text::Wrap
Message-Id: <uEHP6.5$Iw4.197725@news.interact.net.au>


"Thorbjørn Ravn Andersen" <thunderbear@bigfoot.com> wrote in message
news:3B0E3D49.F7390C28@bigfoot.com...
>
> > Name "Text::Wrap::columns" used only once: possible typo at ......
> >
> > How do I pre-declare the variable, or get warnings to shut up?
>
> Just have the line two times.

Not really the desirable solution.  I guess, I'll just turn warning off for
that line.




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

Date: Sat, 26 May 2001 01:19:47 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: -w and Text::Wrap
Message-Id: <3B0F6723.6398EC43@stomp.stomp.tokyo>

Tintin wrote:
 
> I'm trying to be a good boy and use -w and use strict with all my scripts.

I am not convinced this is always such a good thing to do.

 
> I'm using Text::Wrap by importing it when required, eg:
 
> require Text::Wrap;
> Text::Wrap->import('wrap');
 
> $Text::Wrap::columns=60;
 
> This produces:
 
> Name "Text::Wrap::columns" used only once: possible typo at ......
 
> How do I pre-declare the variable, or get warnings to shut up?


#!perl -w

use Text::Wrap;
Text::Wrap->import('wrap');
$Text::Wrap::columns=60;


OR


#!perl -w

use Text::Wrap qw(wrap $columns);
my ($columns) = 60;


I've never used Text Wrap having no use for it.
Test this syntax well. This is one of those rare
times I post untested code.

Godzilla!


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

Date: Sat, 26 May 2001 19:29:37 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: -w and Text::Wrap
Message-Id: <cIKP6.9$aW4.1207424@news.interact.net.au>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3B0F6723.6398EC43@stomp.stomp.tokyo...
> Tintin wrote:
>
> > I'm trying to be a good boy and use -w and use strict with all my
scripts.
>
> I am not convinced this is always such a good thing to do.

In this case, the script is getting very long and complex, so believe me,
it's a good idea.  When I first wrote the script about 4 years ago, my Perl
experience wasn't great, so I've been in the process of tidying up the code.

>
>
> > I'm using Text::Wrap by importing it when required, eg:
>
> > require Text::Wrap;
> > Text::Wrap->import('wrap');
>
> > $Text::Wrap::columns=60;
>
> > This produces:
>
> > Name "Text::Wrap::columns" used only once: possible typo at ......
>
> > How do I pre-declare the variable, or get warnings to shut up?
>
>
> #!perl -w
>
> use Text::Wrap;
> Text::Wrap->import('wrap');
> $Text::Wrap::columns=60;

I was under the impression that 'use' did an automatic import, so the second
line is redundent.

>
>
> OR
>
>
> #!perl -w
>
> use Text::Wrap qw(wrap $columns);
> my ($columns) = 60;

This will work, but I only want to use the module in certain circumstances,
hence the require/import.






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

Date: Sat, 26 May 2001 03:20:40 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Any d20 Gamers here? I'm building a GM aid...
Message-Id: <3B0F5948.15D81D1@earthlink.net>

Brent Stroh wrote:
> 
> Some aspects of this seem like taking a sledgehammer to a gnat, but
> it's given me an excuse to read and understand perltoot, and spend a
> lot more time with references - things I've never pushed myself to
> learn before.

This has nothing to do with your code itself, but if you're looking to
make a shell, you might want to consider the Term::Readline module.

-- 
#! perl -- This took a heck of a lot of work to make.  I hope it works.
@p{split//,'justaperlhacker'}=map oct,qw(6b 71 83 1c1 43 2 3 5 79d 71db
7835 1ddf07 23a871 72656b63); print map {$e=1;for(split//){$e*=$_};pack
'V',$e} qw(ptk ppppprre pperrrlau ppppphc ppjsa r);


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

Date: 26 May 2001 05:12:58 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: archieve newsgroups
Message-Id: <9ene0q$p69$5@bob.news.rcn.net>

me@nowhere.com wrote:
> is it ethical to copy the newsgroups from google into my database?

Depends on what you're going to *do* with the database, but I don't see 
any Perl issue here.



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

Date: Sat, 26 May 2001 01:22:25 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Base 6 sieve.
Message-Id: <3B0F3D91.1103720D@earthlink.net>

Anno Siegel wrote:
[snip] We know by how much the next number is incremented
> > (2 * $n and 4 * $n (results that could have been cached)), but
> > there's a linear relationship between the skips in numbers and the
> > skips in
> 
> Well, linear it isn't but it's certainly one-to-one since it's
> strictly monotonous.

Shouldn't that be monotonic, not monotonous?
It it were monotonous, we wouldn't be interested :)

-- 
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."


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

Date: Sat, 26 May 2001 05:10:05 GMT
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: hash array
Message-Id: <m3lmnkk80u.fsf@ActiveState.com>

mjd@plover.com (Mark Jason Dominus) writes:

> In article <ndAP6.70962$I5.15872424@news1.rdc1.tn.home.com>,
> Todd Smith <todd@designsouth.net> wrote:
> >How do you ask a hash how big it used to be?
> 
> Devel::Peek, perhaps.

You can also get that number with code like this:

  $size = do { local $hash{x} = 1; (split "/", %hash)[1] };

-- 
Gisle Aas


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

Date: 26 May 2001 05:24:20 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: hash array
Message-Id: <9enem4$p69$7@bob.news.rcn.net>

Todd Smith <todd@designsouth.net> wrote:
>> > >
>> > >        %hash = ();
>> >
>> > Better, worse or same as
>> >
>> >          undef (%hash);
>>
>> That depends if you want %hash to rember how many buckets it grew to
>> last time.

> How do you ask a hash how big it used to be?

my ($used,$allocated)=split(/\//,scalar %hash);


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

Date: Sat, 26 May 2001 09:37:58 GMT
From: "vector" <cadmcse@hotmail.com>
Subject: How to delete dupicate elements in array?
Message-Id: <WPKP6.43038$ko.541239@news1.frmt1.sfba.home.com>

suppose I have array @lists ,
inside many elements are the same,
How to delete the dupicate and
keep each element in array is uniq & pirnt out??





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

Date: Sat, 26 May 2001 06:22:17 +0200
From: Philip Newton <pne-news-20010526@newton.digitalspace.net>
Subject: Re: I don't want global variables ?
Message-Id: <ebbugtsef1j7chtoqn1c36q49559g9e5qm@4ax.com>

On 25 May 2001 20:52:21 GMT, Eli the Bearded <elijah@workspot.net>
wrote:

> In comp.lang.perl.misc, Abigail <abigail@foad.org> wrote:
> >      ;+
> >          {
> >              my $foo = "Gotcha"
> >          ,   my $bar = "Really!"
> >          }
> 
> But this gives me a parse error:
> 
> 	+{my$c="Gotcha";my$d="Again"};print$c.$d

Note that Abigail used a comma, not a semicolon, in there.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sat, 26 May 2001 04:33:19 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I don't want global variables ?
Message-Id: <x7vgmo20hb.fsf@home.sysarch.com>

>>>>> "JS" == Joe Schaefer <joe+usenet@sunstarsys.com> writes:

  A> #!/opt/perl/bin/perl -l
  A> use strict;
  >> 
  A> {
  A> ;+
  A> {
  A> my $foo = "Gotcha"
  A> ,   my $bar = "Really!"
  A> }
  >> 
  A> ;   # Enclosing scope.
  A> ;   print $foo
  >> 
  A> }
  A> __END__
  A> Gotcha
  >> 
  JS> Huh?  Try enabling warnings to see exactly what those inner 
  JS> "curly braces" are doing.

my guess is that it is anon hash (the + is a major clue) and that is
true. i think i jumped into the middle of the thread which can be
confusing. in playing with it i may have commented the + so i got the
strict error instead.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Sat, 26 May 2001 00:05:36 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I don't want global variables ?
Message-Id: <3B0F55C0.8B9B1957@stomp.stomp.tokyo>

Uri Guttman wrote:
 
> >>>>> "JS" == Joe Schaefer wrote:

(snipped)

>   JS> Huh?  Try enabling warnings to see exactly what those inner
>   JS> "curly braces" are doing.
 
> my guess is that it is anon hash (the + is a major clue) and that is
> true. i think i jumped into the middle of the thread which can be
> confusing. in playing with it i may have commented the + so i got the
> strict error instead.


Oh my. 


"...pooh-poohed all comments about that away."

    - Uri


* enjoys a laugh *

Godzilla!


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

Date: Sat, 26 May 2001 01:23:37 -0700
From: 00001111 <00001111@aol.com>
Subject: Long names are doom ?
Message-Id: <3B0F6809.B9EE02A9@aol.com>

 Hi All,

  Anybody use variables/names longer than 31 character
and finds it really useful ?

Then please respond  why, where, when.
I have folks here in comp.lang.fortran who will die claiming that they

- "never seen a well written, legible program
  that uses any identifiers longer than 18-20 characters..".
- "long variables names are *hard* to read.  And, you have to
  read though all the characters of every instance of them...".
- "it degrades the legibility of a program to use identifiers that
  can't be easily remembered...."

As a result, despite 90% of computer languages have long, very
long or 'infinite' identifiers, fortran folks seems plan to stay
with their 6...aargh ...sorry this was just not far ago... 31 character
limit intil year 3000.

cheers



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

Date: Sat, 26 May 2001 05:58:04 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Newbie: how can I shorten a repetitive regular expression?
Message-Id: <3B0F7E2C.85D21666@earthlink.net>

David Wake wrote:
> 
> It seems as if there must be some way of shortening code like this.
> Can anyone help?
> 
>     if ( m{CONTACT\sINFORMATION\s+
>                   Name:\s+
>                   (\w[\w\s]+?)\s+     #name
>                   City:\s+
>                   (\w[\w\s]+?)\s+     #city
>                   State:\s+
>                   (\w[\w\s]+?)\s+     #state
>                   Zip\sCode:\s+
>                   (\w[\w\s]+?)\s+     #zip
>                   }sx ){
>     print "Name = $1 \n" ;
>     print "City = $2 \n" ;
>     print "State = $3 \n" ;
>     print "Zip = $4 \n" ;
> }

my $____ = qr/\s+(\w[\w\s]+?)\s+/;
if ( m{CONTACT\sINFORMATION\s+
	Name:$____ City:$____ State:$____ Zip\sCode:$____ }sxo ) {
	print "Name  = $1\n";
	print "City  = $2\n";
	print "State = $3\n";
	print "Zip   = $4\n";
}

Note that the /o causes the interpolation to happen only once, the first
time the expression is matched.  A smart perl compiler would see that
$____ is not used anywhere else in the program except that expression,
and see that /o, and do the interpolation and regexp compilation at
compile time, and throw away [free up] $____.

-- 
#! perl -- This took a heck of a lot of work to make.  I hope it works.
@p{split//,'justaperlhacker'}=map oct,qw(6b 71 83 1c1 43 2 3 5 79d 71db
7835 1ddf07 23a871 72656b63); print map {$e=1;for(split//){$e*=$_};pack
'V',$e} qw(ptk ppppprre pperrrlau ppppphc ppjsa r);


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

Date: 26 May 2001 00:52:30 -0700
From: chrisl_ak@hotmail.com (Chris)
Subject: ntemacs and cperl mode
Message-Id: <b62b39cb.0105252352.4d57cdd9@posting.google.com>

Has anyone gotten the perldoc functions (help on function and perldoc)
working with ntemacs? I'm running activestate perl 5.6.1

perldoc works from the command line, but cperl appears to be trying to
spawn a bash shell?

help on function complains about a missing perl info file...

c


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

Date: 26 May 2001 05:18:13 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Perl script error during testing
Message-Id: <9eneal$p69$6@bob.news.rcn.net>

sloon <sloon@mindless.com> wrote:
> Very often, when I'm developing a perl script, I will make slight
> modifications to the script and upload it to the intended server to
> test the modifications. I might do this 30 or 40 times and it seems
> that after a while, I get an error that the script cannot be run. Even
> if I refresh it, reload it..etc.

> THEN, if I shut down my computer and start it again, the script will
> run correctly.

> I'm usually using IE 5. 

> My question is: 

> Is this due to IE getting tired of opening the same script and
> refusing to do it anymore or is it something server-side, the server
> stops any more requests to the particular script that I'm requesting?

> Even if I just rename a working script to the name of the script that
> now gives an error, I still get the error unless I shut down and start
> again. I've got IE set to always get a new version of the page.

> I'm slightly bamboozled.

I have no idea.  Try grabbing a copy of Opera (since it's a quick 
download) and see if you have the same problem with it.

However, you're doing everything the hard way.  Install Perl on your own 
machine (if you haven't done so already) and then install a Web server (I 
recommend Apache) on your own machine (setting it up to only take requests 
from your local machine).  That way you can do most of the testing of your 
CGI scripts locally.  You'll find that you'll only have to go through the 
upload/test cycle 3 or 4 times instead of 30 or 40.



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

Date: Sat, 26 May 2001 01:41:23 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Perl script error during testing
Message-Id: <3B0F6C33.11EE60F1@stomp.stomp.tokyo>

sloon wrote:

> Very often, when I'm developing a perl script, I will make slight
> modifications to the script and upload it to the intended server to
> test the modifications. I might do this 30 or 40 times and it seems
> that after a while, I get an error that the script cannot be run. Even
> if I refresh it, reload it..etc.

(snipped)

Post your error message verbatim including generation source,
and post your server type.

Two pertinent questions would be are you experiencing
core dumps into your script directory and, is your server
protected by anti-denial-of-service (dOs) software?

Consider installing Indigo Perl on your local machine
for testing. This is so much better for local testing
save for those scripts requiring an internet connection.
You will have access to lots of Apache log records which
are of great help along with full Perl documentation
including comprehensive Perl module documentation.

Indigo Perl is free and includes an Apache web server.
Installation is one button click easy. It includes good
documentation on how to configure Apache to your specs.

http://www.indigostar.com/indigoperl.htm


Godzilla!


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

Date: Sat, 26 May 2001 04:39:17 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: random numbers
Message-Id: <x7r8xc207d.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

  G> (snipped lots of codes all of which take forever to run)

and you suggested one that is broken

  G> use Time::Local;
  G> $id_number = timelocal (localtime()); sleep (1);

that code is the same as just time().

and what if two requests come in during the same second?

you have posted stuff before which works some or most fo the time and
pooh-poohed all comments about that away. just never do this for any
professional site where this matters and the hit rates are high.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Sat, 26 May 2001 00:01:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: random numbers
Message-Id: <3B0F54BD.69A3F0C2@stomp.stomp.tokyo>

Uri Guttman wrote:
 
> >>>>> "G" == Godzilla! the greatest living Perl hacker ever, wrote:
 
>   G> (snipped lots of codes all of which take forever to run)
 
> and you suggested one that is broken

Works fine for me. Your system is broken.

 
>   G> use Time::Local;
>   G> $id_number = timelocal (localtime()); sleep (1);
 
> that code is the same as just time().

Yeah, so? My code is significantly more impressive
looking than yours. Isn't this the idea when you
boys play your never ending weenie wagging game? 
Suppose us girls will never learn how to play right.


> and what if two requests come in during the same second?

Who said anything about requests? I did not. The originating
author did not. I think you are going blind from masturbating
your ego way WAY too much.

 
> you have posted stuff before which works some or most fo the time and
> pooh-poohed all comments about that away. 

I post code which is tested, which works, which is well commented and,
is almost always significantly more efficient than what you boys post.


> just never do this for any professional site where this matters
> and the hit rates are high.

Isn't this why I tell perl core to go nite-night? Professional?
PROFESSIONAL!! Professional work here?

* maniacal laughter *


 "Many of the experts have long since left.  Thank goodness some
  are still here.  Hang around a while and you'll figure out
  who they are pretty quickly."

   - Henry Hardly

Now that is really funny!

Like my name pun? You remember this other Henry from last year
who caused problems here for a month or more with his obsessive
asinine verbose arguments? Well, do you?

I had considered commenting upon his quote. However, you boys,
well, your overhead light bulbs are burnt out. Not a chance any
of you would understand much of anything halfway intelligent.

There is no doubt none of you have pondered why the true experts
abandoned this newsgroup so long ago.

Those true experts just don't have the personal fortitude I have.


Godzilla!


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

Date: Sat, 26 May 2001 00:24:34 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: random numbers
Message-Id: <3B0F5A32.B793CA38@stomp.stomp.tokyo>

Godzilla! wrote:
 
> Uri Guttman wrote:
 
> > >>>>> "G" == Godzilla! the greatest living Perl hacker ever, wrote:
 
(snipped)

>  "Many of the experts have long since left.  Thank goodness some
>   are still here.  Hang around a while and you'll figure out
>   who they are pretty quickly."
 
>    - Henry Hardly
 
> Now that is really funny!
 
> Like my name pun? You remember this other Henry from last year
> who caused problems here for a month or more with his obsessive
> asinine verbose arguments? Well, do you?


I hear you whimpering "Uncle" already Uri. Please whimper "Aunt"
for me. I am not an uncle. Truth is, I can never be an aunt anyhow.
I have no siblings. Nonetheless, don't say uncle around me.

You need some help, I can tell by the sound of your pleading voice,
which more closely sounds like bleating.

Henry Hardly of last year, annoyed all of us by spamming this group
with pages of long arguments demanding he be allowed to setup an autobot
for this newsgroup. His autobot would reject any postings from newbies
for a required waiting period of seven days, email each newbie a copy
of the FAQ for this group based on a premise they "must" read the FAQ
before posting, along with other dictates.


Sound like a familiar theme of late, Uri?


Darn boys, you just never pay attention nor remember anything.


Godzilla!


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

Date: Sat, 26 May 2001 05:42:28 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: random numbers
Message-Id: <3B0F7A84.72F89662@earthlink.net>

Godzilla! wrote:
> 
> Benjamin Goldberg wrote:
> 
> > Garry Williams wrote:
> 
> > >  Bart Lateur  wrote:
> > > > sas wrote:
> 
> (snipped lots of codes all of which take forever to run)
> 
> > Would anyone like to suggest any other algorithms?
> 
> Yes.
> 
> use Time::Local;
> $id_number = timelocal (localtime()); sleep (1);

Considering that the OP wants a 5 digit number, this will get truncated
by a mod 100_000, and padded on the left with 0s.

What happens if a new id is created exactly some multiple of 100_000
seconds of some earlier used id?  Especially as the database approaches
being full.  *Your* code breaks, that's what happens.  You get two
people with the same id.

Now, considering that rand is seeded using time, please tell me why your
[broken] code is any better than:

$new_id = int rand 100_000;
for( 1..100_000 ) {
        if( unused( $new_id ) ) {
                return $new_id;
        } else {
                $new_id = $new_id + 1 % 100_000;
        }
}
return undef;

Especially since mine *works*, all the time, and yours doesn't unless if
the database is nearly empty (and even then, there's a chance of yours
not working).

-- 
#! perl -- This took a heck of a lot of work to make.  I hope it works.
@p{split//,'justaperlhacker'}=map oct,qw(6b 71 83 1c1 43 2 3 5 79d 71db
7835 1ddf07 23a871 72656b63); print map {$e=1;for(split//){$e*=$_};pack
'V',$e} qw(ptk ppppprre pperrrlau ppppphc ppjsa r);


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

Date: Sat, 26 May 2001 01:06:22 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Sorting data file on numerical field
Message-Id: <3B0F39CE.1A97AF8F@earthlink.net>

Abe Timmerman wrote:
[snip]
> # print the sorted data as table
> print table( { -border => 1 }, map Tr([ td( $_ ) ])
>         => sort { $a->[5] <=> $b->[5] } @lines );

The [ ] inside of tr are extraneous.  Also, putting the => on the second
line makes things less readable, not more.

print table( { -border => 1 }, map Tr(td($_)),
	sort { $a->[5] <=> $b->[5] } @lines );

Does anyone know why sort wasn't written to take
	sort EXPR, LIST
as map can, and why map and grep aren't written to take
	map SUBNAME LIST
	grep SUBNAME LIST
as sort can?

-- 
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."


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

Date: Sat, 26 May 2001 03:36:48 -0400
From: Jennifer <toxlists@canada.com>
Subject: split'ing a pipe (|) delimited file
Message-Id: <3B0F5D10.D3E7B269@canada.com>

I have a pipe delimited file and I am trying to split it, but
instead of split'ing on the pipe it seems to be split'ing into
each character.  So how should I split it?

Jennifer


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

Date: Sat, 26 May 2001 08:27:27 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: split'ing a pipe (|) delimited file
Message-Id: <3B0F690F.EF5E409A@acm.org>

Jennifer wrote:
> 
> I have a pipe delimited file and I am trying to split it, but
> instead of split'ing on the pipe it seems to be split'ing into
> each character.  So how should I split it?

It sounds like you are using split like:
split( "|", $line ) or split( /|/, $line )

But because the first argument to split is a regular expression and the
vertical bar character (|) is special in regular expressions (perldoc
perlre) it is the same as using split like this:
split( //, $line )

What you need to do is escape any special characters in regular
expressions.
split( /\|/, $line )


John
-- 
use Perl;
program
fulfillment


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 991
**************************************


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