[12220] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5820 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 28 17:07:21 1999

Date: Fri, 28 May 99 14:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 28 May 1999     Volume: 8 Number: 5820

Today's topics:
    Re: #!usr/local/bin/perl line in IIS for a script examp (Larry Rosler)
    Re: Beginner needs help <thomaslo@uiuc.edu>
    Re: Can Perl call C functions? <ebohlman@netcom.com>
    Re: Can someone help me on this challenging problem? <none@microsoft.com>
        Commercial Perl Debugger/Development for Unix (Andrew Wilson Falgout)
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Tad McClellan)
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (I R A Aggie)
    Re: Hash References (Larry Rosler)
    Re: Help! need fraction of a second time function (Larry Rosler)
        Help, HTML entities <dmelomed@pppl.gov>
        Help: About Apache and Perl weixian_shen@my-deja.com
    Re: Help: About Apache and Perl <craig@mathworks.com>
        Im not asking for much jknoll@my-deja.com
    Re: Im not asking for much (I R A Aggie)
    Re: Incrementing a value in a slice <uri@sysarch.com>
    Re: Incrementing a value in a slice <uri@sysarch.com>
    Re: Incrementing a value in a slice (Larry Rosler)
    Re: method return values <jdporter@min.net>
        Newbie: How to post data? keviny@hk.super.net
    Re: PB writing an uploaded file in perl (size changes!) <uri@sysarch.com>
    Re: Perl "constructors" (Ilya Zakharevich)
    Re: pre-allocating memory needs in perl? (Nathan O. Siemers)
        String Substitution & \t <djjr@ix.netcom.com>
    Re: Strip "http" from URL's (Larry Rosler)
    Re: Thanks man....HOWS THIS? <Allan@due.net>
    Re: Thanks man....HOWS THIS? jknoll@my-deja.com
    Re: to see who is online <dgris@moiraine.dimensional.com>
        Trying to make custom start page for users via cookie a (SiKnight)
    Re: unexponentialize field from text file (Ilya Zakharevich)
    Re: Y2K infected Perl code (Larry Rosler)
    Re: Y2K infected Perl code finsol@ts.co.nz
    Re: Y2K infected Perl code (Ilya Zakharevich)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 28 May 1999 12:13:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: #!usr/local/bin/perl line in IIS for a script example
Message-Id: <MPG.11b88ac163b121de989b21@nntp.hpl.hp.com>

In article <%YA33.6$qD2.968@dfw-service1.ext.raytheon.com> on Fri, 28 
May 1999 13:04:18 -0500, Tim Armbruster <t-armbruster@ti.com> says...
> 
> squeot wrote in message <7imhuo$r07$1@nnrp1.deja.com>...
> >Can someone show me an example of how the #!usr/local/bin/perl line
> >looks on an IIS server?  I need both ISAPI and the standard activeperl,
> 
> On my machine (IIS and ActivePerl) if I have a ".pl" extension, I don't even
> need the #! line.

That must mean you don't use the '-w' flag.  For shame.

#!/any/old/thing/that/contains/the/word/perl/in/it -w
use strict;

And take it away from there! 

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


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

Date: Fri, 28 May 1999 14:52:53 -0500
From: ACRC <thomaslo@uiuc.edu>
Subject: Re: Beginner needs help
Message-Id: <374EF415.2E5D@uiuc.edu>

Oh, we're just cleaning up somebody else's work, and we're still
learning the ropes. But thanks for the suggestion; we'll definitely look
into that.

Tom

John Porter wrote:
> 
> In article <374DE50B.51CB@uiuc.edu>,
>   thomaslo@uiuc.edu wrote:
> > We have some problems displaying PDF files in the secure section of
> our
> > site. Everything seems to work fine when you click on the link to a
> PDF
> > file, and Adobe Acrobat Exchange/Reader would load itself up, and
> after
> > that false hope, it would say it can't open the file. The file is OK
> > too.
> >
> > } elsif ($inputfile ne "" && isElementInArray($extension,
> > @protect_pdf_ext) && $is_group_filter_passed) {
> >     print "Content-type: application/pdf\n\n";
> >     open(PDFFILE, "<$protect_pdf_dir/$filename") ||
> >       &CgiDie("Could not open $protect_pdf_dir/$filename");
> >     while (<PDFFILE>) {
> >         print $_;
> >     }
> >     close (PDFFILE);
> 
> You probably shouldn't print the Content-type header until you
> know for sure that you're actually going to be sending PDF data.
> I.e. wait until after the open() succeeds.  Something like this:
> 
>   if ( open PDFFILE, "< ..." ) {
>     print "Content-type: application/pdf\n\n", <PDFFILE>;
>     close PDFFILE;
>   }
>   else {
>     print "Content-type: text/html\n\n";
>     CgiDie("Could not open $protect_pdf_dir/$filename");
>   }
> 
> Any good reason you're not using CGI.pm?
> 
> --
> John Porter
> Put it on a plate, son.  You'll enjoy it more.
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


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

Date: Fri, 28 May 1999 19:04:41 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Can Perl call C functions?
Message-Id: <ebohlmanFCGIBt.MEJ@netcom.com>

sbeaulieu@my-deja.com wrote:
: Like the subject says, can perl call C funtions?  If so, how can that
: be done?

perldoc perlxs
perldoc perlxstut

Afterwards, go over to <URL:http://reference.perl.com> and look for 
relevant material (you'll recognize it after reading the above documents).



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

Date: Fri, 28 May 1999 13:34:33 -0700
From: plz_reply_to_group <none@microsoft.com>
To: Gerry Quinn <gerryq@indigo.ie>
Subject: Re: Can someone help me on this challenging problem?
Message-Id: <374EFDD9.E7802C23@microsoft.com>

Check out the Algorithm of the Gods, at
http://web2.thesphere.com/SAS/SciAm/1997/SimAneal/SimAneal.html. It is
the elaboration of an article from Scientific American magazine, March,
1997, about an algorithm for solving traveling-salesman-type problems.
It's a really good article, in fact the web site is one of the best on
the net. Really.


Gerry Quinn wrote:
> 
> In article <7ihfpl$t3u@dfw-ixnews11.ix.netcom.com>, "Ralph Emerson" <uyv_IGNORE_r@hotmail.com> wrote:
> >I thought of this one on my own but because it just seems so common, I'm
> >sure someone else out there has done something very similar.  The way I'm
> >thinking of working it won't work for big input files.
> >
> >The number 1 connects to numbers 4,5,8 and 9.
> >The number 2 connects to numbers 4 and 8.
> >The number 3 connects to 5 and 6.
> >.........
> >The number 7 connects to nothing.
> >.......
> >The number 9 connects to 2,5 and 8.
> >
> >The input file looks like this
> >-----------
> >9 {The number of connectors}
> >3 4 5 8 9
> >4 8 9
> >1 5 6
> >1 2 8
> >1 3 9
> >3
> >0
> >1 2 4 9
> >5 2 8
> >--------------
> >I bet you can see what I'm asking already.  Find the shortest connection
> >path between two numbers.  For example the shortest connection between 1 and
> >2 is 1-4-2.  The shortest connection between 6 and 2 is 6-3-5-9-2.
> >
> >I'm thinking a good old recursive function that calles itself with all the
> >numbers in it's row and stops when it hits the number it wants. (I wouldn't
> >have it loop back to itself somehow).  There's got to be a better way to do
> >this so that it will work for list 5000 long with 10-12 connectors each.  I
> >cross posted so that I could get all the ideas I can and even though I can
> >read the languages I posted to, please post back ideas/Visual English and
> >Report Language++ and not real code so that others can comment.
> >
> 
> Shortest path -> A* Algorithm.  Look it up.
> 
> - Gerry Quinn



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

Date: 28 May 1999 19:10:10 GMT
From: afalgout@ocean.otr.usm.edu (Andrew Wilson Falgout)
Subject: Commercial Perl Debugger/Development for Unix
Message-Id: <7impmi$25h$1@thorn.cc.usm.edu>


Does anyone know of a Commercial Development Package for 
programming/debugging perl under the unix platform?
(Specifically AIX and Linux)

Thank You,
Andrew


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

Date: Fri, 28 May 1999 08:10:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <l31mi7.7sp.ln@magna.metronet.com>

Eric Bohlman (ebohlman@netcom.com) wrote:
: finsol@ts.co.nz wrote:
: : Why does the Perl community persist in denying that their applications
: : could have Y2K problems instead of doing more to get the message out
: : that the code needs to be checked.  The stance that the Perl developers
: : disputing this are taking is illogical, irresponsible and could cause
: : serious problems for the organisations that continue to use the Perl
: : code that remains unchecked.

: What the Perl community persists in denying is that Perl the language 
: has built-in Y2K problems.  The Perl community unanimously affirms that 
: Perl code written by people who make guesses about what kind of data 
: localtime() returns, rather than inspecting the documentation for 
: localtime(), is very likely to have Y2K problems.


   The Perl community believes:

      There are no y2k issues with "perl code".

      There are very likely to be y2k issues with "Perl code".

   If you cannot get the distinction between those (after maybe
   seeing qq/What's the difference between "perl" and "Perl"/
   in Perl FAQ part 1), then give up as you are just too silly
   to be taken seriously.

   If you can get the distinction, then you should be able to see
   that we are agreeing with you, and you can stop following up.


   ... unless you think that there *are* issues with "perl code"...


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


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

Date: 28 May 1999 19:51:16 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <slrn7ktt3i.a5u.fl_aggie@thepentagon.com>

On 28 May 1999 14:40:51 -0400, Uri Guttman <uri@sysarch.com>, in
<x7btf5hwb0.fsf@home.sysarch.com> wrote:

+ >>>>> "IRAA" == I R A Aggie <fl_aggie@thepentagon.com> writes:
+ IRAA> *shrug* Another design desicision -- emulate libc calls, a good call
+ IRAA> IMHO. "Fix" the underlying libc and you've "fixed" perl, too. Have you
+ IRAA> submitted a patch to GNU libc?

+ that ain't gonna happen!

Yah, I know, that's why I can suggest it with a straight face...

+ write a module and use it.

Hmmm...'use Date::Localtime;'.

James


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

Date: Fri, 28 May 1999 12:21:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Hash References
Message-Id: <MPG.11b88c8d6f0a1646989b23@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <374ED3F8.5FE0FED8@mitre.org> on Fri, 28 May 1999 13:35:52 -
0400, John Dixon <jdixon@mitre.org> says...
> Perl Gods,

Semi-demi-gods, at best.  :-)

> I am having trouble trying to dereference an array of hashes that
> references arrays.  I access each hash list as follows:
> 
> @{$Records[$i]{$Key}}[$j]
> 
> where "i" iterates through each hash list and "j" iterates through each
> array element referenced by the key in the hash list.
> 
> I am having trouble storing specific hash arrays in another array.  This
> is what I am currently doing:
> 
> push (@new_hash_list, %{$Records[$i]})

This unrolls the hash into key-value pairs and pushes them all onto 
@new_hash_list.  What you want is an array of references:

  push (@new_hash_list, \%{$Records[$i]})

> When I try to print the new list like this:
> 
> print @{$new_hash_list[$i]{$Key}}[$j]
> 
> Nothing prints.  Can anyone help me?

Try it and see if that is the problem.  (I didn't test my proposal, but 
semi-demi-gods don't have to do that, right? :-)

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


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

Date: Fri, 28 May 1999 12:16:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help! need fraction of a second time function
Message-Id: <MPG.11b88b6bb6383477989b22@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7imk4v$sp1$1@nnrp1.deja.com> on Fri, 28 May 1999 17:35:27 
GMT, Greg Fields <greg.fields@infoadvan.com> says...
> I'm trying to find inefficiencies in some often called routines of mine
> so I want to track elapsed time.  However, most times they execute in
> fractions of a second so using the 'time' function for boundaries will
> always be '0'.
> 
> Is there anything out there that would allow me to track hundredths or
> thousandths of a second?

perldoc -f times

The resolution is 'clock ticks', which may be 60 Hz, 100 Hz, or more.

See also perlfaq8:  "How can I measure time under a second?"

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


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

Date: Thu, 27 May 1999 13:08:18 -0400
From: Dan Melomedman <dmelomed@pppl.gov>
Subject: Help, HTML entities
Message-Id: <374D7C02.A0D508BF@pppl.gov>

Hi, trying to get rid of those HTML entities from the string $2, how can
I get rid of it  from the variable $2??

foreach $line (@state){
push @{$1}, $2 if $line =~ /(.*?)=(.*)/;
${$1} =  $2  =~ if $line =~ /(.*?)=(.*)/;
}


Thanks.



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

Date: Fri, 28 May 1999 18:46:55 GMT
From: weixian_shen@my-deja.com
Subject: Help: About Apache and Perl
Message-Id: <7imoau$vs0$1@nnrp1.deja.com>

Hi,
  I am writing a Perl CGI that needs to detect if the users has
clicked the "STOP" button before the CGI finishes.  I thought
apache server will send the CGI script a SIGINT or something of
that kind when user press the STOP button, but it didn't work.
If anyone knows, please let me know.  Thanks


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 28 May 1999 15:06:45 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: Help: About Apache and Perl
Message-Id: <374EE945.68B6AD0@mathworks.com>

mod_perl will allow you to do what you want, but may not be what you are
looking for:

http://perl.apache.org/guide/all.html

Craig

weixian_shen@my-deja.com wrote:

> Hi,
>   I am writing a Perl CGI that needs to detect if the users has
> clicked the "STOP" button before the CGI finishes.  I thought
> apache server will send the CGI script a SIGINT or something of
> that kind when user press the STOP button, but it didn't work.
> If anyone knows, please let me know.  Thanks
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.



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

Date: Fri, 28 May 1999 19:35:48 GMT
From: jknoll@my-deja.com
Subject: Im not asking for much
Message-Id: <7imr6k$1s1$1@nnrp1.deja.com>

I just wanted to try and learn this language from the ground up.  I
wanted to make sure I knew WHY things happened when they did, not just
how to make it look right.  I guess this wasnt the right place to start,
no one here really seems to want to give me a hint, so I am not real
optimistic about my next request;  If I can't get help here, does anyone
have any idea where a starting perl programmer should start?

Thanks for all the help
jrk


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 28 May 1999 20:46:57 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Im not asking for much
Message-Id: <slrn7ku0c1.f6.fl_aggie@thepentagon.com>

On Fri, 28 May 1999 19:35:48 GMT, jknoll@my-deja.com <jknoll@my-deja.com>, in
<7imr6k$1s1$1@nnrp1.deja.com> wrote:

+ optimistic about my next request;  If I can't get help here, does anyone
+ have any idea where a starting perl programmer should start?

Depends on how one parses "starting perl programmer". Are you:

a) a programmer wanting to learn perl
b) a person wanting to learn to program, in this case, in perl

$answer=<STDIN>;
if ( (lc $answer)=~/a/) {
   print "Learning Perl by Randal Schwartz\n";
}else{
   print<<EOF;
Take a programming class, learn to program, then learn perl.
EOF
}

Learning to program *and* learning perl is a tough thing.

James


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

Date: 28 May 1999 15:00:34 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Incrementing a value in a slice
Message-Id: <x74skxhve5.fsf@home.sysarch.com>

>>>>> "GB" == Greg Bacon <gbacon@itsc.uah.edu> writes:

  GB> It's a pedagogical issue.  I wanted to show how to collect the
  GB> information she wanted and then show one possible way to use it.
  GB> Playing Perl golf (fewest (key)strokes wins!) with people who have lots
  GB> of experience is fine, but it's not going to help much for people who
  GB> are still trying to get the hang of it.

i agree to a point. showing a beginner a simpler way and later the
better but more idiomatic way is common. where to draw the line is an
issue. at the boston tutorials i heard a line (from randal?) which was
something like teaching beginners is progressive lying. everything you
teach early on is rescinded later with better techniques. i just like to
start off with the better techniques instead of the simpler ones.

why can't newbies use hash slices in their hello world programs? :-)

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: 28 May 1999 15:03:31 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Incrementing a value in a slice
Message-Id: <x71zg1hv98.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> [Posted and a courtesy copy mailed, so Uri can feel bad sooner :-).]

i don't feel bad. i left the bug as an exercise for you. :-)

  >> 
  >> $max_line = $_ && $max_count = $seen{$_} if ++$seen{$_} > $max_count ; 

  LR> Do you want me to spell out the problem for you, or would you prefer to 
  LR> own up to it yourself?

  LR> :-( for you, buddy.

i don't like or. i like ||. i will use || even when it is buggy! in fact
i use it for open since i use parens with open. i don't normally paren =
so this should have use or or parens. but the thought of winning perl
golf (i like greg's coinage!) can lead to bugs.

and of course, i didn't test it as it was too simple. :-)

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: Fri, 28 May 1999 13:16:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Incrementing a value in a slice
Message-Id: <MPG.11b8995e255da063989b26@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <x71zg1hv98.fsf@home.sysarch.com> on 28 May 1999 15:03:31 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>   LR> [Posted and a courtesy copy mailed, so Uri can feel bad sooner :-).]
> 
> i don't feel bad. i left the bug as an exercise for you. :-)
> 
>   >> $max_line = $_ && $max_count = $seen{$_} if ++$seen{$_} > $max_count ; 
> 
>   LR> Do you want me to spell out the problem for you, or would you prefer to 
>   LR> own up to it yourself?
> 
>   LR> :-( for you, buddy.
> 
> i don't like or. i like ||. i will use || even when it is buggy! in fact
> i use it for open since i use parens with open. i don't normally paren =
> so this should have use or or parens. but the thought of winning perl
> golf (i like greg's coinage!) can lead to bugs.

For those whom Uri is (deliberately?) leaving clueless, in the paragraph 
above,

    s/or/'and'/;
    s/\|\|/&&/g;
    s/!.*/!/s;
 
> and of course, i didn't test it as it was too simple. :-)

That's what they all say.  :-)

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


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

Date: Fri, 28 May 1999 19:31:31 GMT
From: John Porter <jdporter@min.net>
Subject: Re: method return values
Message-Id: <7imquj$1p1$1@nnrp1.deja.com>

In article <374ECE7F.F5F36489@uswest.com>,
  Brad Waite <bwaite@uswest.com> wrote:
>
> I'm using IPC::Shareable which calls croak() if it can't get a shared
> memory segment.  I was trying to use the return value in a decision
whether to
> continue or not.  Shouldn't it rather return an undef or 0 or
something, which
> then allows the calling program to check ERRNO, and do what it wants?

This is what is known as "throwing (or raising) and exception".
To handle an exception like this, wrap the call to the dying (or
croaking) function in an eval block; then test $@.

	eval {
		$obj->get_resource();
	};
	if ( $@ ) {
		# it threw an exception.
		print "Failed to get resource: $@\n";
	# etc.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 28 May 1999 19:54:34 GMT
From: keviny@hk.super.net
Subject: Newbie: How to post data?
Message-Id: <7ims9p$2mc$1@nnrp1.deja.com>

Hi, all,

I have read some html form basics and cgi tutorials but I couldn't find
my answer. I would really appreciate it if you could give me some hints.
Lots of tutorials assume you write your perl script on your server to
generate HTML to be sent to the browser. However, I need the opposite: I
have an HTML form that I use often and I want to automate this process
on my client. I wanted to know how I can post data to the server using
perl. I am new to perl, form and cgi. I would like to know how to
specify the destination (URL), how to assign values to different fields
on the form and how to finally submit the data.

Thanks in advance. I really needed this help.

--
Regards,
Kevin


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 28 May 1999 16:36:47 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: PB writing an uploaded file in perl (size changes!)
Message-Id: <x7wvxtgcdc.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:


  LR> But TomC has made it clear that he, at least, will not adopt my 
  LR> suggestion on how to eliminate this question being asked ad nauseam:

  LR> 'binmode' binary files on every implementation of perl!

do you mean have perl do it? or the code call binmode on binary files
regardless of the OS?

if the latter, then i still have a bone to pick as i am not writing to
be platform independent in some cases. so i can skip it if i know the
program is destined to always run on unix.

here is a documentation suggestion.  binmode for binary files should be
discussed in perlport and linked to there from binmode and open in
the docs.

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: 28 May 1999 20:55:22 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl "constructors"
Message-Id: <7imvrq$hmo$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<zenin@bawdycaste.org>],
who wrote in article <927855938.146713@localhost>:
> 	Or maybe handlers such as CGI::Carp should really be checking the
> 	state of $^S before doing anything...

Yes, this is what $^S was put there for...

Ilya



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

Date: 28 May 1999 10:00:42 -0400
From: nathan@dnase.hpw.pri.bms.com (Nathan O. Siemers)
Subject: Re: pre-allocating memory needs in perl?
Message-Id: <snkiu9di99x.fsf@dnase.hpw.pri.bms.com>


I guess I get to answer my own question.  I don't think my copy of the
camel book was written when perl 5.004 was in existence.  In 5.004,
one can say:

	keys(%hash) = 1024;

and %hash will be pre-allocated with memory to store 1024 "buckets" (if
not keys), for the hash.

(Perl Cookbook, 1st edition (1998), page 149).
(ram book?)

nathan


Craig Ciquera <craig@mathworks.com> writes:

> See Camel book page 82.
> 
> Craig
> 
> "Nathan O. Siemers" wrote:
> 
> > Greetings,
> >
> >         I have some perl code that uses some fairly large hashes
> >         (multi-megabyte size, nested too).  Would there be any
> >         performance advantage to pre-allocating memory for these,
 ...



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

Date: Fri, 28 May 1999 13:38:15 -0700
From: Clarence <djjr@ix.netcom.com>
Subject: String Substitution & \t
Message-Id: <374EFEB7.5A656D31@ix.netcom.com>

I'm new to perl so this is probably a easy question
I'm trying to print out the following string(A directory)
"\\usan\data\inet\transfer\choin"
but it sees the \t in the string as a tab obviously.  I tried
substituting "\\" for every "\"  in this small test program :

#!/usr/bin/perl
my $teststr="\\usan\data\inet\transfer\choin";
my $teststr2="\\\\usan\\data\\inet\\transfer\\choin";
print "$teststr\n";
print "$teststr2\n";
$teststr=~s/\/\\//g;
print "$teststr\n";


When I print $teststr2 I get the desired results
but when I print $teststr I get the wrong results both before and after
the substitution.
This is what I get when I print $teststr : \usandata\inet\
transfeoin

I'm actually going to read these values from a Oracle database, so I
need to clean them up
before I print them.

Am I approaching this the right way?  Or is there a easier way to do
this.

TIA




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

Date: Fri, 28 May 1999 12:36:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Strip "http" from URL's
Message-Id: <MPG.11b8901ea72f5545989b25@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <m1g14hf2mf.fsf@halfdome.holdit.com> on 28 May 1999 11:52:40 
-0700, Randal L. Schwartz <merlyn@stonehenge.com> says...
> >>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
> 
> Larry> + > Given any URL such as:
> 
> Larry> + Maybe something like this:
> Larry> + 
> Larry> + use URI;
> Larry> + $u1 = URI->new("http://www.perl.com/whatever/");
> Larry> + $scheme = $u->scheme;
> Larry> + $opaque = $u->opaque;
> Larry> + $path   = $u->path;    # try printing this
> Larry> + $frag   = $u->fragment;
> 
> Larry> Good Lord.  A new disease -- modulitis.
> 
> Larry>     s%^http://[^/]+%%;
> 
> Which doesn't work if it's *any* URL, as the spec said.

No, that's not what the spec said.  This is what it said:

Given any URL such as:
http://www.whatever.com/whatever/ or
http://www.whatever.com/whatever or
http://whatever.com/whatever/ or
http://www.whatever.com/whatever/whatever.xxx or
http://www.whatever.com/

I could have written the regex differently to fit *your* spec:

    s%^[a-z][a-z\d.+-]*://[^/]+%%i;

RFC 2396:  scheme: alpha *( alpha | digit | + | - | . ) 

> Modules are useful.  Don't knock them.

They serve a useful purpose where pedantry is involved.

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


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

Date: Fri, 28 May 1999 15:04:13 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Thanks man....HOWS THIS?
Message-Id: <7impbh$v17$1@nntp4.atl.mindspring.net>

jknoll@my-deja.com wrote in message <7imf4u$opr$1@nnrp1.deja.com>...
:Thanks man.  I picked up a perl book yesterday, ask a question and now I
:get this.  What is this NG for if I cant get help?

Well, I have to think Uri might be just a tad grouchy today but your first
post was so unclear as to be meaningless.  If you stick around you will find
that Uri is a great source of information and spends a lot of his time
helping others.  Posting here when you have difficulties is a good idea but
include a little code so we can try to figure out what you are doing and
where you are going astray.  Note: it should be the smallest bit of code
that demonstrates where you are having trouble.

:I am getting my info from here:
:http://www.free-ed.net/fr03/lfc/course%20030207_01/index.html


Maybe more time with Learning Perl might be a good idea.

:I'll try to make it easy for you:
:When you are printing a SINGLE-QUOTED STRING LITERAL, how do you make it
:look like this:
:
:WORDSWORDS
:
:WORDSWORDS
:
:Instead of this:
:
:WORDSWORDSWORDSWORDS

The perl motto is "There is more than one way to do it"  Unfortunately there
are even more ways to do it wrong, so it is hard to know how to offer help.
If you want a single quoted string to span multiple lines then one way would
be:

my $words = 'Words words
words words';

(note there is a newline in the file but not a \n, the above is not line
wrapped)

Then:

print $words will give you:

Words words
words words

But that is not a common way to right such code (IMHO).  Anyway, why bother
to single quote it?  Remember: the right tool for the job.  Here double
quotes so that we more easily control how the output will look by using
backslash escape and the control characters. \n is used to produce the
desired newline.

my $words = "Words words\nwords words";
print $words;

Back-quotes are whole different kettle of fish.  They allow you to launch a
shell process and capture output.  If you want to control how that looks you
would need to manipulate the captured output in some way before you print
it.


:I hope you can understand this.  I will email you a picture if you cant.

Actual posting your code would be a bit more helpful than a picture <g>.
Since we don't really know what you are doing it is kind of hard to offer
useful assistance.  This newsgroup highly values effort so the inclusion of
evidence of said effort (by supplying examples of your effort in the form of
a code snippet) is usually a good idea.  There have I beaten that horse to
death?  Probably.


HTH

AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
#else /* !STDSTDIO */     /* The big, slow, and stupid way */
 - Larry Wall in str.c from the perl source code





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

Date: Fri, 28 May 1999 19:39:50 GMT
From: jknoll@my-deja.com
Subject: Re: Thanks man....HOWS THIS?
Message-Id: <7imre6$24h$1@nnrp1.deja.com>

I just wanted to know how to return down a few lines after some text- so
it isnt all bunched up.  This isnt homework, Im tryin to teach myself
perl for my summer job.  I couldnt find out how to do it, so i thought
someone here would know.

thanks
jrk


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 28 May 1999 13:47:17 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: to see who is online
Message-Id: <m31zg1ou2i.fsf@moiraine.dimensional.com>

[this has nothing at all to do with perl, but you are
 obviously confused so I'll try to help.  further
 discussion should be moved to ciwac ]

bababozorg@aol.com writes:

> i was wondering if there is any way that i can see who is in my website
> right now and display the details of that person, or if he is my member
> how can i know he is online right now!.

This looks like english, but I have no idea what it means.  What
do you mean by `in my website'?  Perhaps you have misunderstood
how http works--there is no such thing as being `on' or `in' a
website.

For example, right now I have 53 open browser windows.  Of those,
exactly four are displaying URLs from the same domain (and all
of those are actually local on my hard drive :-).  Which of
those 50 websites would you say that I'm logged onto right
now?  Would you include me as being `on' or `in' the site where
my browser is displaying stock quotes from the first week of
April--I haven't even refreshed that window in 8 weeks.

> i did try to make a file in the tmp dir when my users came online.
> but i didnt know how to remove that file afterwards when they go
> offline or go to another website. 

There is no reliable way to know when the user stops displaying
the document you served.  In fact, there are many contexts
where the notion of `display' is tenuous at best, think of a search
engine or a text-to-speech rendering browser.

> can you please tell me if there is any way to make it work? or see the
> members online (in separat page) when they logged in to my website?

Sorry, but there really isn't any general solution to what you are
trying to do.  That's just not how things work.  If you post
to comp.infosystems.www.authoring.cgi the people there may be
better able to help you accomplish something similar to this.

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


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

Date: 28 May 1999 14:15:08 -0500
From: knightrdr@nospam.com (SiKnight)
Subject: Trying to make custom start page for users via cookie and perl.  Help please?
Message-Id: <374feb08.45820527@news1.newscene.com>

Here's what I'm trying to do.  I'm sure you've all seen the custom
start pages that various sites like excite and msn have.  Those pages
display news and other information according to your preferences which
you can set yourself.  I am assuming it uses cookies and perl to do
this.

On my domain home page (http://home.siliconknight.com), I provide a
news feed and weather report.  I want to make it where the user can
set the news feed to their preferences and change the weather report
to their own hometown.  I have NO clue as how to do this though.  As
some background, the page as it stands now uses SSI for the news and
weather (the news is something like <!--#include
virtual=3D"/vnews.cgi?blah&blah&blah"> and the weather is similar with
the city and state in the SSI call).  Can anyone help me with this?

Thanks,

Timothy R. Winters
Silicon Knight Computing Services
http://home.siliconknight.com


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

Date: 28 May 1999 20:53:42 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: unexponentialize field from text file
Message-Id: <7imvom$hlj$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.11b7769c2514e521989b15@nntp.hpl.hp.com>:
> > Who told you that Perl uses sprintf()?  It may, and it may not:
> > 
> >   perl -V:d_Gconvert
> >   d_Gconvert='gconvert((x),(n),(t),(b))';
> 
> As gconvert() isn't in the C Standard, it isn't standardized  :-).  Perl 
> could attain that standardization by using "sprintf '%.Ng'" for suitable 
> N, as documented for $OFMT ($#).

This choice is an optimization.  It is a Configure-time choice.

> I am beginning to think that the solution of 'add 0 and let perl do the 
> string-to-number-to-string conversion' isn't necessarily the best 
> answer.  I've revised the code I showed before to produce a real 'E-to-
> F' converter.

Thank you, this is exactly what I wanted to point you at.

Ilya


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

Date: Fri, 28 May 1999 12:23:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Y2K infected Perl code
Message-Id: <MPG.11b88d13c9d1bde9989b24@nntp.hpl.hp.com>

In article <374ee6d1.0@news.new-era.net> on 28 May 1999 18:56:17 GMT, 
Scott McMahan <scott@aravis.softbase.com> says...
> > Sorry,  are you saying that you have seen a specification for a *Perl*
> > program that prescribes the use of: $year = '19' . $year ?  Whoaaa .
> 
> The nice thing about Open Source is, you can always hack
> the interpreter to change any string concatenation of
> a three-digit number to the literal "19" to be an addition.
> Problem solved.

Barf bag provided?  (I'll supply the smiley that you forgot. :-)

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


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

Date: Fri, 28 May 1999 20:09:35 GMT
From: finsol@ts.co.nz
Subject: Re: Y2K infected Perl code
Message-Id: <7imt5t$3ep$1@nnrp1.deja.com>

In article <374e7842@newsread3.dircon.co.uk>,
  Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> In comp.lang.perl.misc Lane Core Jr. <elcore@sgi.net> wrote:
> > On 27 May 1999 22:47:28 -0400, Uri Guttman <uri@sysarch.com> wrote:
> >
> >>so fucking what if cgi
> >>routines and perl routines can be infected with y2k. that is the
> >>programmers problem and not the language's.
> >
> > same with cobol.
> > same with any language.
>
> Not entirely true - there are languages with a DATE type that is
completely transparent to the programmer:
>
<SNIP - geek stuff>
>
> I love it when it when a crosspost goes bad ...

Lane's point still holds - a programmer can create Y2K problems in COBOL
and in Perl. Just because a particular language makes this particularly
easy to do (as with Perl and as with languages that have non-compliant
components) doesn't change the fact.

Y2K problems can occur in applications written in any programming
language and all programming languages can be used to write non-Y2K
problem applications.

> I think that uri's point is that basically if someone is too dumb to
have read and understood the documentation for the localtime function
then its basically tough shit - it is not a problem with Perl its a
problem with the meatware.
> /J\
> --
> Jonathan Stowe <jns@gellyfish.com>

Tough shit for who? Just think about it. Who is going to suffer from all
this denial and ignorance the most? There is certainly a problem Perl
developers if they can be so blase about the consequences of Y2K
problems within the organisations which use the Perl progranmming
language.

Jocelyn Amon
--
Financial Solutions Limited
http://www.ts.co.nz/~finsol/


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 28 May 1999 20:47:24 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Y2K infected Perl code
Message-Id: <7imvcs$eho$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.11b88d13c9d1bde9989b24@nntp.hpl.hp.com>:
> > The nice thing about Open Source is, you can always hack
> > the interpreter to change any string concatenation of
> > a three-digit number to the literal "19" to be an addition.
> > Problem solved.
> 
> Barf bag provided?  (I'll supply the smiley that you forgot. :-)

In your infinite wisdom you may be interested to know that 5.00558 may
contain code not *that* dissimilar to the above suggestion.

Ilya


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

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

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