[10048] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3641 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 5 00:06:10 1998

Date: Fri, 4 Sep 98 21:00:18 -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, 4 Sep 1998     Volume: 8 Number: 3641

Today's topics:
    Re: Algorithm help...math and perl... <rick.delaney@shaw.wave.ca>
        Beginner need help with sendmail-t <softsci@eagle.ca>
    Re: Beginner need help with sendmail-t <eashton@bbnplanet.com>
        Best way to log? <rmarsha8@csc.com>
    Re: Best way to log? <rra@stanford.edu>
    Re: Does open() lock the file? <sugalskd@netserve.ous.edu>
    Re: Execute END{} at CGI termination? (Larry Rosler)
    Re: Execute END{} at CGI termination? <uri@sysarch.com>
    Re: Execute END{} at CGI termination? (Jonathan Stowe)
    Re: grouping list of ARRAY refs with grep ? <ajohnson@gpu.srv.ualberta.ca>
    Re: Hats off to Tom Phoenix <dan@fearsome.net>
    Re: Hats off to Tom Phoenix (Larry Rosler)
    Re: my lousy syntax (Mark-Jason Dominus)
    Re: or vs || with open function <dgris@rand.dimensional.com>
    Re: Perl Cookbook, does anyone have it? <beirne@neo.lrun.com>
    Re: Perl Cookbook, does anyone have it? (j)
    Re: Perl gurus opinion needed. <thor@eznet.net>
        Perl <nova9@znet.com>
        reading a file backward <sekchye@singnet.com.sg>
    Re: Regexp to toggle a part of a string (Andre L.)
    Re: Regexp to toggle a part of a string (Andre L.)
        sendmail -t <softsci@eagle.ca>
    Re: sendmail -t <rra@stanford.edu>
        Truncation occurring when passing values as hidden vari (Darren Hayes)
    Re: Truncation occurring when passing values as hidden  (Larry Rosler)
    Re: Truncation occurring when passing values as hidden  (Darren Hayes)
    Re: Use Perl to sendmail: open once, send multiple time <garry@america.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 05 Sep 1998 03:30:48 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Algorithm help...math and perl...
Message-Id: <35F0B1EC.874E9216@shaw.wave.ca>

[posted & mailed]

jhildeb2@my-dejanews.com wrote:
> 
> Excuse me if I have misinterpreted what you're trying to accomplish 
> here but it looks to me like all you want to do is rename the files.  
> Instead of reading in the file and writing it out to a different file 
> it would be easier to use the move command from File::Copy.

It would be easier still to use the built-in rename function.

perldoc -f rename
HTH

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Fri, 4 Sep 1998 20:26:24 -0400
From: "Soft Science" <softsci@eagle.ca>
Subject: Beginner need help with sendmail-t
Message-Id: <6sq1te$8gu$1@mur2.odyssey.on.ca>

Hi:

OPEN (MAIL, "|$mailprogram -t") || die "can't open $mailprogram";
What does -t in the above line do?

-Kumar Sundaram




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

Date: Sat, 05 Sep 1998 03:30:36 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Beginner need help with sendmail-t
Message-Id: <35F0AE04.68AEF6C6@bbnplanet.com>

man sendmail.

e.


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

Date: 5 Sep 1998 01:25:44 GMT
From: "Robert Marshall" <rmarsha8@csc.com>
Subject: Best way to log?
Message-Id: <01bdd86b$0fc65b80$33440509@pissant.marshall.com>

In Perl 5, running on Linux, what is the best, fastest, lowest overhead
method to add entries to the syslog? I can shell the logger utility, like
this...

`logger -i -t TEST Hi! This is a log message`;

 ... but this seems to involve too much overhead. In this application,
several iterations of the Perl script may be invoked at once, just like
CGI. Would the best approach be to open a socket? Or to write to /dev/log?
I am a Perl beginner, and Linux novice, so please be kind.



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

Date: 04 Sep 1998 19:24:40 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Best way to log?
Message-Id: <m3ogsvjnyv.fsf@windlord.Stanford.EDU>

Robert Marshall <rmarsha8@csc.com> writes:

> In Perl 5, running on Linux, what is the best, fastest, lowest overhead
> method to add entries to the syslog? I can shell the logger utility,
> like this...

> `logger -i -t TEST Hi! This is a log message`;

> ... but this seems to involve too much overhead. In this application,
> several iterations of the Perl script may be invoked at once, just like
> CGI. Would the best approach be to open a socket? Or to write to
> /dev/log?

Use Sys::Syslog would probably be the best way, but bear in mind that I
believe it still relies upon a working h2ph.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 5 Sep 1998 00:04:27 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: Does open() lock the file?
Message-Id: <6spv6b$nm$1@news.NERO.NET>

smitzla@uswest.com wrote:
: When I do an open() on a file for writing, is the file that is opened locked
: in any way that would prevent other processes from writing to this file or
: otherwise manipulating it? I've looked for the answer and can't find it but
: from what I've read, my guess would be NO, judging by what I've read in the
: flock() documentation.

The answer's actually maybe. The VMS and OS/2 versions do depending on
your open mode. I think the Win32 port does as well.

				Dan


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

Date: Fri, 4 Sep 1998 17:28:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Execute END{} at CGI termination?
Message-Id: <MPG.105a25975151ba3f989798@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <35F073E4.4B8BC787@earthlink.net> on Fri, 04 Sep 1998 16:12:36 
-0700, Mooneer Salem <mooneer@earthlink.net> says...
> Larry Rosler wrote:
> > That *did* make a difference.  Now &END gets executed, four times!!!!  (I
> > know this because it appends four messages to the debug file.)  Why????
> > 
> > But still no output to the browser (print STDOUT) from &END.  Netscape
> > Navigator appends a horizontal rule and 'Transfer interrupted!' to the
> > output; MSIE just stops quietly.  Where is the bit-bucket?
> 
> Do these two things:
> 
> 1. Put exit(0); at the end of &END

Nope.  I changed the existing 'exit;' to 'exit 0;' and nothing changed.  
Not that I expected it to.  Still *four* outputs from &END!  

> 2. Change it into a NPH script, meaning adding "nph-" to the filename
> and adding the following line before the line that prints out the
> "Content-type:" header:
> 
> print "HTTP/1.0 200 OK\n";

Did that too -- still no change.

I have now had a chance to test this program on Windows NT with IIS4 
server and perl5.004; earlier tests were with HP-UX and Netscape 
FastTrack server and perl5.002.  The IIS server hasn't been configured to 
serve nph- scripts and offers to download them, so I can't check that 
now.  But on NT the original program doesn't get to &END at all when 
interrupted by the browser, even with $SIG{PIPE} added as you suggested 
earlier.  No real pipes, I think.

That's a lot of variables that still produce similar odd but very 
deterministic behavior.  Hmmm...  Maybe the long weekend will produce 
some insights, or someone else will have some ideas.

Thanks for your useful suggestions.

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


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

Date: 04 Sep 1998 22:34:38 -0400
From: Uri Guttman <uri@sysarch.com>
To: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Execute END{} at CGI termination?
Message-Id: <x7pvdb1e4h.fsf@sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
  >> 1. Put exit(0); at the end of &END

  LR> Nope.  I changed the existing 'exit;' to 'exit 0;' and nothing
  LR> changed.  Not that I expected it to.  Still *four* outputs from
  LR> &END!

did you put the exit inside of END?

IIR END is called from exit so exit inside of END maybe some strange loop.

sounds like the cgi script is getting a broken pipe as adding that
handler did something. try making 4 separate sig handlers so you can see
which is called when. maybe it looks like each is calling END themselves
which is why you see the output 4 times.

if you really are calling exit in END and it doesn't exit hard, maybe
try syscall( &SYS_exit ) with syscall.ph included. this won't be abe to
call perl's exit or END again.

and as others have said, when you hit stop on a browser, it should stop
displaying any more data so how could you expect the cgi's END to get
displayed.

uri

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


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

Date: Sat, 05 Sep 1998 02:47:21 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Execute END{} at CGI termination?
Message-Id: <35f0a321.983981@news.btinternet.com>

On Fri, 4 Sep 1998 17:28:42 -0700, Larry Rosler wrote :

[Posted to comp.lang.perl.misc and something completely mailed.]

>[Posted to comp.lang.perl.misc and a copy mailed.]
>
>In article <35F073E4.4B8BC787@earthlink.net> on Fri, 04 Sep 1998 16:12:36 
>-0700, Mooneer Salem <mooneer@earthlink.net> says...
>> Larry Rosler wrote:
>> > That *did* make a difference.  Now &END gets executed, four times!!!!  (I
>> > know this because it appends four messages to the debug file.)  Why????
>> > 
>> > But still no output to the browser (print STDOUT) from &END.  Netscape
>> > Navigator appends a horizontal rule and 'Transfer interrupted!' to the
>> > output; MSIE just stops quietly.  Where is the bit-bucket?
>> 
>> Do these two things:
>> 
>> 1. Put exit(0); at the end of &END
>
>Nope.  I changed the existing 'exit;' to 'exit 0;' and nothing changed.  
>Not that I expected it to.  Still *four* outputs from &END!  
>
>> 2. Change it into a NPH script, meaning adding "nph-" to the filename
>> and adding the following line before the line that prints out the
>> "Content-type:" header:
>> 
>> print "HTTP/1.0 200 OK\n";
>
>Did that too -- still no change.
>
>I have now had a chance to test this program on Windows NT with IIS4 
>server and perl5.004; earlier tests were with HP-UX and Netscape 
>FastTrack server and perl5.002.  The IIS server hasn't been configured to 
>serve nph- scripts and offers to download them, so I can't check that 
>now.  But on NT the original program doesn't get to &END at all when 
>interrupted by the browser, even with $SIG{PIPE} added as you suggested 
>earlier.  No real pipes, I think.
>
>That's a lot of variables that still produce similar odd but very 
>deterministic behavior.  Hmmm...  Maybe the long weekend will produce 
>some insights, or someone else will have some ideas.
>

Lot of wrong tree barking going on here.  As far as I can tell under
usual circumstances there can be no output to the browser because the
browser closes its end of the connection first - the detection of this
condition causes the server to do whatever it was designed to do in
such a situation but which cannot include sending anything to the
client because there is no longer a mechanism for it to do so.

Sorry about that guys. Anyhow time for me to go back to bed.

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



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

Date: Fri, 04 Sep 1998 19:22:36 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: grouping list of ARRAY refs with grep ?
Message-Id: <35F0844C.1F29ABD8@gpu.srv.ualberta.ca>

Phil R Lawrence wrote:
!
! Hello, witness the following array:
! 
! my @beginning_list= (['abc','def','abc'],
!                     ['def','abc'],
!                     ['ghi','jkl','jkl'],
!                     ['jkl','ghi','jkl'],
!                     ['mno','pqr']
! );
! 
! I want to group together those references that share the same 1st two
! elements (regardless of order) in a new array.  So, output should be:
! 
! (
!     [
!         ['abc','def','abc'],
!         ['def','abc']
!     ],
!     [
!         ['ghi','jkl','jkl'],
!         ['jkl','ghi','jkl']
!     ],
!         ['mno','pqr']
!     ]
! )
! 
! Following is my attempt.  Any hints would be sorely appreciated!


I think I'd use a hash as an intermediary in this case, using
stringified slices (first two elements) of each array-ref as
keys in the hash: I seem to be at a lack for words to describe
this any simpler than just showing the code, so here it is:

note: this will not retain any sense of ordering in the
@grouped array, just the groupings:

#!/usr/bin/perl -w
use strict;
my @beginning_list= (['abc','def','abc'],
                     ['def','abc'],
                     ['ghi','jkl','jkl'],
                     ['jkl','ghi','jkl'],
                     ['abc','abc'],
                     ['def','abc','foo'],
                     ['mno','pqr']
                    );

# group array refs by first two items:
my %hash;
foreach my $aref (@beginning_list){
    exists $hash{"@$aref[1,0]"}
        ?(push @{$hash{"@$aref[1,0]"}},$aref)
        :(push @{$hash{"@$aref[0,1]"}},$aref);
}
my @grouped=values %hash;

# print it out:
for(@grouped){
    print "[\n";
    for(@$_){
        print "  [@$_]\n";
    }
    print "]\n"
}
__END__

hope that helps,
regards
andrew


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

Date: Sat, 5 Sep 1998 01:00:04 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Re: Hats off to Tom Phoenix
Message-Id: <904953568.20377.0.nnrp-10.c2deb1c5@news.demon.co.uk>


Larry Rosler wrote in message ...

><SNIPPED> an outrageous, disgusting, off-topic response to someone who is
>just trying to spread good feelings about Tom P, onw of the most
>important contributors here.


Wow, somebody really got into a tantrum, didn't they. My reply was neither
outrageous or disgusting, and was no more off-topic than either the post it
was a response to, or your own followup. Seems like your hypocriticism is on
a par to those "in the synagogue". If you don't like atheism, say so. Just
spare us the sickening moral outbursts of dubious integrity.

>Please can your bigotry, or peddle it elsewhere.

Get a grip.

HTH,

--

Dan Adams
dan@fearsome.net
http://fearsome.net





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

Date: Fri, 4 Sep 1998 17:20:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Hats off to Tom Phoenix
Message-Id: <MPG.105a239cb5a4c9f3989797@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <904953568.20377.0.nnrp-10.c2deb1c5@news.demon.co.uk> on Sat, 
5 Sep 1998 01:00:04 +0100, Daniel Adams <dan@fearsome.net> says...
> Larry Rosler wrote in message ...
> 
> ><SNIPPED> an outrageous, disgusting, off-topic response to someone who is
> >just trying to spread good feelings about Tom P, onw of the most
> >important contributors here.
> 
> Wow, somebody really got into a tantrum, didn't they. My reply was neither
> outrageous or disgusting, and was no more off-topic than either the post it
> was a response to, or your own followup. Seems like your hypocriticism is on
> a par to those "in the synagogue". If you don't like atheism, say so. Just
> spare us the sickening moral outbursts of dubious integrity.
> 
> >Please can your bigotry, or peddle it elsewhere.
> 
> Get a grip.
> 
> HTH,

Perhaps Chip shouldn't have introduced his religion on this forum, but that was no invitation to the savage attack that he was subjected to.

The postings on netiquette suggest that when one is about to post a 
message with "you" in it addressed to an individual, one might best 
consider taking the correspondence offline.  I will post no further in 
regard to this monstrosity.

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


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

Date: 4 Sep 1998 20:14:08 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: my lousy syntax
Message-Id: <6spvog$442$1@monet.op.net>

In article <6spmm2$u99$1@nnrp1.dejanews.com>,  <mmesmer@yahoo.com> wrote:
>Someone please help me with the following snippet!  I cannot figure out what's
>wrong with it.

Buffering.

Someone else followup please, I don't have time.

>while (! -e "$filepath") {
>print '.';




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

Date: Sat, 05 Sep 1998 00:29:13 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: or vs || with open function
Message-Id: <6spvt2$31q$1@rand.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

In article <fl_aggie-0409981315090001@aggie.coaps.fsu.edu>
fl_aggie@thepentagon.com (I R A Aggie) wrote:

>open HANDLE, "some_file" || die $!; # right
>open(HANDLE, "some_file") or die $!; # note the use of () on open, also ok
>open HANDLE, "some_file" or die $!; # doesn't do what you think it should

You've got this exactly backward.  The first example
doesn't do what you'd expect while the third does.

dgris
-- 
Daniel Grisinger        dgris@perrin.dimensional.com
`C++ gives me the willies.  Physical willies.  I take
 medication for it.'
                    Kurt Starsinic on p6p


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

Date: Fri, 04 Sep 1998 22:21:33 -0400
From: Beirne Konarski <beirne@neo.lrun.com>
Subject: Re: Perl Cookbook, does anyone have it?
Message-Id: <35F0A02D.281557E0@neo.lrun.com>

John Call wrote:
> 
> Has anyone gotten a copy of this yet? I'm dying to get it and it doesn't
> seem to have reached Georgia yet.
> 
> If you do have it, do you like it? From what I've seen on the ORA site it
> looks good.
> 
> --
> John Call
> IBM Interactive Media

I got mine from Barnes & Noble for $31 including shipping.  It is a very
good book, especially if you do better learning from example code than
from instructions.  Each topic describes how to solve some sort of
problem.  There is then a code sample, and a description of what the
sample does and any issues involved.  I'd recommend it highly.

Beirne

-- 
Beirne "Bern" Konarski  | Unicycling Home Page:
beirne@neo.lrun.com     | http://www.unicycling.org 
"Untouched by Scandal"  | Unicycling Society of America:
                        | http://www.unicycling.org/usa/


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

Date: Sat, 05 Sep 1998 03:42:17 GMT
From: mocat@best.com (j)
Subject: Re: Perl Cookbook, does anyone have it?
Message-Id: <35f0b25e.151533375@nntp.best.com>

On Fri, 04 Sep 1998 22:21:33 -0400, Beirne Konarski
<beirne@neo.lrun.com> wrote:

>John Call wrote:
>> 
>> Has anyone gotten a copy of this yet? I'm dying to get it and it doesn't
>> seem to have reached Georgia yet.
>> 
>> If you do have it, do you like it? From what I've seen on the ORA site it
>> looks good.
*snip*

I got mine from barnes and noble online as well, just got it today.
Haven't had much of a chance to look through it in depth, but from
what I've seen, it's a great book.  Lots of common problems (and not
so common ones) and how to fix them in numerous ways.
And it's the first ORA book (the only ones worth buying, really) to
cover the tk extensions for perl in depth... ;) happy day.

Just by scanning through it, I'd recommend it.




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

Date: Fri, 04 Sep 1998 19:50:13 -0400
From: thor <thor@eznet.net>
Subject: Re: Perl gurus opinion needed.
Message-Id: <35F07CB5.5193AFA9@eznet.net>

Elaine -HappyFunBall- Ashton wrote:
<snip>
> perl master                  /{kinky!
> perl slave                   \
<snip>
> perl psycho                  {aren't we all?!?
<snip>
> perl thermonuclear device    {1Gigaton?}
<snip>
> perl wizard
> perl sorcerer
> perl knight
> perl dragon
> 
> i could go on...this is fun. ideas anyone?
> 
> e.

I've been called "The Prince of Perl"...

but my personal favorite is:

"perl borg" - we have all been assimilated!

thor


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

Date: Fri, 04 Sep 1998 20:55:04 -0700
From: Lisa <nova9@znet.com>
Subject: Perl
Message-Id: <35F0B618.13F9392A@znet.com>

Hi. I saw your name in the news group. Sorry for the unsolicited e mail,
but i didn't
think anyone would respond to my question because of so many messeges in
the
news group. :)  Anyway, i was just wondering, would you know of a simple
script that
will take the input from a form, and write it to a file, so that i can
ftp any time i want
and retrieve the file and it's contents. The file would need to include
file locking, so
i'm not sure if the file would acutally be a database file. Sorry if the
question is kind
of lame, but i'm new to perl if in case you already had not guessed. :)

Thanks, Lisa.



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

Date: Sat, 05 Sep 1998 10:15:49 +0800
From: sekchye <sekchye@singnet.com.sg>
Subject: reading a file backward
Message-Id: <35F09ED4.5A2D4559@singnet.com.sg>

Hi.  I need to read in a huge log file line by line starting from last
line to the first line.  

How do I do this in PERL?  (Not by using `tac` or reading the whole file
into array and then reverse the array)

TIA for any help.


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

Date: Fri, 04 Sep 1998 20:27:52 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Regexp to toggle a part of a string
Message-Id: <alecler-0409982027520001@dialup-571.hip.cam.org>

In article <e3VyFSA29GA.158@upnetnews05>, "Joerg Wagner"
<jwagner@digilog.de> wrote:

> I4m rather new to Perl and working hard on learning to deal efficently with
> regular expressions.
> One thing I cannot figure out (even not when reading the faqs, news,
> camelbook etc - HELP please!):
> 
> I want to change a line of text which looks like  /Status = (ON|OFF)/
> where I want to toggle ON to OFF and vice versa. In other words I want to
> replace ON by OFF and OFF by ON.
> Can I do that in just _one_ regexp???
> 
> Please send my a copy of your answer by private email. Thanx.
> Jvrg Wagner, DigiLog, Saarbr|cken
> jwagner@digilog.de


How about this simple one?

   s/\b(ON)|OFF\b/$1 ? 'OFF' : 'ON'/e;

Andre


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

Date: Fri, 04 Sep 1998 20:41:25 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Regexp to toggle a part of a string
Message-Id: <alecler-0409982041250001@dialup-571.hip.cam.org>

In article <alecler-0409982027520001@dialup-571.hip.cam.org>,
alecler@cam.org (Andre L.) wrote:

> In article <e3VyFSA29GA.158@upnetnews05>, "Joerg Wagner"
> <jwagner@digilog.de> wrote:
> 
> > I4m rather new to Perl and working hard on learning to deal efficently with
> > regular expressions.
> > One thing I cannot figure out (even not when reading the faqs, news,
> > camelbook etc - HELP please!):
> > 
> > I want to change a line of text which looks like  /Status = (ON|OFF)/
> > where I want to toggle ON to OFF and vice versa. In other words I want to
> > replace ON by OFF and OFF by ON.
> > Can I do that in just _one_ regexp???
> > 
> > Please send my a copy of your answer by private email. Thanx.
> > Jvrg Wagner, DigiLog, Saarbr|cken
> > jwagner@digilog.de
> 
> 
> How about this simple one?
> 
>    s/\b(ON)|OFF\b/$1 ? 'OFF' : 'ON'/e;
> 
> Andre

<blush>Correction:</blush>

   s/\b(ON)\b|\bOFF\b/$1 ? 'OFF' : 'ON'/e;

Andre


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

Date: Fri, 4 Sep 1998 19:51:14 -0400
From: "Soft Science" <softsci@eagle.ca>
Subject: sendmail -t
Message-Id: <6spvrg$8d3$1@mur2.odyssey.on.ca>

open (MAIL, "|mailprog -t") || die "can't open $mailprog\n";
blah blah
close(MAIL);

My question is what does the -t do in the first line of the script?
Advanced thank you for your help!





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

Date: 04 Sep 1998 19:23:39 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: sendmail -t
Message-Id: <m3r9xrjo0k.fsf@windlord.Stanford.EDU>

Soft Science <softsci@eagle.ca> writes:

> open (MAIL, "|mailprog -t") || die "can't open $mailprog\n";
> blah blah
> close(MAIL);

> My question is what does the -t do in the first line of the script?
> Advanced thank you for your help!

It tells sendmail to take the recipient addresses for the message from the
headers (To/Cc/Bcc).  Otherwise you'd have to put the addresses on the
command line.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 05 Sep 1998 01:09:54 GMT
From: darrenh@efn.org (Darren Hayes)
Subject: Truncation occurring when passing values as hidden variables
Message-Id: <35f08e6b.92871845@news.efn.org>

Hello again--

After more carefully investigating the CGI script and the resulting 
dynamic HTML source I have found that appending the two arrays 
is not part of the problem (and I found that I don't even need to 
append arrays). Rather the data is truncated at the point of the first
space character when I pass the form data as hidden variables to the
second HTML form (which is generated as dynamic HTML based on the data
entered in the first HTML form).

Is there an issue with delivering data containing spaces to the values
in hidden INPUT TYPES ? Do I need to escape the space characters in
the CGI script before the data is written to the hidden variables in
the dynamic HTML? Is there an easy way to do this?

My "Programming Perl" book doesn't refer to this situation as far as I
can see. I am thinking I should have purchased the "Learning Perl"
book first ;-)

Here is a more thorough description of the issues...

I am passing values from an html form to an array via a perl cgi 
script which is then passing those array values as hidden 
variables to another HTML form.   

That is in HTML FORM1 I have a field "Presenter_Name" (among 
other fields). When the cgi script processes the data submitted 
from this form it dumps the values from the form fields into an array
(*form_data).  Then the script renders a second HTML form (FORM2) and
"forwards the data" from FORM1 (which is stored in *form_data) to
FORM2 using hidden variables. Example:  

<INPUT TYPE  = "hidden" NAME = "Presenter_Name" VALUE = 
$form_data{'Presenter_name'}>  

When I look at the source of FORM2 (via view source in Netscape) 
I see the some of the values associated with hidden INPUT Types 
highlighted in different colors.  The color changes at the point 
where a space character occurs in the value data (all the text 
after the space character appears in black). I think this may be a 
debugging aid (I wish I had heard of it before) which is telling me 
the value info highlighted in black will not be transferred when the
second form is submitted. Examples:

<INPUT TYPE = "hidden" NAME = "Presenter_Name" VALUE = 
Johnny Appleseed>

"Johnny" appears normal (in violet) in the Netscape source and is 
delivered to the script correctly. Whereas "Appleseed" appears in 
black in the Netscape source and is truncated from the data 
delivered to the script.

<INPUT TYPE = "hidden" NAME = "Themes" VALUE = Curriculum 
and Instructional Strategies>

"Curriculum" appears normal (in violet) in the Netscape source and 
is delivered to the script correctly. Whereas "and Instructional 
Strategies" appears in black in the Netscape source and is 
truncated from the data delivered to the script.

As noted above the data is truncated where the first space 
character occurs in the value.

Hope I am making this all clear. Thanks for any suggestions.  

Darren





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

Date: Fri, 4 Sep 1998 18:21:37 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Truncation occurring when passing values as hidden variables
Message-Id: <MPG.105a31f7fce3d0ae989829@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <35f08e6b.92871845@news.efn.org> on Sat, 05 Sep 1998 01:09:54 
GMT, Darren Hayes <darrenh@efn.org> says...
 ... 
> <INPUT TYPE = "hidden" NAME = "Themes" VALUE = Curriculum 
> and Instructional Strategies>
 ... 
> As noted above the data is truncated where the first space 
> character occurs in the value.

See those quotes aound the one-word values, where they are not needed?  
Put them also around the multi-word values, where they *are* needed.

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


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

Date: Sat, 05 Sep 1998 02:38:09 GMT
From: darrenh@efn.org (Darren Hayes)
Subject: Re: Truncation occurring when passing values as hidden variables
Message-Id: <35f4a3f6.98387725@news.efn.org>

>[Posted to comp.lang.perl.misc and copy mailed.]
>
>In article <35f08e6b.92871845@news.efn.org> on Sat, 05 Sep 1998 01:09:54
>GMT, Darren Hayes <darrenh@efn.org> says... ... > <INPUT TYPE = "hidden"
>NAME = "Themes" VALUE = Curriculum > and Instructional Strategies> ... >
>As noted above the data is truncated where the first space > character
>occurs in the value.
>
>See those quotes aound the one-word values, where they are not needed? 
>Put them also around the multi-word values, where they *are* needed.
>
>-- 
>(Just Another Larry) Rosler
>Hewlett-Packard Laboratories
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com


Larry-

I cease to amaze myself. I keep on looking at the forest without
looking at the trees. Yes the quotes were it! Thanks for the quick
response! 

Darren


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

Date: Sat, 05 Sep 1998 00:38:25 GMT
From: Garry Williams <garry@america.net>
Subject: Re: Use Perl to sendmail: open once, send multiple times?
Message-Id: <35F08846.34084FAD@america.net>

Kevin hawkins wrote:
> 
[snip]
> Even if you telnet directly to the mail server and use SMTP commands,
> you can only send one email per session.

Not true: 

	$ telnet localhost smtp
	Trying 127.0.0.1...
	Connected to localhost.
	Escape character is '^]'.
	220 atl1.america.net ESMTP Sendmail 8.8.7/8.8.7; Fri, 4 Sep 1998 	
20:33:45 -0400 (EDT)
	helo gtw
	250 atl1.america.net Hello localhost [127.0.0.1], pleased to 		meet you
	mail from:<garry@america.net>
	250 <garry@america.net>... Sender ok
	rcpt to: <garry@america.net>
	250 <garry@america.net>... Recipient ok
	data
	354 Enter mail, end with "." on a line by itself
	Subject: First Message

	First Message
	.
	250 UAA18525 Message accepted for delivery
	mail from:<garry@america.net>
	250 <garry@america.net>... Sender ok
	rcpt to: <garry@america.net>
	250 <garry@america.net>... Recipient ok
	data
	354 Enter mail, end with "." on a line by itself
	Subject: Second Message

	Second Message
	.
	250 UAA18865 Message accepted for delivery
	quit
	221 atl1.america.net closing connection
	  Connection closed by foreign host.
	$ pine
	...
	  N  20 Sep  4 Garry T. Williams            (386) First Message
  	  N  21 Sep  4 Garry T. Williams            (388) Second Message

-Garry Williams


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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