[12742] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 152 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 15 10:07:16 1999

Date: Thu, 15 Jul 1999 07:05:13 -0700 (PDT)
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, 15 Jul 1999     Volume: 9 Number: 152

Today's topics:
    Re: $!: Translation 11 --> 'EAGAIN' ? (Malcolm Beattie)
    Re: [Q] Can sendmail be used for attachments? (Jenda Krynicky)
    Re: bug in vars.pm? <john@dlugosz.com>
        CGI newbie question <mlopresti@bigfoot.com>
    Re: constants in PERL <j@mesduncan.co.uk>
    Re: crypt returns different values since ISP upgrade. (Bart Lateur)
    Re: crypt() doesn't decrypt (Tad McClellan)
    Re: Determining the filesize of a given file (Stephan Budach)
    Re: FAQ 7.3: Do I always/never have to quote my strings (Steve van der Burg)
        file upload works in Netscape but not IE dougandbec@my-deja.com
    Re: Future of Perl <gellyfish@gellyfish.com>
    Re: Future of Perl <jrennie@mitre.org>
    Re: getting modify times with perl&unix (Jason Stapels)
    Re: Help reverse(@array); on ActivePerl it works, not o (Larry Rosler)
    Re: Help reverse(@array); on ActivePerl it works, not o <gellyfish@gellyfish.com>
    Re: help with line feeds ()
    Re: help with line feeds (Tad McClellan)
    Re: Help: reading from COM1 (Bbirthisel)
    Re: matching a real \ in Japanese (multibyte characters (Bart Lateur)
    Re: Newbie CGI query <picardk@my-deja.com>
    Re: pefskr lksj knna ksk <mdz4c@node14.unix.Virginia.EDU>
    Re: regex help needed <prlawrence@lehigh.edu>
        storing reference to array? <breville@mpce.mq.edu.au>
    Re: Test if a File Exists? <tchrist@mox.perl.com>
    Re: Tom Christiansen is a perlscript himself... (Tad McClellan)
        use strict <nick.sanders@lineone.net>
    Re: use strict (Bart Lateur)
    Re: use strict (Larry Rosler)
        using slices in a hash of a hash <sstarre@my-deja.com>
    Re: using slices in a hash of a hash <rick.delaney@home.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 15 Jul 1999 12:38:21 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: $!: Translation 11 --> 'EAGAIN' ?
Message-Id: <7mkknt$sru$1@news.ox.ac.uk>

In article <378D904F.509CFB8A@gmx.net>,
Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> wrote:
>I would like to print the value of errno ($!) as 'Exxxx'. Unfortunately,
>I can't seem to find out how.
>
>What I'm doing is doing a non-blocking recv using the O_NONBLOCK fcntl
>flag with recv(). When no data is available, recv returns undef and sets
>$! to EAGAIN. I would like to print out the mnemonic corresponding to $!
>on each attempt. However, using $! in a numeric context gives me 11 and
>using it in string context gives me 'Resource temporarily unavailable'.
>Is there a way to get the string 'EAGAIN' out of $! ?
>
>Looking through the docs for POSIX.pm told me that I can catch EAGAIN
>with if($! == EAGAIN) since POSIX exports EAGAIN if you give it the
>argument :errno_h in the use line. Errno.pm tells me I could write if(!
>$!{EAGAIN}). However, neither of these ways gets me any closer to my
>goal (the string 'EAGAIN'). h2ph on errno.h doesn't look promising,
>either.

There's the following nasty hack which is sort of dependent on the
current implementation of the POSIX module:

    use POSIX ":errno_h";
    foreach $name (@{$POSIX::EXPORT_TAGS{errno_h}}) {
	eval { $errname[&$name] = $name } if $name =~ /^E/;
    }

You can then use $errname[some_number] to return *one* of the "E"
numbers which gives that number. On my system, for example,
    print $errname[EAGAIN];
prints
    EWOULDBLOCK
because both names map to the same errno on this particular system
and EWOULDBLOCK happens to come after EAGAIN in the export tags list.

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"I permitted that as a demonstration of futility" --Grey Roger


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

Date: Thu, 15 Jul 1999 14:12:03 GMT
From: Jenda@McCann.cz (Jenda Krynicky)
Subject: Re: [Q] Can sendmail be used for attachments?
Message-Id: <1103_932047923@way>

On Wed, 14 Jul 1999 00:37:00 -0400, "Jessie Hernandez" <Cyanide320@NOSPAM.hotmail.com> wrote:
>   I know how to send an e-mail without an attachment with sendmail(easy!),
> but how can I send an attachment? Specifically, a page of mine has an input
> of type "file". So I'm actually going to ask two questions:
> 
> How can i get the file handle of the file that the user entered in an HTML
> form?
> 
> How can I send an e-mail with this file attachment?

Well not sendmail based, but still you may find this usefull :

#!perl
use CGI;
use Mail::Sender;

$query = new CGI;

# uploading the file...
$filename = $query->param('mailformFile');
if ($filename ne ""){
 $tmp_file = $query->tmpFileName($filename);
}

$sender = new Mail::Sender {from => 'script@mccann.cz',smtp => 'mail.mccann.cz'};
$sender->OpenMultipart({to=> 'jenda@mccann.cz',subject=> 'test CGI attach'});
$sender->Body();
$sender->Send(<<"*END*");
This is just a test of mail with an uploaded file.

Jenda
*END*
 $sender->SendFile(
          {encoding => 'Base64',
    description => $filename,
    ctype => $query->uploadInfo($filename)->{'Content-Type'},
    disposition => "attachment; filename = $filename",
           file => $tmp_file
          });
$sender->Close();

print "Content-type: text/plain\n\nYes, it's sent\n\n";
__END__ 
 

See http://Jenda.Krynicky.cz or CPAN.

HTH, Jenda



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

Date: Thu, 15 Jul 1999 08:30:47 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Re: bug in vars.pm?
Message-Id: <F11F65B053BD75F5.761DE1208A458D49.E81AC06246EBEC15@lp.airnews.net>

Thanks.

A more constructive post that would have been less effort would be something
like, "because it's way faster; see x.x.x in the faq.  Maybe someday Perl
will optomize a s// containing nothing but a single [...], but for now this
is a good trick."

That's what I managed to gather out of his message anyway -- is that right?

--John

Daniel Grisinger <dgris@moiraine.dimensional.com> wrote in message
news:m3yagiik3s.fsf@moiraine.dimensional.com...
> tadmc@metronet.com (Tad McClellan) writes:
>
> <snip>
>
> >    [ Sorry for my tone. Nothing personal. Occasionally I have to vent.
>
> Me, too
>
> You are completely out-of-line.
>
>  0-  The poster had obviously read the docs, he understood both _what_
>      was happening and _how_ it was happening.  He just didn't get
>      _why_ it was being done that particular way.
>
>      I don't know about you, but I'd much rather answer questions
>      about why things are done than about how they are done.  How
>      is readily available from any decent reference, why is often
>      a function of experience.  One of those we can reasonably
>      demand from posters, the other we can't.
>
>  1-  His confusion was made worse by the fact that he had stumbled
>      across an actual bug in perl.  Think about, that's bound to
>      throw you off.  If there's one place that I expect to find
>      well-written perl code it's in the core perl distribution.
>
>  2-  After deciding that he had probably found a bug in perl he
>      didn't go rushing off to p5p waving his hands and screaming
>      his head off.  Instead he came here to verify that it was a
>      an actual bug. That's something that I guarantee you every
>      subscriber to p5p appreciates.
>
> I understand people being frustrated by the constant flow of basic
> questions that could be answered with just a cursory inspection of the
> documentation.  But this guy did not deserve this in any way.
>
> He had done _everything_ that we could possibly have asked him to
> but was still confused.  Those are exactly the circumstances in
> which people should be coming here for help.
>
> And those are exactly the circumstances in which we should be acting
> like helpful, respectful adults, not like spoiled teenagers having a
> dick-size competition.
>
> *plonk*
>
> dgris
> --
> Daniel Grisinger          dgris@moiraine.dimensional.com
> perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
> m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'




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

Date: Thu, 15 Jul 1999 09:59:18 -0400
From: matt <mlopresti@bigfoot.com>
Subject: CGI newbie question
Message-Id: <378DE936.E135BF35@bigfoot.com>

I am writing CGI scripts for win32 and would like to know if there are
any tools or utilities that will allow me to test these scripts before I
FTP them to the server, so all the testing can be done before then? Any
ideas would be appreciated, if you recommend PWS, can you please explain
how to set it up, I'm having a great deal of difficulty with it.

Thanks in advance,
-Matt
mlopresti@bigfoot.com




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

Date: Thu, 15 Jul 1999 14:09:39 +0100
From: "James A. Duncan" <j@mesduncan.co.uk>
Subject: Re: constants in PERL
Message-Id: <378ddcef.0@news.proweb.co.uk>


Running perldoc constant should help,  but if for some reason you're missing
the POD's, try:

use constant MYCONSTANT => 'VALUE';
or
use constant MYCONSTANT => 5;

Regards,
James.

--
James A. Duncan ~ WebFusion Systems Administrator
james@webfusion.co.uk ~ j@mesduncan.co.uk

Victor Hannak wrote in message <378D30EE.F905A4A4@rochester.rr.com>...
>I could not find documentation about constants in Perl.  Is there a way
>to define a constant literal string as a number in order to make your
>program more readable?
>
>i.e.
>
>BLUE = 0;
>RED = 1;
>BLACK = 2;
>
>if ($old_house_color == BLACK) {
>    $new_house = BLUE;
>} else {
> $new_house = RED;
>}
>
>
>I know that you could just assign a variable (i.e. $BLACK = 0) but is
>this the only way?
>
>Thanks.
>




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

Date: Thu, 15 Jul 1999 12:16:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: crypt returns different values since ISP upgrade.
Message-Id: <3792d011.19918386@news.skynet.be>

robyoung wrote:

>I created a log file of usernames and passwords using Perl's crypt()
>function for one of my scripts.
>Recently, the ISP upgraded their machines.  Shortly thereafter, my users
>started calling to tell me they could not log in.

That seems familiar. In fact, I've reported to this newsgroup that
crypt() MAY return different results on different systems. Some people
were really shocked by that. :-) You may use Deja.com to look that up.

But, anyway: crypt() is compatible with your system. So the only
solution (:-/) is to re-encrypt the passwords for the users. Since YOU
don't know their passwords (you're not supposed to, anyway), You may
randomly choose new passwords, and send a mail to the users with their
new password.

Damn those ISP's.

	Bart.


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

Date: Thu, 15 Jul 1999 04:18:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: crypt() doesn't decrypt
Message-Id: <mg5km7.stk.ln@magna.metronet.com>

: Subject: crypt() doesn't decrypt


   That is correct.


Dr. Who (qwerty@post.utfors.se) wrote:

: what's the point in encrypting someting that is decryptable?


   So that only those who can decrypt it can read it.

   This question seems the exact opposite of the question in
   your Subject header.


: ... or is there really a way? :)


   Guesses.

   Lots of guesses.

   Lots and lots of guesses.


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


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

Date: Thu, 15 Jul 1999 15:07:49 +0200
From: stephan.budach@knsk-bbdo.de (Stephan Budach)
Subject: Re: Determining the filesize of a given file
Message-Id: <stephan.budach-1507991507490001@budach-stephan.intern.knsk-bbdo.de>

In article <slrn7omvmj.ump.mike@lindt.fat.dotat.at>, mike@fat.dotat.at
(Mike Bristow) wrote:

> You're not doing any error checking; try:
> 
> @stats = stat($filename) or die "Oh, my god!  I can't stat $filename: $!";
> $size = $stats[7];
> 

Mike,

thatīs true iīm not using any error checking, but that doesnīt help me
understand why the hell, stat doesnīt work an normal files. I have tried
that with Linux and with BSD, both failed. Huh?!


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

Date: 15 Jul 1999 13:53:40 GMT
From: steve.vanderburg@lhsc.on.ca (Steve van der Burg)
Subject: Re: FAQ 7.3: Do I always/never have to quote my strings or use semicolons and commas?
Message-Id: <8E0465A55stevevanderburglhsco@newshost.uwo.ca>

perlfaq-suggestions@perl.com (Tom and Gnat) wrote in 
<378d4412@cs.colorado.edu>:

>  Do I always/never have to quote my strings or use semicolons and commas?
>
[ lots of useful information snipped ]
>

What about:

% perl -Mstrict \
       -e 'sub hyphen { print join("\n",@_) } hyphen(-testing,-this)'
-testing
-this

perlop tells us why this works.  Is it worth adding to the FAQ too?

 ...Steve

-- 
Steve van der Burg
Technical Analyst, Information Services
London Health Sciences Centre
London, Ontario, Canada
Email: steve.vanderburg@lhsc.on.ca


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

Date: Thu, 15 Jul 1999 13:16:03 GMT
From: dougandbec@my-deja.com
Subject: file upload works in Netscape but not IE
Message-Id: <7mkmu9$feg$1@nnrp1.deja.com>

Thanks in advance for any help anyone can give me...

I've written a cgi script in Perl with CGI.pm that runs on an Apache web
server (v. 1.3.3) on Solaris 2.5. The script builds a web page that
lists directories and files, and also allows for file upload using the
html <input type="file"> tag.

When I test the script in Netscape Navigator 4.61, it works perfectly.
However, when I test the script using an IE client, a file is created on
the server like it is supposed to be, but it has 0 size. For some
reason, the file data isn't getting to the server when IE is used.

Does anyone have any idea why this would happen? I don't think it's my
script, but there may be something I've done wrong. Here's a little
piece of my script:

if (defined(param("File"))){
	$UploadedFileName = param("File");
	while ($Bytes = read($UploadedFileName, $Data, 2048)){
		$UploadedFile = $UploadedFile . $Data;
		$TotalBytes += $Bytes;
	}
	$OutputName = ExtractFileName($UploadedFileName);
	open(OUTPUT, ">$FullPath/$OutputName");
	print OUTPUT $UploadedFile;
	close (OUTPUT);
}

Thanks for any help you can give me!!

Doug Walker


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


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

Date: 15 Jul 1999 13:21:31 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Future of Perl
Message-Id: <378dd24b@newsread3.dircon.co.uk>

Jeffrey <Jeffrey@ix.netcom.com> wrote:
> 
> How long is Perl going to be around? 

Its been around ten years already I dont think its going to disappear.

>                                      I want to know if I'm wasting my
> time learning it. 

Its almost never a waste of time learning a useful programming language.

>                   Some say Java will replace Perl. I don't see how
> that can happen when Java is so bloody slow and such a memory hog.

And is not designed to work in the same kind of area that Perl is used
in - *where* is it supposed to replace Perl ?  

> Some say PHP3 is better. Then why hasn't it taken over yet? 

Because PHP3 is not a useful general purpose programming language - for myself
I have absolutely no use for it and probably will never.  Anyhow *who* says
PHP3 is better - I have never heard anyone suggest that ...

>                                                              I just
> don't want to spend time learning something that's going to be of no
> marketable value in the near future.
> 

Looking at the recruitment Ads in the paper this morning I remarked that
Perl seems to be in increasing demand.  

Your problem is that you seem to think that Perl is just used for 'Web
Programming' which is as far from the truth as you can get - I use Perl
everyday and less than 10% of that is anything to do with 'The Web'.  I
certainly couldnt be arsed to use Jave for most of the things I do ( that
is assuming it can do them ) and PHP3 is incapable of doing those things.

/J\
-- 
"Long before anyone else had decriminalized homosexuality, Ireland had
a thriving gay community. Or the clergy as they prefer to be known" -
Kevin Hayes


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

Date: Thu, 15 Jul 1999 09:45:04 -0400
From: "Jason D. Rennie" <jrennie@mitre.org>
To: Jeffrey <Jeffrey@ix.netcom.com>
Subject: Re: Future of Perl
Message-Id: <378DE5E0.8BC9B4EC@mitre.org>

Jeffrey wrote:
> 
> How long is Perl going to be around? I want to know if I'm wasting my
> time learning it. Some say Java will replace Perl. I don't see how
> that can happen when Java is so bloody slow and such a memory hog.
> Some say PHP3 is better. Then why hasn't it taken over yet? I just
> don't want to spend time learning something that's going to be of no
> marketable value in the near future.

Perl is the programming language equivalence of a twinkie: tasty,
wholesome, endlessly useful and capable of surviving a nuclear holcaust.
:-)  (see www.twinkiesproject.com)

Just like the twinkie, perl will never die.

Jason Rennie
781-271-7281
jrennie@mitre.org
http://www.andrew.cmu.edu/~jr6b/


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

Date: 15 Jul 1999 13:50:14 GMT
From: jmstapel_n0spam@mtu.edu (Jason Stapels)
Subject: Re: getting modify times with perl&unix
Message-Id: <7mkoum$t4u$1@campus1.mtu.edu>

I'm afraid this doesn't help... if could rely on the fact that
the remote machine had perl, I could easily use a stat command,
unforunetely I can't.

Of course I'm curious as to how this works... where would I
specify a specific file to check the mtime on?

Jason



Larry Rosler (lr@hpl.hp.com) wrote:
: In article <slrn7opq3a.4jl.*@dragons.duesouth.net> on Wed, 14 Jul 1999 
: 20:08:43 GMT, Matthew Bafford <*@dragons.duesouth.net> says...
: ...
: > $mtime = qx!remsh $hostname "perl -e 'print modtime'"!;

: I don't understand this.  Are you not instructing the remote perl to 
: print the contents of (undefined) $_ to an (unopened) filehandle 
: 'modtime'?

: Please clarify what this actually does.

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


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

Date: Thu, 15 Jul 1999 06:03:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help reverse(@array); on ActivePerl it works, not on line
Message-Id: <MPG.11f77bfff9685fcf989cd6@nntp.hpl.hp.com>

In article <378E2542.6048@XXXtechnologist.com> on Thu, 15 Jul 1999 
11:15:30 -0700, scientiaXXX <scientiaXXX@XXXtechnologist.com> says...
 ... 
> I need to use
> reverse(@host);
> where @host is an array.
> 
> It works on Active Perl (in DOS/Win95)
> but when I upload it to my server (Unix)
> it does not work!
> No errors, the program runs correctly
> but reverse is ignored and the array remains the same!

Can you post a small but self-contained piece of code that demonstrates 
this remarkable problem?

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


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

Date: 15 Jul 1999 14:38:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help reverse(@array); on ActivePerl it works, not on line
Message-Id: <378de453@newsread3.dircon.co.uk>

scientiaXXX <scientia@technologist.com> wrote:
> 
> I need to use
> reverse(@host);
> where @host is an array.
> 
> It works on Active Perl (in DOS/Win95)
> but when I upload it to my server (Unix)
> it does not work!
> No errors, the program runs correctly
> but reverse is ignored and the array remains the same!

Without seeing your code I can only suggest that you are mistaken - there
is nothing in the difference between running a Perl program at the
command prompt and running in the CGI environment that would cause this.

Please post the smallest piece of code that works but will demonstrate this
behaviour.

/J\
-- 
"I thought homogenous culture was a kind of yogurt used to alleviate
thrush" - Ben Elton


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

Date: 15 Jul 1999 12:16:31 GMT
From: dcross@tech-19.quixell.com ()
Subject: Re: help with line feeds
Message-Id: <7mkjev$3n6$1@starburst.uk.insnet.net>

Kevin Howe (khowe@performance-net.com) wrote:
: Is there a way to convert UNIX lines feeds to NT and vice versa using Perl?

Unix marks the end of line with \n. NT (and all other MS excuses for 
Operating Systems) uses \r\n. Armed with this knowledge, it's trivial
to produce a Perl implementation of dos2unix or unix2dos. dos2unix
would look something like this:

while (<STDIN>) {
  s/\r\n/\n/;
  print;
}

unix2dos is left as an exercise for the reader.

hth,

Dave...



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

Date: Thu, 15 Jul 1999 04:34:51 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with line feeds
Message-Id: <bf6km7.stk.ln@magna.metronet.com>

Kevin Howe (khowe@performance-net.com) wrote:

: Is there a way to convert UNIX lines feeds to NT and vice versa using Perl?


   perl -p -i -e 's/\r//g'  filenames...              # dos2unix

   perl -p -i -e 's/\n/\r\n/g'  filenames...          # unix2dos


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


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

Date: 15 Jul 1999 13:11:50 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Help: reading from COM1
Message-Id: <19990715091150.29661.00000481@ng-bg1.aol.com>

Hi George:

>I'm trying to read a text file coming through COM1 on an NT 4.0
>system.  I'm using the following commands in a Perl script:
>
>  open (Scanner, "COM1") or die "Can't open COM1/n";

The preferred solution to this is to use the Win32::SerialPort
module from CPAN.

The other (read-only case on NT) is possible with a 
system (mode ...) command to configure the port. But it
doesn't scale well to interactive use and doesn't work at
all on Win9x.

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Thu, 15 Jul 1999 12:11:15 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: matching a real \ in Japanese (multibyte characters)
Message-Id: <3791cf36.19700059@news.skynet.be>

Anatole Varin wrote:

>I'm having trouble adapting a Perl script to support Japanse shift-jis
>characters. The problem I'm having is that part of my script has regexs
>such as these:
>
>s/\\/&#92;/g;
>s/\(/&#40;/g;
>s/\)/&#41;/g;
>s/\[/&#91;/g;
>s/\]/&#93;/g;
>
>The problem is these characters are often the second byte of a double
>byte japanese character, so Perl ends up slicing of a byte that I would
>prefer it didn't.
>
>I've done a bit of reasearch and I've found out that the first byte of
>any two-byte shift-jis character falls in the range of:
>
>0x81-0x9F or 0xE0-0xEF
>
>the second byte falls in the range of:
>
>0x40-0x7E or 0x80-0xFC (where \()[] and other friends seem to hang out)
>
>Any ideas how I could make a regex that would only match \ (for example)
>if were not part of the two-byte sequence above?

Try matching the two bytes first, and matching one of the above
characters if something else. Simple version:

	s/([\x81-\x9F\xE0-\xEF].)|\(/$1 || '&#40;'/ge;

Note that if the two byte sequence is found, it is replaced by itself
($1 then is 2 bytes, which is always true), or, if not, you found a "("
which is replaced by that other string.

You can throw the other chacters in as well: the number on the right is
their Ascii code, so:

	s/([\x81-\x9F\xE0-\xEF].)|([()\[\]\\])/
		$1 || '&#'.ord($2).';'/ge;

Even a more general solution (no obvious connection between the
character and the substitution) can be done using a hash:

	%replace = ( '\\' => '&#92', '(' => '&#40;', ')' => '&#41;',
			'[' => '&#91;', ']' => '&#93' ) ;
	s/([\x81-\x9F\xE0-\xEF].)|([()\[\]\\])/$1 || $replace{$2}/ge;

	Bart.


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

Date: Thu, 15 Jul 1999 13:40:37 GMT
From: Keith P <picardk@my-deja.com>
To: saku.new@ytti.net
Subject: Re: Newbie CGI query
Message-Id: <7mkoci$g2m$1@nnrp1.deja.com>

Thank you for the advice.  I'll give it a try.

Before I go, let me give you some background on what it is I'm trying
to do.  We have a web site where we have page which displays the daily
Pollen count.  At present, the variable information (Date of reading,
Count and forecast) is hard coded (YUCK!) in the HTML.  It was my idea
that this might be a good place to use Perl.  I wrote an HTML "form"
which accepts the variable information and submits it to a Perl program
which validates it and writes it to a file.  So far, so good.  What I
need now is a way to modify the existing Pollen page HTML to call a
Perl program which fetches the values from data file.  Is it possible
for a Perl program to pass information back to the calling HTML?  Or
would the Perl program need to construct it's own HTML (as in your
example)?  I could do it with SSI calls but that seems inefficient (I
think I'd need on call per variable).  Also, it wouldn't be Perl.

Please excuse my lack of familiarity with CGI techniques and my
reckless use of terminology.

In article <slrn7omqdd.9ub.saku.news@ytti.net>,
  saku.news@ytti.net (Saku Ytti) wrote:
>
> open(FOO,file);
> $foo=<FOO>;
> ($foo[0], $foo[1], $foo[2])=split(/:/,$_,3);
> print<<EOF;
> Content-type: text/html
>
> $foo[0], $foo[1], $foo[2]
> EOF
>

--
Keith Picard


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


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

Date: Thu, 15 Jul 1999 08:51:13 -0400
From: Matthew Zimmerman <mdz4c@node14.unix.Virginia.EDU>
Subject: Re: pefskr lksj knna ksk
Message-Id: <Pine.A41.4.05.9907150850340.32524-100000@node14.unix.Virginia.EDU>

On Wed, 14 Jul 1999, Dr. Who wrote:

> Ikjsf!!
> sl=F6k ksl=F6dk =F6lkwe nmm,n sdmn  iowu oijhbjnmx ljkeeeor ukl ...... sl=
kjj
> lkjlwr ..
> slkj ,nwer  opisdv ???
> jskklsjdf lkj woieru ojkl   ncmnm,errrrrwr?

You really need to work on your trolling technique.

Matt=20
--
Matthew Zimmerman            http://www.people.virginia.edu/~mdz4c
Interdisciplinary Biophysics Program        University of Virginia
------------------------------------------------------------------
"You got to be very careful if you don't know where you're going,
because you might not get there."                    -- Yogi Berra



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

Date: Thu, 15 Jul 1999 08:54:05 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Re: regex help needed
Message-Id: <7mklle$ao0@fidoii.cc.Lehigh.EDU>


Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
> Phil R Lawrence <prlawrence@lehigh.edu> wrote:
> > DB<1> $r2 = '(?i)^(\s*(M|F|U)\,?\s*)+$'
>
> You want to require a comma or whitespace or both after each letter.
> So:
> $r2 = '(?i)^(\s*[MFU][,\s]\s*)+$'

Actually, I want to require a comma or whitespace after each letter *only* if
another letter follows.  Otherwise one couldn't simply enter one letter and then
ENTER.

Phil R Lawrence






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

Date: Thu, 15 Jul 1999 23:51:27 +1000
From: "Brendan Reville" <breville@mpce.mq.edu.au>
Subject: storing reference to array?
Message-Id: <7mkp1r$omj$1@sunb.ocs.mq.edu.au>

hi all,

Regarding get ( MSGNUM ) in Net::POP3

  "Get the message MSGNUM from the remote mailbox. Returns a
  reference to an  array which contains the lines of text read
  from the server. "

I tried storing this "reference to an array" by saying:
  $message_ref = get(0);
but I get: syntax error at test.pl line 16, near "$get("

Q: Is this "syntax error" related to my use of message_ref?
Q: At any rate, how do I store this reference to the array, and subsequently
dereference it?


(I've had no luck finding sample code for Net::POP3.)

Thanks very much!





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

Date: 15 Jul 1999 06:07:20 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Test if a File Exists?
Message-Id: <378dcef8@cs.colorado.edu>

In comp.lang.perl.misc, 
    rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
:> Phone your sysadmin and ask him to read out the manual for you.
:> If there are 2 sysadmins in your MIS department, they can do it
:> in stereo. With 3 or more, they can sing it in an ensemble.
:
:Oo, how about a round?

A round?  A bloody *round*?  What do we need obsequious repetition for?
Are not unbridled creativity, innovative intelligence, and multifaceted
multiplicities of meaning the hallmarks of the Perl programmer?

This clearly indicates that the optimal model for documentation listening
should of course be a fugue.  It's not clear how the pieces would be
woven and stacked so that they have both a vertical parse (chordal) and
a horizontal one (melodic), but a seven-part fugue comprising perlref,
perldsc, perllol, perltoot, perltootc, perlobj, and perltie would be
a wonder to behold.

--tom
-- 
#ifdef USE_STD_STDIO    /* Here is some breathtakingly efficient cheating */
    --Larry Wall, from sv.c in the v5.0 perl distribution


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

Date: Thu, 15 Jul 1999 04:15:21 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Tom Christiansen is a perlscript himself...
Message-Id: <pa5km7.stk.ln@magna.metronet.com>

Dr. Who (qwerty@post.utfors.se) wrote:


: Why doesn't Larry Wall post things here?


   He used to.

   I expect the signal-to-noise ratio became such that he felt it
   wasn't worth his time any longer.

   Let's thank all of the pre-K posters of FAQs and off-topic
   articles for driving him (and scores of other gurus) off.


   Folks who are new to this newsgroup don't know about such things.

   Savvy Usenetters do know about such things.

   Hence newbies wonder why the experienced folks don't like FAQs
   and off-topic posts.



----------------------------------------------
In article <1995Nov9.193745.13694@netlabs.com>, lwall@netlabs.com (Larry
Wall) wrote: ...

<Larry>  [snip]  I view a programming language as a place to be
<Larry>  explored, like Disneyland. You don't need to have a lot of preparation
<Larry>  to explore a theme park.  You do have to go along with the crowd
<Larry>  control measures, though.  In a sense, each ride has its own
<Larry>  prerequisites--if you cut in line, you risk getting tossed out of the
<Larry>  park.
<Larry> 
<Larry>  What we have here in this newsgroup is a failure in crowd control.
<Larry>  Reading the FAQ is like staying in line--it's something you should
<Larry>  learn in kindergarten.  Usenet needs a better kindergarten.
----------------------------------------------


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


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

Date: Thu, 15 Jul 1999 11:46:21 +0100
From: Nick Sanders <nick.sanders@lineone.net>
Subject: use strict
Message-Id: <378DBBFC.6C8A2434@lineone.net>

I have just tried using strict for the first time and all scripts fall
over mainly with errors like the one below

Variable "$body" is not imported at d:/msdweb/cgi-bin/staff_search.pl
line 52. (Did you mean &body instead?) Global symbol "body" requires
explicit package name at d:/msdweb/cgi-bin/staff_search.pl line 52

For the line below

  $body = "<body background=\"../images/back.gif\" bgcolor=\"#000000\"
text=\"#ffffff\" link=\"#d7bb0f\" vlink=\"#9a9698\">";

Can someone tell me what is wrong??

Thanks

Nick



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

Date: Thu, 15 Jul 1999 12:44:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: use strict
Message-Id: <378dd716.21715916@news.skynet.be>

Nick Sanders wrote:

>I have just tried using strict for the first time and all scripts fall
>over mainly with errors like the one below
>
>Variable "$body" is not imported at d:/msdweb/cgi-bin/staff_search.pl
>line 52. (Did you mean &body instead?) Global symbol "body" requires
>explicit package name at d:/msdweb/cgi-bin/staff_search.pl line 52
>
>For the line below
>
>  $body = "<body background=\"../images/back.gif\" bgcolor=\"#000000\"
>text=\"#ffffff\" link=\"#d7bb0f\" vlink=\"#9a9698\">";
>
>Can someone tell me what is wrong??

You have to declare the variable $body. Basically, there are two ways:

A) You want to keep $body a global, so that it can be accessed from
other (library) files as well, or so that local() works on it. Then, do

	use vars qw($body);

You can add other variables to that line, separated from "$body" with a
space.

B) You don't need it as a global. So make it a lexical instead:

	my $body;

in the main text of the script, not in a block.

   HTH,
   Bart.


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

Date: Thu, 15 Jul 1999 05:59:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: use strict
Message-Id: <MPG.11f77b027cbb89dd989cd5@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <378DBBFC.6C8A2434@lineone.net> on Thu, 15 Jul 1999 11:46:21 
+0100, Nick Sanders <nick.sanders@lineone.net> says...
> I have just tried using strict for the first time and all scripts fall
> over mainly with errors like the one below
> 
> Variable "$body" is not imported at d:/msdweb/cgi-bin/staff_search.pl
> line 52. (Did you mean &body instead?) Global symbol "body" requires
> explicit package name at d:/msdweb/cgi-bin/staff_search.pl line 52
> 
> For the line below
> 
>   $body = "<body background=\"../images/back.gif\" bgcolor=\"#000000\"
> text=\"#ffffff\" link=\"#d7bb0f\" vlink=\"#9a9698\">";
> 
> Can someone tell me what is wrong??

`perldoc strict` can tell you what is wrong.  See the section on "strict 
'vars'".

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


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

Date: Thu, 15 Jul 1999 12:15:39 GMT
From: S Starre <sstarre@my-deja.com>
Subject: using slices in a hash of a hash
Message-Id: <7mkjd4$e54$1@nnrp1.deja.com>

 I'm tyring to use something like:

  foreach (@main::names2)
   {@h{$_}{@main::names} = @main::thelist;

and I get:

Can't use subscript on hash slice at x.pl line 23, near "@main::names}"

why? @h{$_}{@main::names} is a slice isn't it?

Also, can I use opendbm to store a hash of a hash?

HUG,
S

--

Proud Member of the Working Minority in the USA
-S Starre 1999


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


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

Date: Thu, 15 Jul 1999 12:56:20 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: using slices in a hash of a hash
Message-Id: <378DDA43.9F9E5EFF@home.com>

[posted & mailed]

S Starre wrote:
> 
>  I'm tyring to use something like:
> 
>   foreach (@main::names2)
>    {@h{$_}{@main::names} = @main::thelist;

If you put 

    use vars qw/@names @names2 @thelist/;

at the top of your program then you won't have to use the ugly @main::
syntax.  Or you could have just declared them with C<my>.

> and I get:
> 
> Can't use subscript on hash slice at x.pl line 23, near "@main::names}"
> 
> why? @h{$_}{@main::names} is a slice isn't it?

Not quite.  You want to take a slice of the hash that $h{$_} is a
reference to.  So simply plug the reference into where the hash name
would normally go:

    @{ $h{$_} }{ @names } = @thelist;

> Also, can I use opendbm to store a hash of a hash?

perldoc perlfaq4

    How can I store a multidimensional array in a DBM file?

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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 V9 Issue 152
*************************************


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