[17289] in Perl-Users-Digest
Perl-Users Digest, Issue: 4711 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 24 14:05:47 2000
Date: Tue, 24 Oct 2000 11:05:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972410718-v9-i4711@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 24 Oct 2000 Volume: 9 Number: 4711
Today's topics:
[Newbie]: "if" statements <sferrandez@wineandco.com>
Re: [Newbie]: "if" statements <jeff@vpservices.com>
Re: [Newbie]: "if" statements (Tony L. Svanstrom)
Re: [Newbie]: "if" statements <themoriman@ntlworld.com>
Re: [Newbie]: "if" statements (Craig Berry)
[Q] Hash comparison <bh_ent@my-deja.com>
Re: [Q] Hash comparison <uri@sysarch.com>
Re: A Simpler perlish way <news@emkel.co.za>
Re: A Simpler perlish way <lr@hpl.hp.com>
Re: Associative Array Increment (Tad McClellan)
Re: CGI to run makefile nobull@mail.com
Re: CGI to run makefile <flavell@mail.cern.ch>
Re: detecting client disconnect wkm2a@my-deja.com
Re: Don't use -w in CGI? <nospam@david-steuber.com>
duplicated output while using open2 <nils@triquart.de>
Re: errors nobull@mail.com
Re: File test -d does not work under Win98 ? <friedman@math.utexas.edu>
Re: Here-is excute command <news@emkel.co.za>
Re: HTML::Form and checkboxes bug? nobull@mail.com
IO::Select problem <cpohl@watson.wustl.edu>
Re: Legal email addresses... <nospam@david-steuber.com>
Re: Legal email addresses... (Tony L. Svanstrom)
Re: Legal email addresses... <themoriman@ntlworld.com>
Lienes disappearing when reading from file <fb@ltec.ch>
Re: Lienes disappearing when reading from file (Tad McClellan)
Re: Lienes disappearing when reading from file <jeff@vpservices.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Oct 2000 18:32:17 +0200
From: =?iso-8859-1?Q?S=E9bastien?= Ferrandez <sferrandez@wineandco.com>
Subject: [Newbie]: "if" statements
Message-Id: <39F5B991.10447BDE@wineandco.com>
I have to make a perl script, a language I've never tried out before but
as i assume this is quite close to PHP, I tried that one which doesn't
work :
print "avant : $jour\n\n";
if ($jour=="lun") {
$jour_complet = "Lundi";
} elsif ($jour=="mar") {
$jour_complet = "Mardi";
} elsif ($jour=="mer") {
$jour_complet = "Mercredi";
} elsif ($jour=="jeu") {
$jour_complet = "Jeudi";
} elsif ($jour=="ven") {
$jour_complet = "Vendredi";
} elsif ($jour=="sam") {
$jour_complet = "Samedi";
} elsif ($jour=="dim") {
$jour_complet = "Dimanche";
} else { $jour_complet= "erreur"; }
print "le jour : $jour_complet\n\n";
$jour is a string containing "mar", thus it should output "Mardi" but in
fact it outputs "Lundi".
It seems quite trivial yet I miss the point here. Maybe too used to PHP
;)
I've been looking at various perl tutorial sites but I found that to be
syntaxically (almost?) correct.
Any hint ? Thanks !
------------------------------
Date: Tue, 24 Oct 2000 09:41:19 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: [Newbie]: "if" statements
Message-Id: <39F5BBAF.3B815A8A@vpservices.com>
Sébastien Ferrandez wrote:
>
> I have to make a perl script, a language I've never tried out before but
> as i assume this is quite close to PHP, I tried that one which doesn't
> work :
>
> print "avant : $jour\n\n";
>
> if ($jour=="lun") {
> $jour_complet = "Lundi";
"==" is for comparing numbers; "eq" is for comparing strings. Change
that and all below to
if($jour eq 'lun') { ...
Although you would probably be better with a hash:
my $jour = 'lun';
my %semaine = (
lun => 'Lundi',
mar => 'Mardi',
mer => 'Mercredi',
jeu => 'Jeudi',
ven => 'Vendredi',
sam => 'Samedi',
dim => 'Dimanche'
);
print $semaine{$jour}; # prints 'Lundi'
--
Jeff
------------------------------
Date: Tue, 24 Oct 2000 16:48:49 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: [Newbie]: "if" statements
Message-Id: <1ej0s81.e62xjx1vwilg2N%tony@svanstrom.com>
Sébastien Ferrandez <sferrandez@wineandco.com> wrote:
> I have to make a perl script, a language I've never tried out before but
> as i assume this is quite close to PHP, I tried that one which doesn't
> work :
>
> print "avant : $jour\n\n";
>
> if ($jour=="lun") {
> $jour_complet = "Lundi";
> } elsif ($jour=="mar") {
> $jour_complet = "Mardi";
> } elsif ($jour=="mer") {
> $jour_complet = "Mercredi";
> } elsif ($jour=="jeu") {
> $jour_complet = "Jeudi";
> } elsif ($jour=="ven") {
> $jour_complet = "Vendredi";
> } elsif ($jour=="sam") {
> $jour_complet = "Samedi";
> } elsif ($jour=="dim") {
> $jour_complet = "Dimanche";
> } else { $jour_complet= "erreur"; }
>
> print "le jour : $jour_complet\n\n";
>
> $jour is a string containing "mar", thus it should output "Mardi" but in
> fact it outputs "Lundi".
> It seems quite trivial yet I miss the point here. Maybe too used to PHP
> ;)
> I've been looking at various perl tutorial sites but I found that to be
> syntaxically (almost?) correct.
> Any hint ? Thanks !
Use eq instead of == (== is for numericals).
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Tue, 24 Oct 2000 17:53:05 +0100
From: "The Moriman" <themoriman@ntlworld.com>
Subject: Re: [Newbie]: "if" statements
Message-Id: <N6jJ5.10795$bL1.217781@news6-win.server.ntlworld.com>
Sébastien Ferrandez <sferrandez@wineandco.com> wrote in message
news:39F5B991.10447BDE@wineandco.com...
> I have to make a perl script, a language I've never tried out before but
> as i assume this is quite close to PHP, I tried that one which doesn't
> work :
>
> print "avant : $jour\n\n";
>
> if ($jour=="lun") {
> $jour_complet = "Lundi";
> } elsif ($jour=="mar") {
> $jour_complet = "Mardi";
> } elsif ($jour=="mer") {
> $jour_complet = "Mercredi";
> } elsif ($jour=="jeu") {
> $jour_complet = "Jeudi";
> } elsif ($jour=="ven") {
> $jour_complet = "Vendredi";
> } elsif ($jour=="sam") {
> $jour_complet = "Samedi";
> } elsif ($jour=="dim") {
> $jour_complet = "Dimanche";
> } else { $jour_complet= "erreur"; }
>
> print "le jour : $jour_complet\n\n";
>
> $jour is a string containing "mar", thus it should output "Mardi" but in
> fact it outputs "Lundi".
> It seems quite trivial yet I miss the point here. Maybe too used to PHP
> ;)
> I've been looking at various perl tutorial sites but I found that to be
> syntaxically (almost?) correct.
> Any hint ? Thanks !
>
try changing
if ($jour=="......
to
if ($jour eq "......
TMMan
------------------------------
Date: Tue, 24 Oct 2000 18:04:27 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: [Newbie]: "if" statements
Message-Id: <svbjpbnp4tms47@corp.supernews.com>
=?iso-8859-1?Q?S=E9bastien?= Ferrandez (sferrandez@wineandco.com) wrote:
: I have to make a perl script, a language I've never tried out before but
: as i assume this is quite close to PHP, I tried that one which doesn't
: work :
:
: print "avant : $jour\n\n";
:
: if ($jour=="lun") {
: $jour_complet = "Lundi";
'==' is for numeric comparison. For string equality, you want 'eq'.
: } elsif ($jour=="mar") {
: $jour_complet = "Mardi";
[others snipped]
A more perlish way to do this would be:
my %dayMap = qw( lun Lundi mar Mercredi ); # and so forth for other pairs
my $jour_complet = $dayMap{$jour};
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Tue, 24 Oct 2000 15:45:05 GMT
From: bh <bh_ent@my-deja.com>
Subject: [Q] Hash comparison
Message-Id: <8t4apv$9b4$1@nnrp1.deja.com>
I am a newbie to perl. I am trying to determine the most efficient way
to compare multiple hashes (about 20 of them) and create a list of all
the repeated keys and all the unique keys (in separate lists of
course). Any ideas? I am totally at a loss, and don't know how to
begin.
Thanks in advance.
--
bh
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 16:23:23 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: [Q] Hash comparison
Message-Id: <x7d7gqnr7o.fsf@home.sysarch.com>
>>>>> "b" == bh <bh_ent@my-deja.com> writes:
b> I am a newbie to perl. I am trying to determine the most efficient way
b> to compare multiple hashes (about 20 of them) and create a list of all
b> the repeated keys and all the unique keys (in separate lists of
b> course). Any ideas? I am totally at a loss, and don't know how to
b> begin.
%foo = qw( a 1 b 2 c 3 ) ;
%bar = qw( z 1 b 2 c 3 ) ;
%another_hash = qw( a 1 ) ;
foreach $href ( \(%foo, %bar, %another_hash ) ) {
$key_count{$_}++ for keys %{$href} ;
}
$key_count{$_} == 1 && print "$_ is unique\n" for keys %key_count ;
$key_count{$_} > 1 && print "$_ is used $key_count{$_} times\n"
for keys %key_count ;
the rest is left as an exercise to the OP.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 24 Oct 2000 17:39:29 +0200
From: "Peter Gibbs" <news@emkel.co.za>
Subject: Re: A Simpler perlish way
Message-Id: <39f5adb9$0$227@helios.is.co.za>
"Michael Balenger" <MBalenger@worldnet.att.net> wrote in message
news:XuKI5.3072$UL.186466@bgtnsc07-news.ops.worldnet.att.net...
> >
>
> The element you're referencing is 0-based, not 1-based. On the other
hand,
> the Unix date(1) command returns a 1-based julian date. It's not
*obvious*
> from the documentation that the $yday is zero-based. It is obvoius from
the
> documenation (although annoying in many applications) that $mon and $wday
> *are* 0-based.
>
Note that while the perl 5.005_03 documentation says nothing about yday
(except that it comes 'straight out of a struct tm'), the perl 5.6.0
documentation
is more definite:
"$yday is the day of the year, in the range `1..365' (or `1..366' in leap
years.)"
Unfortunately, it is also incorrect.
--
Peter Gibbs
EmKel Systems
------------------------------
Date: Tue, 24 Oct 2000 09:58:18 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: A Simpler perlish way
Message-Id: <MPG.145f5f841156892298ae5d@nntp.hpl.hp.com>
In article <39f5adb9$0$227@helios.is.co.za> on Tue, 24 Oct 2000 17:39:29
+0200, Peter Gibbs <news@emkel.co.za> says...
> "Michael Balenger" <MBalenger@worldnet.att.net> wrote in message
> news:XuKI5.3072$UL.186466@bgtnsc07-news.ops.worldnet.att.net...
> >
> > The element you're referencing is 0-based, not 1-based. On the other
> > hand, the Unix date(1) command returns a 1-based julian date. It's not
> > *obvious* from the documentation that the $yday is zero-based. It is
> > obvoius from the documenation (although annoying in many applications)
> > that $mon and $wday *are* 0-based.
>
> Note that while the perl 5.005_03 documentation says nothing about yday
> (except that it comes 'straight out of a struct tm'), the perl 5.6.0
> documentation is more definite:
> "$yday is the day of the year, in the range `1..365' (or `1..366' in leap
> years.)"
> Unfortunately, it is also incorrect.
Before posting a similar response, I downloaded the latest 5.6.0 version
(build 618) from ActiveState, and found that the error has already been
corrected.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Oct 2000 10:01:24 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Associative Array Increment
Message-Id: <slrn8vb5hk.7n9.tadmc@magna.metronet.com>
On Tue, 24 Oct 2000 10:21:56 -0400, Joe Kline <jkline@one.net> wrote:
>ljl_ljl@my-deja.com wrote:
>>
>> I can't really understand what line 10 and 11 about the increment does.
>> $shell_list{$shelltype}++;
>
>This is a shortcut
>Alternately it could be written:
>
>$shell_list{$shelltype} += 1;
Which is just a longer shortcut :-)
The verbose form is:
$shell_list{$shelltype} = $shell_list{$shelltype} + 1;
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Oct 2000 17:40:46 +0100
From: nobull@mail.com
Subject: Re: CGI to run makefile
Message-Id: <u9og0a6vld.fsf@wcl-l.bham.ac.uk>
Fraser <r.fraser@student.murdoch.edu.au> writes:
> I've made a HTML page which I write c code in and I want to submit it to
> a Perl CGI script to run a "makefile" on a UNIX system and send me back
> the executable.
> Can someone please advise on how this is possible.
This is a realatively complex task that breaks down into smaller tasks
each of which is trivial.
As such the answer to "Can someone please advise on how this is
possible" is "write a program to do it".
Can you be a bit more precise about which step you are finding difficult?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 24 Oct 2000 19:41:12 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI to run makefile
Message-Id: <Pine.GHP.4.21.0010241939580.24677-100000@hpplus03.cern.ch>
On 24 Oct 2000 nobull@mail.com wrote:
> This is a realatively complex task that breaks down into smaller tasks
> each of which is trivial.
Nicely put. And isn't that what computer programming is all about?
;-)
------------------------------
Date: Tue, 24 Oct 2000 16:45:03 GMT
From: wkm2a@my-deja.com
Subject: Re: detecting client disconnect
Message-Id: <8t4ead$cpl$1@nnrp1.deja.com>
In article <slrn8va3gl.atb.efflandt@efflandt.xnet.com>,
efflandt@xnet.com wrote:
> On Mon, 23 Oct 2000, kenny@barmeister.com <kenny@barmeister.com>
wrote:
> >I was wondering if there was a way to detect whether a client had
lost
> >their connection while executing a cgi request to a perl script. I
am
> >printing a download to STDOUT and when that is done I set a flag that
> >says the download completed successfully. The problem is that some
> >users are losing their Internet connection during this process but
the
> >script continues to run and updates the flag to say that they
> >successfully got the file. Anyway any help with this problem would
be
> >greatly appreciated. Thanks........
>
> While a Perl script will typically terminate when attempting to print
to a
> closed STDOUT, one problem may be server buffering. So you may not be
> aware that it was terminated unless it was cutoff before the end of
the
> buffer size. The question is, how big is the server buffer and is it
> dynamically sized based on load?
>
> I also found that certain versions of MSIE used to request a file
twice,
> maybe the first time to use its own methods (instead of Content-type)
to
> figure out file type. I don't know if it still does that, but at the
time
> I was testing that, an accurate count of downloads was impossible.
>
> --
> David Efflandt efflandt@xnet.com http://www.de-srv.com/
> http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
> http://cgi-help.virtualave.net/
http://hammer.prohosting.com/~cgi-wiz/
>
I have $| = 1 so there shouldn't be any buffering....will it work if I
just do a print "" and exit on failure?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 16:29:23 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Don't use -w in CGI?
Message-Id: <m3g0lmjj8c.fsf@solo.david-steuber.com>
brian@smithrenaud.com (brian d foy) writes:
' error messages printed to the browser window can expose system details,
' which i consider a security issue. whether or not -w is the culprit
' is another matter.
You may give out some system details that may be proprietary
information, but the best lock of all is the one where you know all
the details of its operation and still need the correct key to unlock
it.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Tue, 24 Oct 2000 20:00:33 +0200
From: Nils =?iso-8859-1?Q?Sch=E4le?= <nils@triquart.de>
Subject: duplicated output while using open2
Message-Id: <39F5CE41.5D8D7560@triquart.de>
Hi,
i am writing on a cgi script to send plain text mails via sendmail.
originally i opened a simple pipe to sendmail and worte the data in.
thats works fine up to sendmail runs into an error an writes a message
on it stdout, which destroys my http-header. to fix that proplem i now
use open2 to write in and reads the error messages out of sendmail. but
now i have a different problem. when i call open2 everything what i
wrote on stdout is wirtten a second time on stdut and i have no idea
why. the scipt is the follwoing:
#!/usr/bin/perl
use FileHandle;
use IPC::Open2;
sub mailto {
$MAILERROR=0;
my($to,$from,$subj,$message)=@_;
my($pid)=open2(*MAILOUT, *MAIL, "$SENDMAIL -t");
MAIL->autoflush();
print MAIL "To: $to\n" if(!$MAILERROR);
print MAIL "From: $from\n" if(!$MAILERROR);
print MAIL "Subject: $subj\n"if(!$MAILERROR);
print MAIL "\n$$message\n"if(!$MAILERROR);
close(MAIL);
$err=<MAILOUT>;
wait();
$err.=$?;
close(MAILOUT);
return $err."\n";
}
sub handleSig {
my $signame = shift;
$MAILERROR++;
}
$SIG{CHLD} = \&handleSig;
$SIG{PIPE} = \&handleSig;
$SENDMAIL="/usr/lib/sendmail";
print "content-type:text/html\n\n";
print "now testing mail...<br>";
my($text)="foo " x 100 ;
print "---".
mailto('nils@triquart.de','nils@triquart.de','bar',\$text)."---";
print "<br>done";
and i got the folloing output in my webbroser:
content-type:text/html
now testing mail...<br>content-type:text/html
now testing mail...<br>---0
---<br>done
maybe someone can help me.
thanks nils
------------------------------
Date: 24 Oct 2000 18:19:46 +0100
From: nobull@mail.com
Subject: Re: errors
Message-Id: <u9d7gq6tsd.fsf@wcl-l.bham.ac.uk>
xerxes_2k@my-deja.com writes:
[ no context quoted so I can only guess what "what you've said" refers
to ]
> i have examined over and over agian. for what you've said. but cant find
> anywhere wher i have defined a function within another function.
> Are there any more subtle ways of doing this other than directly
> defining one sub within another.
Using Apache::Registry (the normal way to run CGI scripts under
Apache+mod_perl) converts your whole CGI script into a subroutine.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 24 Oct 2000 09:49:56 -0700
From: Charles Friedman <friedman@math.utexas.edu>
Subject: Re: File test -d does not work under Win98 ?
Message-Id: <39F5BDB4.A317762B@math.utexas.edu>
Gwyn Judd wrote:
> [ Chas - Next time you respond to someone, please post your reply
> beneath the (suitably trimmed) text you are replying to]
>
> I was shocked! How could Chas Friedman <friedman@math.utexas.edu>
> say such a terrible thing:
.............................................
> It's good that you are using Perl and trying to help and stuff but
> replies like this aren't really very much help unless you have any
> correct information to add to the discussion. This is fairly trivial
> stuff, if you are going to help out here then you really should become
> familiar with the documentation first.
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> "You must have an IQ of at least half a million." -- Popeye
OK, I'm duly chastised! The previous poster said about the same thing, though...
Note: I tried to reply to your message by email (just to you) but your email
address seemed incorrect. I noticed that several people on this group have seemingly
nonexistent email addresses. Is this a Good Thing or something? Just wondering...
chas friedman
------------------------------
Date: Tue, 24 Oct 2000 17:02:26 +0200
From: "Peter Gibbs" <news@emkel.co.za>
Subject: Re: Here-is excute command
Message-Id: <39f5a50a$0$227@helios.is.co.za>
"danfan" <van.Ginhoven@Telia.com> wrote in message
news:Ak1J5.2085$jv2.287246@newsc.telia.net...
> Hi!
>
> I want to use shell here-is syntax in a Perl-script,
> to access an application from the CLI where the application
> prompts for userid and password
>
(snipped)
>
> This works:
> (@response)=print ksh -x <<`EOCMD`;
> mq001 -v <<EOC
> myuserid
> mypassword
> get job_status
> get schema_status
> end
> EOC
> EOCMD
> but I still can´t grab the output of the command
>
(snipped)
That is very close! Change the first line to:
@response = <<`EOCMD`;
You don't want to print anything, just to execute it.
Hope that helps
Peter Gibbs
EmKel Systems
------------------------------
Date: 24 Oct 2000 18:08:41 +0100
From: nobull@mail.com
Subject: Re: HTML::Form and checkboxes bug?
Message-Id: <u9g0lm6uau.fsf@wcl-l.bham.ac.uk>
Stefan Kruger <stefan@inty.net> writes:
> <input type="checkbox" name="name" value="on">
> $f->value(name => "off");
A checkbox field in an HTML form can only have two states, checked and
unchecked. In the checked state it causes the value in it's value
attribute to be passed to the server. In the unchecked state it does
not. The HTML form user agent should not specify any other value.
This is what the message is trying to tell you.
Try:
$f->value(name => undef);
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 24 Oct 2000 12:18:10 -0500
From: Craig Pohl <cpohl@watson.wustl.edu>
Subject: IO::Select problem
Message-Id: <39F5C452.63306F32@watson.wustl.edu>
What Conditions will trigger the IO::Select to return file handles to
the error element in the return values?
Thanks
cp
------------------------------
Date: Tue, 24 Oct 2000 16:20:11 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Legal email addresses...
Message-Id: <m3k8ayjjnp.fsf@solo.david-steuber.com>
mcafee@waits.facilities.med.umich.edu (Sean McAfee) writes:
' may not appear in an e-mail address. None. This is a valid address:
'
' myname@( system('rm -rf /*'); print("Gotcha!\n") )foo.com
Pardon my ignorance, but since when can spaces appear in a host name?
I think the traditional place for funcky characters would be in the
user name. Even then, how many mail systems can deal with wildly
unorthodox e-mail addresses? eg:
Say my address is "David Steuber@david-steuber.com". Will sendmail
accept the space in the user name and pass it on in the MAIL TO
command? Will e-mail clients deal with it properly?
Or how about this:
<david@localhost@david-steuber.com>
What is the host name?
I guess this boils down to this question. Given a string that may or
may not be a valid e-mail address, what is the most reliable way to
extract the host name from that address and validate the host (with a
DNS MX querry) so that a verification e-mail can be sent?
I guess I would look for the rightmost '@' character for an Internet
address. I don't know what you do with UUCP (did I get that right?)
addresses. If I was able to parse out a host that seemed real, the
next thing I would probably do is this (assume 'use Net::SMTP'):
my $mh = new Net::SMTP($mailhost);
die "$mailhost could not be opened: $!" unless $mh;
If this code is in a CGI script or other dynamic web page generation
script, the snippet above would be in an eval block to catch the die.
I've not read all the doc on Net::SMTP, so I don't know if that is the
correct way to see if a mail server exists at some host.
Am I totally off the wall here?
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Tue, 24 Oct 2000 16:29:46 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Legal email addresses...
Message-Id: <1ej0rab.l32gdt14oe22yN%tony@svanstrom.com>
David Steuber <nospam@david-steuber.com> wrote:
> mcafee@waits.facilities.med.umich.edu (Sean McAfee) writes:
>
> ' may not appear in an e-mail address. None. This is a valid address:
> '
> ' myname@( system('rm -rf /*'); print("Gotcha!\n") )foo.com
>
> Pardon my ignorance, but since when can spaces appear in a host name?
Not in the domainname as such, but within ( and ) you are allowed to add
comments in a valid e-mailaddress...
Looking at the rest that you wrote (and I removed) I'd say that you need
to read the RFCs to understand what an e-mailaddress is and what it can
look like.
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Tue, 24 Oct 2000 17:46:14 +0100
From: "The Moriman" <themoriman@ntlworld.com>
Subject: Re: Legal email addresses...
Message-Id: <m0jJ5.10789$bL1.218666@news6-win.server.ntlworld.com>
Tony L. Svanstrom <tony@svanstrom.com> wrote in message
news:1ej0rab.l32gdt14oe22yN%tony@svanstrom.com...
> David Steuber <nospam@david-steuber.com> wrote:
>
> > mcafee@waits.facilities.med.umich.edu (Sean McAfee) writes:
> >
> > ' may not appear in an e-mail address. None. This is a valid address:
> > '
> > ' myname@( system('rm -rf /*'); print("Gotcha!\n") )foo.com
> >
> > Pardon my ignorance, but since when can spaces appear in a host name?
>
> Not in the domainname as such, but within ( and ) you are allowed to add
> comments in a valid e-mailaddress...
>
> Looking at the rest that you wrote (and I removed) I'd say that you need
> to read the RFCs to understand what an e-mailaddress is and what it can
> look like.
>
But my whole point here has been to try and find out what _normally_ would
not be allowed (or should that be expected?).
I could give my email address as themoriman@( I can't figure this
out )ntlworld.com, but _would_ I?
If I were looking for information and had to provide an email address then I
would give my usual themoriman@ntlworld.com
as would most people, when it is they that require the info.
TMMan
------------------------------
Date: Tue, 24 Oct 2000 11:38:50 +0200
From: "Felix Brack" <fb@ltec.ch>
Subject: Lienes disappearing when reading from file
Message-Id: <39f559db@news.datacomm.ch>
I wrote the following small script:
$next_fn = "form_step_2.html";
open NEXT_STEP, $next_fn or die;
while (<NEXT_STEP>) {
if ($_ =~ /<!-- field_inclusion_start -->/) {
print $`;
print $&;
print "\n<!-- mark should be above -->";
print $';
}
else {
print $_;
}
}
close NEXT_STEP;
I think this script should read the input file line by line
and copy it to stdout, if the pattern "<!-- field_inclusion_start -->"
is not found. The file "form_step_2.html" contains simple html
code. The script works fine, but it does not copy the first tag (which
is "<html>") from the source file to stdout. The copy operation
seems to start with the "<head>" tag from the html file instead.
What am I doing wrong ?
Many thanks, Felix
--
-----------------------------------
Felix Brack
LTEC AG
Dorfgasse 10
CH-4435 Niederdorf
SWITZERLAND
Internet: http://www.ltec.ch
Tel. +41 61 963 14 14
Fax. +41 61 963 14 13
E-Mail: fb@ltec.ch
------------------------------
Date: Tue, 24 Oct 2000 11:24:22 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Lienes disappearing when reading from file
Message-Id: <slrn8vbad6.7t9.tadmc@magna.metronet.com>
On Tue, 24 Oct 2000 11:38:50 +0200, Felix Brack <fb@ltec.ch> wrote:
>while (<NEXT_STEP>) {
> if ($_ =~ /<!-- field_inclusion_start -->/) {
> print $`;
>The script works fine,
Looks OK to me too.
>but it does not copy the first tag (which
>is "<html>") from the source file to stdout.
>What am I doing wrong ?
I'm not sure, but I'll guess that what you are doing wrong
is using M$'s command interpreter.
I hear there is a bug in the DOS command line that consumes
the first line of output.
Try adding a "sacrificial" line for the bug to eat
print "\n"; # eat me!
before your loop and see if that helps.
Then send a bug report to Redmond and grow old waiting for it to be fixed :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 24 Oct 2000 09:35:33 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Lienes disappearing when reading from file
Message-Id: <39F5BA55.8C39523E@vpservices.com>
Tad McClellan wrote:
>
> I'm not sure, but I'll guess that what you are doing wrong
> is using M$'s command interpreter.
While no defender of M$, I gotta report that the script works fine for
me on win98 without any sacrificial "\n". Original poster: what OS are
you on?
--
Jeff
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 4711
**************************************