[11848] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5448 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 22 02:07:27 1999

Date: Wed, 21 Apr 99 23:00:20 -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           Wed, 21 Apr 1999     Volume: 8 Number: 5448

Today's topics:
    Re: "unterminated character constant"? (Ronald J Kimball)
    Re: \s+ and ' ' in split (Abigail)
    Re: CGI programmer wanted (Tom Mornini)
    Re: CGI programmer wanted (David H. Adler)
        Cookies. <slanicky@students.uiuc.edu>
    Re: Cookies. (Abigail)
    Re: Database Converter (Abigail)
    Re: FAQ 4.11: How do I find the current century or mill (Abigail)
    Re: FAQ 4.13: How can I take a string and turn it into  <wyzelli@yahoo.com>
    Re: Generating a unique string for order number (Ronald J Kimball)
    Re: Help! Error message when using C-comment stripper f (Abigail)
    Re: How can I do wildcard file test? (Ronald J Kimball)
        How can I write a script in perl for uploading files? (Jimmy Huang)
    Re: How to change an array to a list? (Ronald J Kimball)
    Re: How to make an array name to be a variable? <uri@sysarch.com>
        http related module ? (Ching-Yu Lin)
    Re: Is it REALLY impossible to install Perl on Windoze? <watcher_q@my-dejanews.com>
    Re: last item in associative array. <jamesht@idt.net>
    Re: last item in associative array. <jamesht@idt.net>
    Re: last item in associative array. <jamesht@idt.net>
    Re: last item in associative array. <jamesht@idt.net>
        no signal called on child exit, on linux? <jamesht@idt.net>
    Re: Perl notation question? <wyzelli@yahoo.com>
        remove space <dbws@----nospam----hotmail.com>
    Re: Server Push (David Efflandt)
    Re: Sorting Hashes of Arrays.... <aqumsieh@matrox.com>
    Re: Suggestions and oneliners for Perl-talk? <aqumsieh@matrox.com>
    Re: The Future of Tk? (dg)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 22 Apr 1999 01:19:55 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: "unterminated character constant"?
Message-Id: <1dqn07z.1r9521x3yhh36N@p55.block2.tc5.state.ma.tiac.net>

Neil Cherry <njc@dmc.uucp> wrote:

> I'm getting the following:
> 
> :13: unterminated character constant
> 
> I have only one 13 in an array reference (that doesn't make sense) and
> I have no ^M's (unix). So what is this and how can I find this.

I don't believe that that is a Perl error message.  How are you
attempting to execute your script?

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        perl -le 'print "Just another \u$^X hacker"'


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

Date: 22 Apr 1999 05:31:44 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: \s+ and ' ' in split
Message-Id: <7fmc80$7gt$5@client2.news.psi.net>

Kin Cho (kin@symmetrycomm.com) wrote on MMLX September MCMXCIII in
<URL:news:19990422020153.15009.qmail@nym.alias.net>:
^^ What's the difference between ' ' and \s+ when used in split?
^^ In the following code, ' ' behaves as expected, but not \s+.


Because you expect the wrong thing. 

This is explained in the manual. IN FACT, IT EVEN DISCUSSES THE
DIFFERENCE BETWEEN SPLITTING ON ' ' AND SPLITTING ON /\s+/!


Now, I could explain the difference as well, but clearly, you
haven't mastered the concept of reading yet.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Thu, 22 Apr 1999 05:09:02 GMT
From: tmornini@netcom.com (Tom Mornini)
Subject: Re: CGI programmer wanted
Message-Id: <tmorniniFAKrn2.8Fx@netcom.com>

: + I saw Alyssa Milano testifying on CSPAN about it last year.

: Yes, yes, but did she have any clothes on while testifying?

: James - and was she given an invitation to visit the Oval Office?

I think she's more Lincoln Bedroom material, don't you think?

-- Tom Mornini
-- InfoMania


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

Date: 22 Apr 1999 01:59:44 -0400
From: dha@panix.com (David H. Adler)
Subject: Re: CGI programmer wanted
Message-Id: <slrn7htem9.sbf.dha@panix.com>

>Tad McClellan wrote:
>> 
>> David Cassell (cassell@mail.cor.epa.gov) wrote:
>> [snip down to highlight]
>> 
>> : Of course, we all know that CGI == Perl.
>>                               ^^^^^^^^^^^
>> 
>>    I'm sure you meant:        CGI eq Perl

Only if you don't want it to return true...

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Any sufficiently advanced technology is compatible with magic.
	- The Doctor, _Seeing I_


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

Date: Wed, 21 Apr 1999 23:04:14 -0500
From: Kevin Slanicky <slanicky@students.uiuc.edu>
Subject: Cookies.
Message-Id: <Pine.SOL.3.96.990421230033.19410A-100000@ux9.cso.uiuc.edu>

If some one out there is a resident "expert" on Perl and would offer me
some help with a script I'm trying to make work, could you please email
me?  The gist of the problem is this:

I can set a cookie fine using:

&setCookie("10", "3:2K 1/2W:18",  $expDate, $path, $domain);

Where setCookie is defined below.  THIS works fine. 

Hoowever, when I try replacing the value field (3:2K 1/2:18) with a Perl
variable ($description) it will never delete it (or maybe not even create
it) correctly.  This is the basis of the problem.  If you have time, and
would be so kind to help me out, please email me and we can talk more.
Basically I'll send you my code.  I've been working on this for at least
15 hours, and am about to give up.  However, it's my Senior Design project
for school, so I really can't.  :)  Thanks to anyone out there.

//////////////////////////////
///Kevin Slanicky         ///
//University of Illinois ///
/Illini Hockey # 16     ///
--------------------------



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

Date: 22 Apr 1999 05:10:02 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Cookies.
Message-Id: <7fmava$7gt$2@client2.news.psi.net>

Kevin Slanicky (slanicky@students.uiuc.edu) wrote on MMLX September
MCMXCIII in <URL:news:Pine.SOL.3.96.990421230033.19410A-100000@ux9.cso.uiuc.edu>:
"" If some one out there is a resident "expert" on Perl and would offer me
"" some help with a script I'm trying to make work, could you please email
"" me?  The gist of the problem is this:
"" 
"" I can set a cookie fine using:
"" 
"" &setCookie("10", "3:2K 1/2W:18",  $expDate, $path, $domain);
"" 
"" Where setCookie is defined below.  THIS works fine. 

No it isn't. There's no code.

"" Hoowever, when I try replacing the value field (3:2K 1/2:18) with a Perl
"" variable ($description) it will never delete it (or maybe not even create
"" it) correctly.

"it will never delete it". What it will never delete what other it?

""                 This is the basis of the problem.

What problem? You're setting a cookie, right? And something doesn't get
deleted by someone. So what? All you want is setting anyway, not deleting.



Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: 22 Apr 1999 05:11:57 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Database Converter
Message-Id: <7fmb2t$7gt$3@client2.news.psi.net>

JJ (webdude@mcminn.net) wrote on MMLX September MCMXCIII in
<URL:news:HxuT2.2394$94.998891@news1.usit.net>:
^^ I am trying to convert letters in a database into words for output to a
^^ webpage..ie First field of database might be ^DJI to Dow Jone Industry..Next
^^ line of database ^IXIC to NASDAQ.. (its a flat database)
^^ 
^^  Is this possible?


Why wouldn't it be? A harder question would be to find a language where
it would take more than 10 lines (except for the translation data) to
code this.



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


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

Date: 22 Apr 1999 05:05:47 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: FAQ 4.11: How do I find the current century or millennium?
Message-Id: <7fmanb$7gt$1@client2.news.psi.net>

Larry Rosler (lr@hpl.hp.com) wrote on MMLX September MCMXCIII in
<URL:news:MPG.11882da96a36fbf5989905@nntp.hpl.hp.com>:
"" [Posted and a courtesy copy sent.]
"" 
"" In article <371e7b72@cs.colorado.edu> on 21 Apr 1999 19:29:22 -0700, Tom 
"" Christiansen <tchrist@mox.perl.com> says...
"" > In comp.lang.perl.misc, 
"" >     ada@fc.hp.com (Andrew Allen) writes:
"" > ::             return int((((localtime(shift || time))[5] + 1999))/100);
"" > ::             return 1+int((((localtime(shift || time))[5] + 1899))/1000);
"" > :
"" > :my simple brain finds the following easier to understand (removed a
"" > :redundant paren pair too):
"" > :
"" > :             return int(((localtime(shift || time))[5] + 1900 + 99)/100);
"" > :             return int(((localtime(shift || time))[5] + 1900 + 999)/1000);
"" > 
"" > But that code is different.  You just put us in the third
"" > millennium already. :-)
"" 
"" Methinks the code is the same.  Move the 1 inside the numerator after 
"" multiplying by 1000, add to 1899 = 2899; 1900 + 999 = 2899.  And they 
"" both return 2 for the millennium as expected.


Yes, and they are both wrong.


It's the not-always-so-nice "feature" of 0 being false that bites the person
in the year 2014 who wants to know in which century 'Jan 1 1970 0:00' was.

If only we had the ?? operator....


Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Thu, 22 Apr 1999 13:40:22 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: FAQ 4.13: How can I take a string and turn it into epoch seconds?
Message-Id: <MixT2.52$bD2.4748@vic.nntp.telstra.net>

Tom Christiansen wrote in message <371e9e1d@cs.colorado.edu>...
>(This excerpt from perlfaq4 - Data Manipulation
>    ($Revision: 1.46 $, $Date: 1999/04/20 18:59:53 $)
>part of the standard set of documentation included with every
>valid Perl distribution, like the one on your system.
>See also http://language.perl.com/newdocs/pod/perlfaq4.html
>if your negligent system adminstrator has been remiss in his duties.)
>
>  How can I take a string and turn it into epoch seconds?
>
>    If it's a regular enough string that it always has the same format,
>    you can split it up and pass the parts to `timelocal' in the
>    standard Time::Local module. Otherwise, you should look into the
>    Date::Calc and Date::Manip modules from CPAN.
>
>--
>When I was a boy I was told that anybody could become President.  Now
>I'm beginning to believe it.
>                --Clarence Darrow

This was a FAQ I looked through yesterday whilst trying to figure out how to
turn a string of epoch seconds into a date and time format.

I was already familiar with the

localtime(time)

 function and after a bit of klutzing around (my specialty) I figured I
could stick the string in a variable and do

localtime($variable)

Hey Presto.

However... is this the best way to perform this operation or is there
something better?

'Lookin for clues...'

Wyzelli




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

Date: Thu, 22 Apr 1999 01:19:56 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Generating a unique string for order number
Message-Id: <1dqn0rv.8y4jyh1f6tljuN@p55.block2.tc5.state.ma.tiac.net>

Greg McCann <gregm@well.com> wrote:

> I'm working on an e-commerce application where I would like to generate a
> unique, mostly numeric string for a new order number.
> 
> Here are some of the possibilities I have considered.  I don't think that
> any of these alone are sufficient but combining two of them may give me
> something close to what I want.  I would appreciate any suggestions or
> insights into this problem.
> 
> time - I think this is a good start, but not to be used alone since two
> customers may submit an order at the same time (within the same second).

As you said, not sufficient by itself.

> rand - May be good concatenated with time.  I'm a little afraid of creating a
> duplicate order number one in a gazillion times though.

rand() generates random numbers.  It does *not* generate unique numbers.
Using rand when you need unique numbers is, IMO, stupid.

> ip address - Bad.  Users behind a firewall may all have the same apparent ip
> address.

As you say, this is not a very good idea.

> $$ (process id) - May be good concatenated with time.  It's especially
> nice on a *nix system, since it returns numbers that don't repeat for a
> long time.  On my NT system though, it is a pattern that repeats within
> 10-20 numbers.

Another bad idea.  The numbers do repeat eventually.  Process ids are
unique, but they have a temporary lifespan.  Using them for permanently
unique numbers doesn't make sense.


What's wrong with a simple counter?  Implement it just like a CGI
counter, with file locking.  You won't get repeating numbers if you
simply increment.  :)


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


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

Date: 22 Apr 1999 05:20:23 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help! Error message when using C-comment stripper from perlfaq
Message-Id: <7fmbin$7gt$4@client2.news.psi.net>

James R. Goodfriend (GoodfriB@jntf.osd.mil) wrote on MMLIX September
MCMXCIII in <URL:news:7flli5$5k2$1@news1.rmi.net>:
,, 
,, 	I'm using the massive regular expression listed in perlfaq6 to strip 
,, out the comments from a C file.  (I won't repeat my code here since mine 
,, exactly the same). When I run this using -w I get the following error message
,, 
,, Use of uninitialized value at (program) line 19, <CFILE> chunk 1.
,, 
,, 	...this shows up about 20 times.  Can anyone tell me what I can do to 
,, suppress this damn message?  It's driving me slowly insane...

Easy. You have an uninitialzed value at line 19 of your program.

,, ps. I'd copy a code chunk, but all my code is on a (government) secret machin
,, and I don't feel like manually typing it out...it really does look exactly li
,, the faq.

Well, the program in the faq is only 4 lines long. So, how are we supposed
to know what those other 15 lines are doing? If you can't be bothered
to post code, yet insist on quoting error messages that reference line
numbers, don't expect much help. The ESP modules are still in a very
alpha state.

,, 	Email preferred.  Thanks!

My email is on a secret machine, and I don't feel like manually typing
it out... it really does look exactly the same as my posting anyway.


Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


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

Date: Thu, 22 Apr 1999 01:20:00 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How can I do wildcard file test?
Message-Id: <1dqn14w.bp7jn213iai6hN@p55.block2.tc5.state.ma.tiac.net>

[posted and mailed]

Mark Silverblatt <mark.silverblatt@boeing.com> wrote:

> Wanna speed it up by first testing for...
> 
>  if (-e ( $fileBase. 'ANYTHING' )) { do something ) ;
> 
> ...i.e., for ANY extension, OR for a file named $fileBase
> with NO extension (to include a directory named $fileBase)
> 
> Simple * wildcard doesn't work.  Globbing syntax gleaned 
> from the O'Reilly books doesn't seem to work with the -e 
> "file exist?" operator.  My extreme ignorance serves to 
> exacerbate the problem.  Help!

Why would you use -e with a fileglob?  If the glob returns a filename,
you already know it exists, right?

Perhaps something like this...

@files = <$fileBase.*>;
if (@files) { do something }


And once you've read all those filenames in, no sense in using -e to
check for them again...

@files{@files} = 1 x @files;
if ($files{"$fileBase.jpg"}) { do this }
if ($files{"$fileBase.gif"}) { do that }


[untested]


HTH!

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
      perl -s -e'print sort grep { /\s/ } keys %main::
            ' -- -is -' Just' -' another ' -'Perl ' -'hacker 
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]


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

Date: Wed, 21 Apr 1999 05:30:29 GMT
From: jimmy_cat@990.net (Jimmy Huang)
Subject: How can I write a script in perl for uploading files?
Message-Id: <3721626c.18821139@news.sta.net.cn>

Thanks.


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

Date: Thu, 22 Apr 1999 01:20:01 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to change an array to a list?
Message-Id: <1dqn1dw.1rdgnvi193a596N@p55.block2.tc5.state.ma.tiac.net>

<yong321@yahoo.com> wrote:

> I have a strange question. I want to change @ary which contains "a", "b"
> elements to an "a", "b" list.

That is indeed a strange question.  Frankly, it makes no sense.
An array *is* a list; it's a list with certain special characteristics.


> Let me explain. I'm using the SMTP module. If
> the user enters the string "a@b.com c@d.com" which is passed in as $email, I
> want this:
> 
>       if ($email =~ / /)
>        { @email = split / /,$email;
>          $smtp->to(@email); #doesn't seem to work

How does it not seem to work?  What does @email contain at this point?

>        }
>       else
>        { $smtp->to($email);
>        }


> I know $smtp->to("a\@b.com", "c\@d.com") works, but $smtp->to
> ("a\@b.com,c\@d.com") does not. Please help. Thanks.

What does that have to do with what you wrote above?  Did you really
mean to split on comma instead of space?

-- 
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-


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

Date: 22 Apr 1999 00:50:53 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How to make an array name to be a variable?
Message-Id: <x7lnflcl76.fsf@home.sysarch.com>

>>>>> "r" == rbradlaw  <rbradlaw@my-dejanews.com> writes:

  r> although the previously posted responses are entertaining and maybe
  r> not without merit, i will optimistically think you just got a
  r> typopraphical error and really meant to type

  r>     print "$key: ${$array}{$key}\n";

ok, we have a winnah!! all future requests for symbolic ref stuff and
the bugs they will be forwarded to this guy who will help them out. he
thinks that hashes are not meritorious enough and symrefs are fine. he
obviously know better than all the guru types that inhabit this group
and who are on the verge of nervous breakdowns caused by the avalanche
of newbies asking how to make data structures with symrefs.

all hail rbradlaw, the newest perl hacker on the block, who is so
competent he uses symrefs with impunity and even posts from dejanews.

should we make a filter to search for "name to variable" and other
relates strings and just pass all of those posts directly to rbradlaw?
can you hack that rbradlaw or do you want to renege on your
disparagement of hashes?

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 22 Apr 1999 05:14:24 GMT
From: linjy@pdp.csie.nctu.edu.tw (Ching-Yu Lin)
Subject: http related module ?
Message-Id: <7fmb7g$22v$1@netnews.csie.NCTU.edu.tw>


hello,
I want to write a WWW client application in perl.
Are there any http module I can use ?
Or any sample code to refer to ? 
thanks in advance ,

-- 
E-mail : linjy@csie.nctu.edut.tw


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

Date: Thu, 22 Apr 1999 04:29:34 GMT
From: Watcher <watcher_q@my-dejanews.com>
Subject: Re: Is it REALLY impossible to install Perl on Windoze???
Message-Id: <7fm8jb$hur$1@nnrp1.dejanews.com>

In article <MPG.1186ed807b2b64c2989691@news.supernews.com>,
  mjw@bahnhof.se wrote:

<munch>
> More times than I want to remember I tried to install Perl
> under Win95, on three different machines:
> 1. My humble, hopelessly obsolete Pentium 133 MHz
> 2. Compaq Armada 233 MHz notebook in my office
> 3. A Dell desktop PC in my office.

I've done mine on a P90 with 64MB with 80 MB harddisk space...

> I used various builds of Perl. I tried many times to
> carry out every installation. I tried every conceivable
> measures, deactivated antivirus programs (WHY, ON EARTH,
> IS IT NECESSARY???), switched off the lights in my room,
> prayed to God and so on.

Have you tried to supplicate to Kibo? ;)

<munch>
> The ActiveState installation program freezes always
> when "preparing HTML documentation", at 95%, leaving
> the installation unfinished (I believe that 60 min
> waiting for the program to continue - was enough...).

I had this problem.  Did you try to enable PerlScript?  Without it enabled,
I've got the same problem.

<munch>
> Is there anything I can do  before I start hating Perl
> and send millions of anti-Perl spam messages on the whole
> net?

Not a good idea...

<munch>



Watcher

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


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

Date: Thu, 22 Apr 1999 00:20:47 -0400
From: James Tolley <jamesht@idt.net>
To: sjose@mulmax.com
Subject: Re: last item in associative array.
Message-Id: <371EA39E.803D560D@idt.net>

Associative arrays have no real first and last, so no.

To find how many items there are:

$number = scalar(keys %hash);

hth,

James

Multimax wrote:

> How can I find the last item in an associative array?
>
> Is there an equivalent of $#myArray (the last item in @myArray)?
>
> Stephane





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

Date: Thu, 22 Apr 1999 00:21:05 -0400
From: James Tolley <jamesht@idt.net>
To: sjose@mulmax.com
Subject: Re: last item in associative array.
Message-Id: <371EA3B0.E6F664CA@idt.net>

Associative arrays have no real first and last, so no.

To find how many items there are:

$number = scalar(keys %hash);

hth,

James

Multimax wrote:

> How can I find the last item in an associative array?
>
> Is there an equivalent of $#myArray (the last item in @myArray)?
>
> Stephane





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

Date: Thu, 22 Apr 1999 00:21:20 -0400
From: James Tolley <jamesht@idt.net>
To: sjose@mulmax.com
Subject: Re: last item in associative array.
Message-Id: <371EA3C0.CA032008@idt.net>

Associative arrays have no real first and last, so no.

To find how many items there are:

$number = scalar(keys %hash);

hth,

James

Multimax wrote:

> How can I find the last item in an associative array?
>
> Is there an equivalent of $#myArray (the last item in @myArray)?
>
> Stephane





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

Date: Thu, 22 Apr 1999 00:22:00 -0400
From: James Tolley <jamesht@idt.net>
Subject: Re: last item in associative array.
Message-Id: <371EA3E8.E81B65C2@idt.net>

Associative arrays have no real first and last, so no.

To find how many items there are:

$number = scalar(keys %hash);

hth,

James

Multimax wrote:

> How can I find the last item in an associative array?
>
> Is there an equivalent of $#myArray (the last item in @myArray)?
>
> Stephane





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

Date: Thu, 22 Apr 1999 00:18:21 -0400
From: James Tolley <jamesht@idt.net>
Subject: no signal called on child exit, on linux?
Message-Id: <371EA30D.A786E919@idt.net>

Hello all,

I'm having some trouble receiving the $SIG{CHLD} signal on Linux. Any
one ever have this trouble before? I get $SIG{INT}, and I can 'wait' on
the children, but when children die, my handler's never called. Have I
miscompiled perl or the kernel??

ANY help would be GREATLY appreciated!

Thank you much,

James



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

Date: Thu, 22 Apr 1999 13:33:42 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Perl notation question?
Message-Id: <ycxT2.51$bD2.4827@vic.nntp.telstra.net>

>> I prefer TIMTOWTDI, since the docs say it is supposed to be pronounced
>> 'tim-toady'.
>
>perldoc perl
>
>    The Perl motto is "There's more than one way to do it."
>                       ^^^^^^^


How can there be a phonetically correct way to pronounce an acronym?

Isn't that taking nit-picking just a little to extremes?

:^)

Wyzelli




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

Date: Thu, 22 Apr 1999 01:51:56 -0400
From: "Dan Burke" <dbws@----nospam----hotmail.com>
Subject: remove space
Message-Id: <yJyT2.5907$8m5.8839@newsr1.twcny.rr.com>

How do you remove all spaces from a string?

Example...

Convert:  $string = "    remove all spaces ";
To:       $string = "removeallspaces";

Thanks a lot for any help.

Dan Burke






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

Date: 22 Apr 1999 05:09:35 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Server Push
Message-Id: <slrn7htbll.he.efflandt@efflandt.xnet.com>

On Wed, 21 Apr 1999 18:32:07 +0100 (BST), HP Ow Yong
<een7hpo@electeng.leeds.ac.uk> wrote:
>I am having trouble with server push utility for CGI.pm module. Even though I 
>copy paste the example found on the documentation, I don't seem to be able to 
>run the script over the browser. However if I run it via command line (eq perl 
>somefile.pl) It works perfectly fine. Any advice?
>
>Anyway I am using WIN95 with Apache and the latest ActivePerl.. and IE3. Thank 
>you

I believe that server push is still a Netscape only thing, so your script
needs to just send a proper single page or image to non-Netscape browsers.
If you send a single image to others, make sure you include
'Content-length:' (in bytes) in the headers, because certain Mosaic based
browsers, like MSIE, used to choke without it (not sure if they still do).

The logic I use is to only do server push for HTTP_USER_AGENT that
contains 'Mozilla' with a version (before the dot) > 1, and does NOT
contain the word 'compatible' (case insensitive).  There are many Mozilla
fakes around (including MSIE) that are not even close.

Even though MSIE calls itself Mozilla, it does not do server push, only
recently added file upload (version 4?) and pays almost no attention to
MIME headers.

-- 
David Efflandt    efflandt@xnet.com
http://www.xnet.com/~efflandt/


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

Date: Wed, 21 Apr 1999 15:38:38 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
To: Anthony Baratta <Anthony@Baratta.com>
Subject: Re: Sorting Hashes of Arrays....
Message-Id: <x3yd80xydaa.fsf@tigre.matrox.com>


Anthony Baratta <Anthony@Baratta.com> writes:

> 	# print the whole thing sorted by number of members and name
> 1	foreach $family ( sort { @{$HoL{$b}} <=> @{$HoL{$a}} } keys %HoL ) {
> 2		print "$family: ", join(",", sort @{ $HoL{$family} }), "\n";
> 3	}
> 
> 
> I understand how line 2 works. Sorting the 'list' contained withing
> $HoL{$family} 'horizontally' just before print out. But I don't
> understand Line 1 - What compare is this doing here... @{$HoL{$b}} <=>
> @{$HoL{$a}} ??

It is sorting the keys of %HoL by the number of elements contained in
the arrays their values reference, in descending order.

What do you mean by "horizontal" and "vertical" sorting? Have you had
a look at perlfaq4 yet? What about perlfunc?

> Does this take each line of the $HoL{$family} and compare it to the one
> above it for sorting? So that a Hash of Array like this...
> 
> 	%HoL = (
> 		flinstones	=> [ "fred", "barney" ],
> 		simpsons	=> [ "homer", "marge", "bart"" ],
> 		jetsons		=> [ "george", "jane", "elroy" ],
> 	);
> 
> Would print out like...
> 
> 	flinstones: barney, fred
> 	jetsons: elroy, george, jane
> 	simpsons: bart, homer, marge

Why don't you try and see for yourself?

> And what if I had a Hash of Array like this.....
> 
> %HoL = (
> 	StoreID1 => [ "A Store Name", "A Street Address", "A City", "A State",
> "A Zip" ],
> 	StoreID2 => [ "C Store Name", "C Street Address", "C City", "C State",
> "C Zip" ],
> 	StoreID3 => [ "B Store Name", "B Street Address", "B City", "B State",
> "B Zip" ],
> 	StoreID4 => [ "D Store Name", "D Street Address", "A City", "A State",
> "A Zip" ],
> 	);
> 
> How would I sort on City then Store Name between StoreIDs (vertically)
> and print out the info that order? So my print out looks like this....
> 
> 	"A Store Name", "A Street Address", "A City", "A State", "A Zip"
> 	"D Store Name", "D Street Address", "A City", "A State", "A Zip"
> 	"B Store Name", "B Street Address", "B City", "B State", "B Zip"
> 	"C Store Name", "C Street Address", "C City", "C State", "C Zip"

{
	local $" = ', ';
	for my $key (sort {	$HoL{$a}[2] cmp $HoL{$b}[2]
					     ||
				$HoL{$a}[0] cmp $HoL{$b}[0]
			  } keys %HoL) {
		print "@{$HoL{$key}}\n";
	}
}

HTH,
Ala



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

Date: Wed, 21 Apr 1999 17:39:14 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Suggestions and oneliners for Perl-talk?
Message-Id: <x3yaew1y7pa.fsf@tigre.matrox.com>


Thorbjoern Ravn Andersen <Thunderbear@bigfoot.com> writes:

> Since this is an excellent opportunity to show the possibilities with
> Perl, I would like some ideas for what I should tell and demonstrate in
> the 2-3 hours I have available (expected audience is people who do know
> how to program but does not know perl), and I am intending to mention
> the following:
> 
> o	regular expressions
> o	dynamic arrays
> o	hashes
> 
> but there must be additional "power tools" within perl which would be
> suitable for the uninitiated.

Here are a few I particularly like:

1) eval() : Having access to a run-time evalution mechanism is
	    extremely powerful. Definitely one of the biggest
	    assets of Perl.

2) Regular Expressions: you already mentioned that.

3) hash slices : I just love them. They make life so much easier.

4) map() and grep() : Extremely handy.

5) CPAN and comp.lang.perl.* : If a module doesn't exist that does
	    what you want (highly unlikely), you can post a question
	    and you'll get your answer within 24 hours guaranteed
	    (or your money back ;-)

6) The debugger : I yet have to tame that beast, but I still like it.

7) Command-Line flags

8) Function return value according to Context

9) TMTOWTDI

10) Perl's built-in variables : Once you get used to them, you can't
	    live without them.

11) $_

It's hard to stop, but I have to draw the line somewhere :-)



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

Date: Wed, 21 Apr 1999 21:24:37 -0700
From: see@my.sig (dg)
Subject: Re: The Future of Tk?
Message-Id: <MPG.11884463ba4ee49b989695@news.nwlink.com>

In article <371E964F.C531C2A@istar.ca>, eugened@istar.ca spoke thusly:
> For programmers using languages other than Tcl.
> 
> I recently "discovered" the latest stable version of Tcl/Tk (8.05) and
> must say that was quite impressed by the simplicity and ease of use of
> Tk.
> 
> But I also found that while older versions of Tk were using lightweight
> components (Some Java terminology :) the latest version is using native
> components for things like scrollbars and buttons.
> 
> I don't want to say that this is bad for Tcl users but what about all
> the other languages that use Tk? Isn't writting multiplatform GUI harder
> using native components....

Tk does all the hard work, depending on which platform it's compiled for.  
The gui programmer makes the same calls in either case. 
-- 
Don Groves (groves_acm_org)
Replace underscores to get my email address


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

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

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