[9253] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2848 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 11 20:07:20 1998

Date: Thu, 11 Jun 98 17:00:35 -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           Thu, 11 Jun 1998     Volume: 8 Number: 2848

Today's topics:
    Re: [META] hypersensitivity (Mike Stok)
    Re: [META] hypersensitivity <gnat@frii.com>
    Re: [META] hypersensitivity <tchrist@mox.perl.com>
    Re: access to a hash of lists <gnat@frii.com>
    Re: access to a hash of lists <gnat@frii.com>
        Associating Perl with .pl in CGI <brian.barnes@tfn.com>
        Can I change the word boundary anchoring pattern? (Ralph Brands)
    Re: Can I change the word boundary anchoring pattern? <gnat@frii.com>
    Re: ceil or trunc <tchrist@mox.perl.com>
    Re: Certified Perl Programmers <fsg@newsguy.com>
    Re: chopping leading spaces <rootbeer@teleport.com>
    Re: chopping leading spaces <tchrist@mox.perl.com>
    Re: chopping leading spaces <quentin@shaddam.amd.com>
    Re: Command line substitution thru subdirectories <tchrist@mox.perl.com>
    Re: Copy in Perl... <gmarziou@club-internet.fr>
    Re: Copy in Perl... <rootbeer@teleport.com>
    Re: Copy in Perl... <tchrist@mox.perl.com>
    Re: File Upload (Richard S. Smith)
        Filehandle "|mail" Question <coreyp@rc.gc.ca>
    Re: Filehandle "|mail" Question (Kelly Hirano)
    Re: Filehandle "|mail" Question <rootbeer@teleport.com>
    Re: filehandles (Jonathan Stowe)
    Re: filehandles <rootbeer@teleport.com>
    Re: Forcing a literal " (quote) into a form value field <gabriele@kollwitz.doit.wisc.edu>
    Re: Googol bytes (was: Re: [Q] unpack( q/%32C*/ ... )) (Tye McQueen)
    Re: Googol bytes (was: Re: [Q] unpack( q/%32C*/ ... )) <rootbeer@teleport.com>
    Re: Help with Perl CGI script <gabriele@kollwitz.doit.wisc.edu>
    Re: Help with Perl CGI script <rootbeer@teleport.com>
    Re: I want threads, threads and more threads! <gabriele@kollwitz.doit.wisc.edu>
        Importing Modules as variables <pmercer@verio.net>
    Re: Importing Modules as variables <rootbeer@teleport.com>
    Re: JPL Copyright <rootbeer@teleport.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 11 Jun 1998 21:54:57 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: [META] hypersensitivity
Message-Id: <6lpjnh$7of@news-central.tiac.net>

In article <35802C15.3D11@min.net>, John Porter  <jdporter@min.net> wrote:
>jimbo@soundimages.co.uk wrote:
>> 
>> For the record, I believe Perl and its documentation ranks as high as
>> it is possible for software and documentation to rank, if there is
>> such a ranking. 
>
>There is a man, whose initials are rms -- a brilliant, pioneering, and
>widely respected computer scientist; he would disagree with you on this
>point.  He attempted to learn Perl from the provided documentation, and 
>gave up in utter frustration.  So how good can the be really?

He may have been learning from the perl 4.xxx and before docs.  Tom
Christiansen has put considerable effort into the new doc set which comes
with perl 5.xxx and both expanded and organised it better than before.

There is a difference between reference and tutorial documentation and
trying to use a reference materials is like trying to learn how to frive
by studying the specifications of a car's parts.  

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 11 Jun 1998 15:59:56 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: [META] hypersensitivity
Message-Id: <5qhg1rmwf7.fsf@prometheus.frii.com>

John Porter <jdporter@min.net> writes:
> There is a man, whose initials are rms -- a brilliant, pioneering, and
> widely respected computer scientist; he would disagree with you on this
> point.  He attempted to learn Perl from the provided documentation, and 
> gave up in utter frustration.  So how good can the be really?

Don't forget, rms last read the Perl documentation about 8 years ago
:-) Things have changed considerably since then.

You might as well say: "When I first started with English, in the early
18th century, there was no dictionary.  The documentation for English
can hardly be the best of all languages, now can it?"

Nat


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

Date: 11 Jun 1998 23:00:17 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: [META] hypersensitivity
Message-Id: <6lpni1$ma4$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    jdporter@min.net writes:
:There is a man, whose initials are rms -- a brilliant, pioneering, and
:widely respected computer scientist; he would disagree with you on this
:point.  He attempted to learn Perl from the provided documentation, and 
:gave up in utter frustration.  So how good can the be really?

I represent, and resent, that remark.

Anyway, Richard read perl3 docs.

--tom
-- 
    X-Windows: Complex nonsolutions to simple nonproblems.
	--Jamie Zawinski


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

Date: 11 Jun 1998 16:00:36 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: access to a hash of lists
Message-Id: <5qg1hbmwe3.fsf@prometheus.frii.com>

John Cartwright <jcartwright@wans.net> writes:
> Can someone suggest a way that I can retrieve the desired values?


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

Date: 11 Jun 1998 16:02:53 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: access to a hash of lists
Message-Id: <5qemwvmwaa.fsf@prometheus.frii.com>

Nathan Torkington <gnat@frii.com> writes:
> John Cartwright <jcartwright@wans.net> writes:
> > Can someone suggest a way that I can retrieve the desired values?
> [emptiness]

   @firsts = map { $_->[0] } values %HoL;

Nat
(fracking mumble gnus "article is not owned by you" mumble spit)


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

Date: Thu, 11 Jun 1998 18:41:33 -0500
From: "Brian P. Barnes" <brian.barnes@tfn.com>
Subject: Associating Perl with .pl in CGI
Message-Id: <35806B2D.4E51F58A@tfn.com>

Hi,

I just setup the Apache web server and I have a Perl CGI script that I
want to run. I put it in the /apache/cgi-bin directory tried to launch
it from Netscape with the URL:
http://brianb/cgi-bin/image.plx

What I get is the text of the perl script echoed to my browser. I have
done this before with IIS by setting a registry setting. Apache seems to
have setup only 1 registry key defining the root.

I have also tried changing the extension from ".plx" to ".pl" to give it
the standard Perl extension without success.

The closest thing I can find in the /apache/conf/srm.conf file is an
AddHandler feature, but it doesn't seem to work.

How does one associate a ".plx" file extension with Perl in Netscape?

Thanks,

    Brian




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

Date: 11 Jun 1998 22:03:32 GMT
From: brinton@unixg.ubc.ca (Ralph Brands)
Subject: Can I change the word boundary anchoring pattern?
Message-Id: <brinton-1106981457160001@p007.intchg3.net.ubc.ca>

I9ve made a perl program that searches large text databases for groups of
regular expressions. We often use the word boundary anchoring pattern
(which assumes a word contains letters, digits, and underscore characters)
in a search to retrieve only whole words matching the search pattern. 

The text databases (marked up in SGML) include Old English characters and
words which are delimited by "&" and ";" as in these complete words

w&ae;ron
&t;urh

To get around this problem, I9ve added code that translates any input with
"&ae;" into "zaez", any "&t;" into "ztz" etc before the match operator
looks for it. It is then translated back again if a match is made, and
I9ve found the actual word boundaries.

This way of doing things works but all the substitutions add about 25-35%
to the time the code needs to work.

Can anyone suggest a faster perl way to accomplish the same thing, say
somehow changing the definition of a word boundary anchoring pattern? I
realize I could just do all the substitutions permanently in the text
databases using a word processor etc, but I9d prefer not to alter the text
corpus if possible.

Many thanks,

Ralph Brands


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

Date: 11 Jun 1998 17:06:07 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: Can I change the word boundary anchoring pattern?
Message-Id: <5qaf7jmtcw.fsf@prometheus.frii.com>

brinton@unixg.ubc.ca (Ralph Brands) writes:
> To get around this problem, I=B9ve added code that translates any input w=
ith
> "&ae;" into "zaez", any "&t;" into "ztz" etc before the match operator
> looks for it. It is then translated back again if a match is made, and
> I=B9ve found the actual word boundaries.
> 
> This way of doing things works but all the substitutions add about 25-35%
> to the time the code needs to work.

(1) Translate the database (into zeaz and ztz) and keep that around.  Then
search it, instead of reading and translating the original each time.

(2) wherever you'd say
=09/\bWORD\b/
instead say
=09/(^|[^word characters])WORD([^word characters]|$)/
where "word characters" are the full set of things you want, e.g.
=09/(^|[^A-Za-z0-9&;])WORD([^A-Za-z0-9&;]|$)/

No doubt mjd can do it with three maps and a hash slice. :-)

Nat


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

Date: 11 Jun 1998 23:20:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: ceil or trunc
Message-Id: <6lpooa$ma4$4@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Gopinath Venkataramanan <vgopinat@cisco.com> writes:
:Is there a ceil or trunc function in perl (to round off numbers)

Maybe.

:thanx for ur time.

Thanks for reading the FAQ, which covers this.

--tom
-- 
    "No, I'm not going to explain it. If you can't figure it out, 
     you didn't want to know anyway..." --Larry Wall 


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

Date: Thu, 11 Jun 1998 15:08:17 -0700
From: "Felix S. Gallo" <fsg@newsguy.com>
Subject: Re: Certified Perl Programmers
Message-Id: <6lpk8h$k7v@enews3.newsguy.com>

Mark-Jason Dominus writes:
>For my scheme to work, it helps to have as many competing certifynig
>authorities as possible.

This blasphemous sacrilege must not be permitted to continue.
For the good of Perl, it is _clearly_ a _really_ bad idea to have
ANY more than ONE competing certification authorities.

So in order to help correct this grievous perfidy being ruthlessly
perpetrated by Mark-Jason, who has _always_ been counter
to the causes of the right and the just, I hereby announce

THE ONE TRUE CERTIFYING PERL AUTHORITY (tm) (c) (r)

This certifying authority will certify you in one of the following
job fields:

CERTIFIED PERL ENGINEER
CERTIFIED PERL SYSTEMS ENGINEER
CERTIFIED PERL CONSULTANT
CERTIFIED PERL SYSTEMS ANALYST
CERTIFIED PERL SYSTEMS ENGINEER LEVEL 9 GOLD PREMIERE

and

CERTIFIED PERL LANGUAGE OPERATOR

In addition to its existing certification practice, the other
job of the ONE TRUE CERTIFYING PERL AUTHORITY
is to root out and exterminate pretender "perl certification"
authorities such as that of the malicious puppet
Mark-Jason "Dominus" (what an obvious facade).

To obtain certification, send e-mail requesting your
particular designation to fsg@ultranet.com.  And remember:
all other wannabe "certifying" Perl authorities are for the WEAK!

Felix
p.s. plans exist for certification of 'conforming' certifying
perl authorities.  If you wish to run your own certifying perl
authority, be sure to contact the OTCPA for guidelines and
mandatory certification procedures.






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

Date: Thu, 11 Jun 1998 23:26:55 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: chopping leading spaces
Message-Id: <Pine.GSO.3.96.980611162506.5401v-100000@user2.teleport.com>

On Thu, 11 Jun 1998, Phil Taylor wrote:

> How do you chop off leading spaces in a string?

There's a good way in the FAQ.

> How do you test for a string containing spaces as opposed to being
> empty?

With either a pattern match or a string equality operator, depending upon
which I'm really checking for. You'll find good information in the perlre,
perlfunc, and perlop manpages. And you'd probably benefit from getting the
Llama book (described in perlbook). 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 11 Jun 1998 23:32:41 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: chopping leading spaces
Message-Id: <6lppep$ma4$7@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    phil@ackltd.demon.co.uk (Phil Taylor) writes:
:How do you chop off leading spaces in a string?

By reading about this question in the faq.

:How do you test for a string containing spaces as opposed to being
:empty?

By learning how to test whether a string matches a pattern.

--tom
-- 
Weinberg's Second Law: If builders built buildings the way programmers
write programs, the first woodpecker to come along would destroy civilization.


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

Date: 11 Jun 1998 18:47:42 -0500
From: Quentin  Fennessy <quentin@shaddam.amd.com>
Subject: Re: chopping leading spaces
Message-Id: <ximlnr3biw1.fsf@shaddam.amd.com>

>>>>> "Phil" == Phil Taylor <phil@ackltd.demon.co.uk> writes:
    Phil> How do you chop off leading spaces in a string?  How do you
    Phil> test for a string containing spaces as opposed to being empty?

Check the FAQ (perldoc perlfaq4):

  =head2 How do I strip blank space from the beginning/end of a string?

And this should answer your second question:

	/^\s+$/

You can find more in the docs.  Check perlre(1).

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: 11 Jun 1998 23:05:20 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Command line substitution thru subdirectories
Message-Id: <6lpnrg$ma4$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Scratchie <upsetter@ziplink.net> writes:
:But that didn't stop you from flaming him to hell and back when it was
:pointed out that your unix-based answer wouldn't work on his platform, did
:it?

I gave a *tools-based* answer.  If that's not good enough, he can damned
well write his own tools.  God knows the rest of us have when stuck
in that kind of hell.

If I told someone to use a browser to pull something in from the Net,
and they didn't well have it, and then told me to write them a browser,
I'd flame them, too.

--tom
-- 
    str->str_pok |= SP_FBM;                     /* deep magic */
    s = (unsigned char*)(str->str_ptr);         /* deeper magic */
        --Larry Wall in util.c from the perl source code


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

Date: Thu, 11 Jun 1998 23:42:30 +0200
From: Gael Marziou <gmarziou@club-internet.fr>
Subject: Re: Copy in Perl...
Message-Id: <35804F46.7A662C42@club-internet.fr>

use File::Copy;

copy ("C:\sdsd\dir1\file.txt", "C:\sd\dir2");


Uday Pai wrote:

> I have a file in dir1 and want to copy in dir2. I do not want to make a
> system call
> like
>
> system("copy C:\sdsd\dir1\file.txt C:\sd\dir2");
>
> I want a platform independent solution. Is there no function like copy()
> in perl. I
> could not find it anywhere.
>
> Thanks
>
> Uday
> uday@cyberdude.com
>
>   ------------------------------------------------------------------------
>
>   Uday Pai <uday@ionet.net>
>   CyberDude
>
>   Uday Pai
>   CyberDude  <uday@ionet.net>
>              Netscape Conference Address
>              Netscape Conference DLS Server
>   URL: http://www.ionet.net/~uday/
>   Additional Information:
>   Last Name       Pai
>   First Name      Uday
>   Version         2.1





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

Date: Thu, 11 Jun 1998 23:27:42 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Copy in Perl...
Message-Id: <Pine.GSO.3.96.980611162708.5401w-100000@user2.teleport.com>

On Thu, 11 Jun 1998, Gael Marziou wrote:

> copy ("C:\sdsd\dir1\file.txt", "C:\sd\dir2");

Do you really have a formfeed in your file's name? :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 11 Jun 1998 23:32:05 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Copy in Perl...
Message-Id: <6lppdl$ma4$6@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    gmarziou@club-internet.fr writes:
:copy ("C:\sdsd\dir1\file.txt", "C:\sd\dir2");

That's would be what in this part of the world
we cordially refer to as "wrong".  But since it's
Microsoft, I'll let Mr $Bill figure out what he
screwed up.

--tom
-- 
"I woudn't recommend sex, drugs, or Unix for everyone, but they work for me."
    Jim Thompson (jthomp@tadpole.com), paraphrasing Hunter S. Thompson


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

Date: Thu, 11 Jun 1998 22:28:54 GMT
From: rsmith@netcom.com (Richard S. Smith)
Subject: Re: File Upload
Message-Id: <rsmithEuErs7.F0t@netcom.com>

B00rah (b00rah@aol.com) wrote:
> I am looking for a simple script to Upload just one graphic at a time
> through a Web Browser without using modules.  Can anyone point me in
> the right direction?  How do I parse out the contents of the file and
> the file name from the multipart/file encoding?

First, you have to get the content type:

  $content_type = $ENV{'CONTENT_TYPE'};

Next, get the boundary:

  if ($content_type =~ /multipart\/form-data; boundary=(.*)/) {
    $boundary = $1;
  }

Now you can parse out the content of the file:

  undef $/;
  $post_stuff = <STDIN>;

  if ($post_stuff =~ /$boundary.+?;\ filename="(.*?)".*?\r\n\r\n(.*?)\r\n
                    --$boundary/sx) {
    $upload_file = Basename($1);
    $stuff = $2;
  }

  open TEMP, ">$upload_file";
  print TEMP $stuff;
  close TEMP;

The beauty of Perl is that this regexp match will work whether the
file is a few lines or several meg (I've tested it up to 10MB or so).

"Basename" is my own function (left as an exercise).

Email me if you need more help.

--
+------------------------------------------------------------------+
| Richard S. Smith / rsmith@netcom.com / http://www.idiom.com/~rss |
| Progress DBMS Stuff: http://www.idiom.com/~rss/progress-faq.html |
+------------------------------------------------------------------+


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

Date: Thu, 11 Jun 1998 19:43:32 GMT
From: "Corey Parsons" <coreyp@rc.gc.ca>
Subject: Filehandle "|mail" Question
Message-Id: <EuEK58.4o6@rc.gc.ca>

I was wondering if anyone knew how to change the 'from' field on a mail
message that is sent with with the following snippet:

open (MAIL,"|mail some_address\@here.com") || die " blah";
print MAIL "Message text";
close (MAIL);

Currently it says it's from the 'Superuser'
Any help would be greatly appreciated...

Thanks
Corey
coreyp@rc.gc.ca




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

Date: 11 Jun 1998 16:20:03 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: Filehandle "|mail" Question
Message-Id: <6lpon3$80r@Xenon.Stanford.EDU>

In article <EuEK58.4o6@rc.gc.ca>, Corey Parsons <coreyp@rc.gc.ca> wrote:
>I was wondering if anyone knew how to change the 'from' field on a mail
>message that is sent with with the following snippet:
>
>open (MAIL,"|mail some_address\@here.com") || die " blah";
>print MAIL "Message text";
>close (MAIL);

i'm sure there is a perl module you can use, but you can also just use
sendmail.

open (MAIL, "|/usr/lib/sendmail -t") || die "bah!: $!";
print MAIL qq(To: someone\@somewhere.com\n);
print MAIL qq(From: whoever\@wherever.com\n);
print MAIL qq(Subject: test\n\n);
print MAIL qq(message text);
close (MAIL);
-- 
Kelly William Hirano	                    Stanford Athletics:
hirano@cs.stanford.edu	                 http://www.gostanford.com/
hirano@alumni.stanford.org      (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20


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

Date: Thu, 11 Jun 1998 23:38:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Filehandle "|mail" Question
Message-Id: <Pine.GSO.3.96.980611163827.5401C-100000@user2.teleport.com>

On Thu, 11 Jun 1998, Corey Parsons wrote:

> I was wondering if anyone knew how to change the 'from' field on a mail
> message that is sent with with the following snippet:
> 
> open (MAIL,"|mail some_address\@here.com") || die " blah";

If you're using the proper commands to run another program from perl, but
the other program doesn't cooperate, then it's the other program's fault. 
If you're not using the proper commands, then it's your fault. If you
aren't sure about the proper commands, you should read the program's
documentation. If you've read it and you're still not sure, you should ask
in a newsgroup about the program. 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 11 Jun 1998 22:50:05 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: filehandles
Message-Id: <3580551a.17366461@news.btinternet.com>

On Thu, 11 Jun 1998 14:02:41 -0700, Wirehead wrote :

>I don't have much experience in perl. Is there an easier way to do this?
>

Eh,oh.

>#!/usr/local/bin/perl5
>
>print "Please enter the subnet in which you would like to scan:\n";
>chomp($_=<STDIN>);
>open(FINDIT, "grep $_ /etc/hosts |");
>open(FINDOUT, ">temp1");
>while (<FINDIT>){
>        print FINDOUT "$_";
>}
>close FINDIT;
>close FINDOUT;
>exit;
>

I would probably render this like:

#!/usr/local/bin/perl5 -w
# Turn the warnings on to catch Typos

print "Please enter the subnet in which you would like to scan:\n";
chomp($search=<STDIN>);
# My personal taste not to assign to $_ unless using it as default

open(HOSTS,"/etc/hosts") or die "Cannot open hosts -$!";
# *Always* check for failure of open
open(FINDOUT,">temp1") or die "Cannot oen temp1 - $!";
while(<HOSTS>)
  {
     print FINDOUT if /$search/;
     # print uses default ($_) anyhow
     # the shortcut if is for concision you could use if (/$search/){}
  }
close HOSTS;
close FINDOUT;
 
__END__

There is as you see no need to spawn the external grep because Perl
has more than adequate capability.  Perl has got a grep builtin which
you could use - you had better look at the perlfunc manpage to get an
idea how to do this.

If you do spawn an external program in a pipe like you do in your
example you should check the return of close as well - this again is
documented in the manpages.

I have assiduously avoided talking about the subnet thing as you may
have noticed.  I think that you probably need to find a more robust
method to determine this but I am sure someone will come along who can
enlighten you further on that.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Thu, 11 Jun 1998 23:22:00 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: filehandles
Message-Id: <Pine.GSO.3.96.980611162146.5401t-100000@user2.teleport.com>

On Thu, 11 Jun 1998, Wirehead wrote:

> open(FINDIT, "grep $_ /etc/hosts |");
> open(FINDOUT, ">temp1");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 11 Jun 1998 17:38:49 -0500
From: "Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu>
To: rpearce@my-dejanews.com
Subject: Re: Forcing a literal " (quote) into a form value field
Message-Id: <Pine.LNX.3.96.980611172756.1456F-100000@kollwitz.doit.wisc.edu>

On Thu, 11 Jun 1998 rpearce@my-dejanews.com wrote:

> <INPUT TYPE=TEXT NAME=whatever VALUE="$string" SIZE=30>

This is not a perl problem, but an HTML problem. If $string='This "one"'
then the HTML line looks like this:

<INPUT TYPE=TEXT NAME=whatever VALUE="This "one"" SIZE="30">

And you will get different behavior in different browsers. Some will still
be able to handle it even though it IS an HTML error, some will only get
"This " (which is what they should do) and some will and some wont
interpret the SIZE tag correctly. The easiest solution is to apply

s/"/\&quot;/g;

To all variables, becuase _within_ the "" assignment, the only problem
character is '"', while other HTML meta-characters do not seem to cause
problems in any browser. The other, more correct option, it to encode
_all_ HTML meta-characters.

You may want to look at the HTML::Entities module which will do all of
that for you. If it is not installed on your system, check your local
CPAN.

-Gabriele



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

Date: 11 Jun 1998 17:10:30 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Googol bytes (was: Re: [Q] unpack( q/%32C*/ ... ))
Message-Id: <6lpkkm$omv@fohnix.metronet.com>

Tom Phoenix <rootbeer@teleport.com> writes:
) 
) Perhaps I should have said that, in a more perl-fect world, perl would
) emit a diagnostic message (such as 'out of memory!') in this situation. 
) 
) Here's a better test case:
) 
)     perl -wle '$_ = "x" x 1e100; print "got a googol!"'
) 
) If it doesn't produce an error message, isn't Perl claiming that you've
) just malloc'd a somewhat large amount of memory? Hard to believe... :-) 

Wrong bug.  Your test case does print a diagnostic.  The orginal:

    perl -le "$_= qq/\cA/ x 4294967295; print length"

doesn't complain and it isn't that the C<x> operator failed, it is
that C<4294967295> is not a valid IV.

    C:> perl -wle "$_= ' ' x 4294967295; print length"
    0
    C:> perl -wle "$_= ' ' x 4294967299; print length"
    3
    C:> perl -wle "$_= ' ' x 429496729; print length"
    Out of memeory!
    C:>

Yes, a warning would be nice -- at least with C<-w>.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Thu, 11 Jun 1998 23:29:56 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Googol bytes (was: Re: [Q] unpack( q/%32C*/ ... ))
Message-Id: <Pine.GSO.3.96.980611162917.5401y-100000@user2.teleport.com>

On 11 Jun 1998, Tye McQueen wrote, quoting me:

> ) Here's a better test case:
> ) 
> )     perl -wle '$_ = "x" x 1e100; print "got a googol!"'
> ) 
> ) If it doesn't produce an error message, isn't Perl claiming that you've
> ) just malloc'd a somewhat large amount of memory? Hard to believe... :-) 
> 
> Wrong bug.  Your test case does print a diagnostic.  

Not on my machine. Maybe it does on yours. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 11 Jun 1998 16:39:44 -0500
From: "Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu>
Subject: Re: Help with Perl CGI script
Message-Id: <Pine.LNX.3.96.980611163324.1456D-100000@kollwitz.doit.wisc.edu>

On 11 Jun 1998, Scratchie wrote:

> Jason Bodine <jbodine@internetpro.net> wrote:
> : Hi Tom:
> 
> : Guess I should be a little more specific. LOL.  I have no problem making
> : my script send mail using the good old-fashioned To: and From: headers.
> : What I *do* have a problem with is writing a program that can utilize
> : the Cc: and Bcc: headers as well.
> 
> ???
> 
> Why can't you simply print those headers to the mail program when you're
> printing your To: and From: headers?? Am I missing something here?
> 

I confess I do not know what os we are talking about here, but this works
for me in UNIX if I do not have anyof the Mail pm's available:

open(MAIL, "| /usr/sbin/sendmail -t") or die "Puke! $!";
print MAIL <<"EOF"
To: "Someone" <someone@somewhere.com>
From: "Me" <me@mycomputer.com>
Cc: "Someone Else" <someone.else@somewhere.else.com>
Bcc: "Someone Secret" <spy@secretplace.com>
Subject: Boo!

This is an email to say "Boo! I see you!"

 .
EOF
close MAIL;

NOTE: the "." is not neccessary on 99% of all systems.

As I said, this has always worked for me since before there was a Mail.pm
on CPAN.

-Gabriele



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

Date: Thu, 11 Jun 1998 23:28:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Help with Perl CGI script
Message-Id: <Pine.GSO.3.96.980611162805.5401x-100000@user2.teleport.com>

On Thu, 11 Jun 1998, Gabriele R. Fariello wrote:

> I confess I do not know what os we are talking about here, but this works
> for me in UNIX if I do not have anyof the Mail pm's available:
> 
> open(MAIL, "| /usr/sbin/sendmail -t") or die "Puke! $!";
> print MAIL <<"EOF"
> To: "Someone" <someone@somewhere.com>

No, that doesn't work for you. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 11 Jun 1998 16:51:28 -0500
From: "Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu>
Subject: Re: I want threads, threads and more threads!
Message-Id: <Pine.LNX.3.96.980611164809.1456E-100000@kollwitz.doit.wisc.edu>

On Thu, 11 Jun 1998, John Porter wrote:

> Gabriele R. Fariello wrote:
> > 
> > 4) Something else, better, mo better than what I have been able to come up
> > with.
> 
> Umm, have you considered the SysV IPC routines?  msg*, shm*, sem* ???
> 
> John Porter
> 
> 
Heh, sorry not a SysV OS. It's on RedHat 5.0 Linux. I do not have the
option to move it to a SysV system right now. BTW I profess ignorance
on the msg*, shm* etc IPC routines. Are they (I assmue that the "*" is a
wildcard) available on other systems?

-Gabriele



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

Date: Thu, 11 Jun 1998 17:14:39 +0100
From: pat mercer <pmercer@verio.net>
Subject: Importing Modules as variables
Message-Id: <3580026F.5585@verio.net>

when importing modules into a script, is there any way to import the
module as a variable name?  for instance,

  $module_name = "My_module";

  use $module_name;  # instead of use My_module;

i receive a syntax error when i try to implement the above.

only reason i'm asking is because we're using perl for a large project
involving LOTS of modules, but only *ONE* module will be used per run.
it would be real nice if we could retrieve the module name from a hash
and then import it, say ...

  use $modules{$module_name};  # this would be VERY NICE

has anybody tried this before?  any success stories?  any workarounds?

thanks,

-pat mercer


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

Date: Thu, 11 Jun 1998 23:31:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Importing Modules as variables
Message-Id: <Pine.GSO.3.96.980611163018.5401z-100000@user2.teleport.com>

On Thu, 11 Jun 1998, pat mercer wrote:

> when importing modules into a script, is there any way to import the
> module as a variable name?  for instance,
> 
>   $module_name = "My_module";
> 
>   use $module_name;  # instead of use My_module;

Not quite like that. But if you re-write the 'use' as a BEGIN block, as
shown in perlfunc, you can make it do all sorts of tricks. Be sure that
you assign $module_name early enough, though - if the assignment is not in
a BEGIN block, it probably won't do what you want. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 11 Jun 1998 23:12:19 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: JPL Copyright
Message-Id: <Pine.GSO.3.96.980611161100.5401p-100000@user2.teleport.com>

On Thu, 11 Jun 1998, Nicholas Konidaris wrote:

> JPL which came with the Perl Resource Kit seems like a good option to
> me, however, I don't know what the copyright is on it?
> 
> If someone could tell me, I'd appreciate it!

The only (real) way to find out the copyright status of something is to
ask the author. Of course, the author may have told you already by
including that information with the other documentation. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2848
**************************************

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