[9607] in Perl-Users-Digest
Perl-Users Digest, Issue: 3201 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 20 03:07:18 1998
Date: Mon, 20 Jul 98 00:00:32 -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 Mon, 20 Jul 1998 Volume: 8 Number: 3201
Today's topics:
Re: /^[a-z0-9]/ (Ronald J Kimball)
get a key strike in perl... (GEMINI)
Re: How can you encrypt a CGI script on a server so it <tbsmith@viper.net>
Re: How do I clear an array? (Ronald J Kimball)
Re: if ($line =~ /$in{'word'}/i) <jwb79@mail.idt.net>
Re: join and warnings on undef values (Ronald J Kimball)
Re: matching problem merzky@physik.hu-berlin.de
novice Q; reading columns of numbers isifuelo@my-dejanews.com
Re: novice Q; reading columns of numbers (Ronald J Kimball)
Re: open (IN, "foo.txt") works, open (IN, "$foo") does (J|rgen P|nter)
Re: open (IN, "foo.txt") works, open (IN, "$foo") does (J|rgen P|nter)
Re: Perl Beautifier Home Page <rra@stanford.edu>
Re: Perl Beautifier Home Page <zenin@bawdycaste.org>
Re: Perl CGI's under Windows NT kanak@pobox.com
Perl script to POP3 <raymond_wmip@hotmail.com>
Re: Reading in an email message into a Perl program (Ronald J Kimball)
Re: sub's and rsh rlogin (Martien Verbruggen)
The Perl Job Board (Jon Orwant)
Re: Web Components (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 20 Jul 1998 00:35:00 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: /^[a-z0-9]/
Message-Id: <1dcfu6g.11mnch81v5ohz4N@bay2-86.quincy.ziplink.net>
Abigail <abigail@fnx.com> wrote:
> Yes. And
>
> print join "\n", grep /^[^a-z0-9]/, qw /a::: b;;; s[][]/
>
> prints
>
> a:::
> b;;;
> s[][]
>
Um... No it doesn't.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 20 Jul 1998 05:16:06 GMT
From: dennis@info4.csie.nctu.edu.tw (GEMINI)
Subject: get a key strike in perl...
Message-Id: <6oujqm$s2p$1@netnews.csie.NCTU.edu.tw>
hi there,
in my program I need to let user key in a password.
I'd like to get every key he strikes and display a '*'
instead of echoing the key directly. under unix,
we can use system 'stty ....' to do that. however,
my program will be used under win32 environment.
then what should I do?
thanks.
------------------------------
Date: Mon, 20 Jul 1998 01:31:53 -0500
From: Todd Smith <tbsmith@viper.net>
To: jpl@t-f.com
Subject: Re: How can you encrypt a CGI script on a server so it will not get "stolen"?
Message-Id: <35B2E458.70E05E4B@viper.net>
put your script on a secure server and just change the link that goes to it,
have it run normally, you'll have to change the code for doing whatever
output it does slightly, and then they'll have no way of getting to it.
John Layne wrote:
> Hi there,
>
> I have spent many, many hours writing a CGI script that creates a
> client's web site from a text file on the server. I am worried because
> there is nothing to prevent this client from copying the plain-text
> script, firing me as their web developer, and getting someone else to
> use the script. I have made it clear that the scripts belong to me and
> they pay to use them. But...
>
> What would be the best way to protect my assets? I guess I could encrypt
> the script on the server and have another password-protected script that
> would decode it and then run it. Any ideas would be gratefully accepted.
> I would imagine that this is an issue others have faced.
>
> Thanks!
>
> John Layne
> jpl@t-f.com
--
---------------
Todd Smith
Web Programmer
ITC^DeltaCom
tbsmith@viper.net
%|
------------------------------
Date: Mon, 20 Jul 1998 00:35:01 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: How do I clear an array?
Message-Id: <1dcfue1.fyx7samvb1n4N@bay2-86.quincy.ziplink.net>
- <root.noharvest.\@not_even\here.com> wrote:
> Also, consider that, if you need this feature, undef() is nice enough
> to return the value that you just undefine (at least, I think it
> does... this statement is somewhat ambiguous - "the undefined value is
> returned" - it could mean the value that signifies "undefined" is
> returned (0), or it could mean the value that was cleared is returned)
You could try it to see what it returns. Your reading of the
documentation turns out to be the incorrect one. I never thought of it
as ambiguous before, but I do sorta see what you mean.
Anyway, to clear up the confusion, undef() always returns the value that
signifies "undefined". (Which, by the way, is not 0.)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 20 Jul 1998 02:55:30 GMT
From: "jim babbington" <jwb79@mail.idt.net>
Subject: Re: if ($line =~ /$in{'word'}/i)
Message-Id: <01bdb388$cd6897f0$6488fdc7@dixon>
Nathalie M. <elssa09@nospam.callisto.si.usherb.ca> wrote in article
<35B19CC3.4D31@nospam.callisto.si.usherb.ca>...
: I know there's an error somewhere in this line:
<....>
:
: -----------------------------------------------------------------
: open(HTMLFILE,"<$corpus");
: @inputData=<HTMLFILE>;
: close(HTMLFILE);
:
: $word = $in{'word'};
:
: foreach $line (@inputData) {
:
: if ($line =~ /$in{'word'}/i)
: {
: print "success $line<BR>\n";
: }
: else
: {
: print "Not in this line.<BR>\n";
: }
: }
Nathalie,
When I run in to these types of problems, what I will do (to regain my
sanity), is put _print_ statments in my program that will let me know what
variables contain what data. In your example, I would print
"word=$in{'word'} \n"; right before your _if_ statement. This way you can
visualize the data as it's being tested. You may also wand to print the
contents of $line, if the first suggestion doesent lead you to the bug.
I hope this helps,
Jim
PS: Dont forget to remove or pound out your debuging diplays after you have
it fixed.
------------------------------
Date: Mon, 20 Jul 1998 00:35:03 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: join and warnings on undef values
Message-Id: <1dcfuol.1adxrmz1k2txbN@bay2-86.quincy.ziplink.net>
Uri Guttman <uri@sysarch.com> wrote:
> i am using dbi/dbd and fetching rows of records, some of which have null
> fields. these are converted to undef by dbi/dbd. i then join them for
> printing to a file. if i have warnings enabled (which i do as a standard
> matter, tom c) i of course get warnings with the join of undef values. i
> currently disable warnings around that join with $^W=0. i don't want to
> do a
>
> @row = map { defined( $_ ) ? $_ : '' ) @row ;
Why not? That's probably how I'd do it. :-)
> is there any better way to do this? i think join shouldn't trigger
> warnings on undef. maybe there are cases where that is useful but not
> with rdbms's. this is another reason for lexical warnings or warning
> levels so i can disable join warnings in the sub but leave other
> warnings active.
Assuming that $foo is undefined, then join('', 'abc', $foo, 'def') is
pretty much equivalent to "abc${foo}def", and I would expect both of
them to give a 'Use of unitialized value' warning - that's what the
warning is for, after all.
Perhaps it's a bug in dbi/dbd that it returns undef instead of the null
string for null fields...
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 20 Jul 1998 04:48:21 GMT
From: merzky@physik.hu-berlin.de
Subject: Re: matching problem
Message-Id: <6oui6l$6eo$1@nnrp1.dejanews.com>
In article <Pine.LNX.3.96.980717092341.238A-100000@mp220.iis>,
Simon Dueckert <dueckert@iis.fhg.de> wrote:
> Hi All,
>
> I have a problem. In my download directory I wrote a file with the
> following content:
> filename description web-address
> example:
> test.txt Text to Test http://www.microsoftsucks.com
>
> Now I want to split it in 3 variables. I did the following (I'm new to
> perl ;^)
>
> script:
>
> #!/usr/bin/perl
>
> open INFO,"test.txt"
> while ($line=<INFO>)
> {
> print $line; --> this works fine
> ($file,$desc,$url) = (/^(\s)()(\s)$/);
($file,$desc,$url) = ($line =~ /^\s*(\S+)\s*(.+?)\s*(\S+)\s*$/); (Field of
matches) = (string to operate on =~ /BOL spaces? (nonspaces+) spaces?
(everything+, minimal) spaces? (nonspaves+) spaces? EOL/);
something like this...
Andre.
> print $file; -->no output
> }
> So what is the right matching syntax ????
>
> --
> Regards
> Simon Dueckert \^ ^/
> )@ @(
> +---------------------------oOO--(_)----------------------------------+
> + Student of Friedrich Alexander University - Electrical Engineering +
> + Mr. Simon Dueckert | Phone: (+49) (0)9131 33068 +
> + Karlsbader Strasse 9 | Fax : (+49) (0)9131 33068 +
> + 91058 Erlangen (germany) | Mobil: (+49) (0)177 4101640 +
> + | Work : (+49) (0)9131 776315 +
> + | Email: dueckert@iname.com +
> + web site: under construction | dueckert@iis.fhg.de +
> +-----------------------------------Oooo--oOO-------------------------+
> oooO ( )
> ( ) ) /
> \ ( (_/
> \_)
>
> Type Bits/KeyID Date User ID
> pub 1024/514EC449 1998/03/22 Simon Dueckert <dueckert@iis.fhg.de>
>
> -----BEGIN PGP PUBLIC KEY BLOCK-----
> Version: 2.6.3i
>
> mQCNAzUVkEsAAAEEALnpUJNlyfzRmdchWCm+sJejFsYlOF+1zD00UANEzIBtGxj4
> iMMg5BEZuF2Vq4EFSxgi5OFp4GnaI1cUHJshWwehyHedB3+GmbKmebXc4Qz/5Wqk
> vVRO/LklJ0gUZ3YIKd7RgJ5cjUScN+odJklQWgjMMsSb5Y1kwzdnXytRTsRJAAUR
> tCRTaW1vbiBEdWVja2VydCA8ZHVlY2tlcnRAaWlzLmZoZy5kZT6JAJUDBRA1FZBL
> N2dfK1FOxEkBAU5QA/4uBzbfD5jB/tMbFgVXpxysrxWCP57ta2Z/EgdVs7SZAwcs
> JaxPGO21tJqgWHdbYzTo+OFxO1F2I9UypdslLkPq94G5EnjIooMSZ91JWwB9aG5o
> f3mbmTWXy7sAEXORr4yN8IjHh7518zStgWKppdr54IA/6M4/FpdpM8Yfz0ozEA==
> =WyIf
> -----END PGP PUBLIC KEY BLOCK-----
>
>
--
Andre Merzky
pinocchio@earthling.net
http://pino.home.pages.de/
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Mon, 20 Jul 1998 03:07:57 GMT
From: isifuelo@my-dejanews.com
Subject: novice Q; reading columns of numbers
Message-Id: <6oucad$ui5$1@nnrp1.dejanews.com>
I'm trying to read html file which contains 6 columns seperated by spaces
[deleted html stuff]
A B C D E F
1/05/98 25.545 25.875 26.225 25.323 2,790,245
1/02/98 25.000 25.375 25.750 25.063 2,566,445
12/31/97 25.225 24.938 25.545 24.625 3,242,645
^--------------------------------^ move here
I'd like to reformat above so numbers are seperated using commas,
commas removed from numbers (1,234,567 -> 1234567), column B moves
after E, and dates reveresed (line with old date at the beginning of file).
output should look like:
12/31/97......
1/02/98,25.875,26.225,26.225,25.000,2790245
1/05/98,...
I'm trying to match...
(\d(\d)?)/(\d(\d)?)/(\d\(d)?)\s([0-9]+(\.[0-9]*)?)\s([0-9]+(\.[0-9]*)?)\s([0-
9]+(\.[0-9]*)?)\s([0-9]+(\.[0-9]*)?)\s([0-9]*) i dont know how to do last
column (number with commas) is that right? what other stuff i need to make it
a perl program (using perl on win95).
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Mon, 20 Jul 1998 00:35:04 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: novice Q; reading columns of numbers
Message-Id: <1dcfuwy.qglnpx1d1hq6gN@bay2-86.quincy.ziplink.net>
<isifuelo@my-dejanews.com> wrote:
> I'm trying to read html file which contains 6 columns seperated by spaces
> [...]
> I'm trying to match...
Don't do that. Use split or unpack instead. They're documented in
perlfunc. If you use split, watch out for the lines with initial
whitespace.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 20 Jul 1998 05:03:55 GMT
From: Juergen.Puenter@materna.de (J|rgen P|nter)
Subject: Re: open (IN, "foo.txt") works, open (IN, "$foo") does not???
Message-Id: <6ouj3r$2as$1@penthesilea.Materna.DE>
In article <6oojpe$5r$1@hirame.wwa.com>, troy@whadda.com says...
>
>This works for me.
>
>#!/perl/bin -w
>
>$file2 = "test.";
>$file3 = "txt";
>$file4 = $file2.$file3; #works fine, as expected
>#$file4 = "$file2$file3"; #works file, as expected
Right, and that's exactly what I expeced, too. Only that it does not
work for me. <Sigh>
Oh well, thanks anyway.
Juergen Puenter
------------------------------
Date: 20 Jul 1998 05:18:45 GMT
From: Juergen.Puenter@materna.de (J|rgen P|nter)
Subject: Re: open (IN, "foo.txt") works, open (IN, "$foo") does not???
Message-Id: <6oujvl$2as$2@penthesilea.Materna.DE>
In article <g1g0ocba.fsf@mailhost.panix.com>, jdf@pobox.com says...
>
>Juergen.Puenter@materna.de (J|rgen P|nter) writes:
>
>> $file4 = #choose your method to put together $file2 and $file3#
>> open (FHIN, "$file4") || die "...";
>
>If you can post a *brief* but *complete* program that demonstrates this
>behavior, please do.
OK, here it is:
### start skript ###
#!/usr/local/bin/perl -w # perl 5.001 BTW
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read (STDIN, $ENV{'QUERY_STRING'}, $ENV{'CONTENT_LENGTH'});
}
$Eingabe = $ENV{'QUERY_STRING'};
&Sonderzeichen(); # omitted for brevity.
# it cannot be the
# source of error.
$Eingabe =~ s/\s//g;
$Eingabe =~ s/\+/ /g;
%words = split (/[=&]/, $Eingabe);
$datei = $words{"datei"};
$path3 = "/a/b/c/this_is_My.fIle.001.001"; # this works
# $path1 = "/a/b/c/"; # this does not work
# $path2 = "this_is_My.fIle.001.001";
# $path3 = $path1.$path2;
# $path1 = "/a/b/c/"; # this does not work.
# $path2 = $datei; # Yes, $datei really
# $path3 = "$path1.$path2"; # is what it should be
# $path1 = "/a/b/c"; # this does not work
# $path2 = "this_is_My.fIle.001.001"; # even though chdir
# chdir ($path1); # puts me into /a/b/c
# $path3 = $path2;
print STDERR "\n\n|$path3|\n\n"; # is $path3 correct and
# without \n, \t...
# Yes, every time.
open (FHIN, "<$path3") || die "Can't open '$path3' for read: $!";
# The rest is never executed, the script always dies right here at the 'open'.
# It says "Can't open '/a/b/c/this_is_My.fIle.001.001' for read: No such file
# or directory". (File and dir are there and are 777)
# If the rest were executed, this is what should happen:
$line = <FHIN>;
close (FHIN);
($qsid, $kurzb, $test, $soll) = (split(/\+{3}/, $line))[0,1,2,3];
$ist = $words{"ergebnis"};
$error = $words{"error"};
$anm = $words{"anm"};
open (FHOUT, ">$path3") || die "Can't open '$path3' for write: $!";
print FHOUT join("+++", $qsid, $kurzb, $test, $soll, $ist, $error, $anm);
close (FHOUT)
### end skript ###
And that's all there is to the script. Nothing fancy, but it still it
fails in all but one case :-(
Thanks for your time
Juergen Puenter
------------------------------
Date: 19 Jul 1998 20:25:55 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl Beautifier Home Page
Message-Id: <m3r9zhyzi4.fsf@windlord.Stanford.EDU>
Abigail <abigail@fnx.com> writes:
> I tend to use:
> ($VERSION) = '$Revision: 1.2 $' =~ /([\d.]+)/;
The reason why I don't just use that is that things get rather confused
when I go from version 1.9 to version 1.10.
--
#!/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: 20 Jul 1998 03:35:43 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl Beautifier Home Page
Message-Id: <900906331.646167@thrush.omix.com>
Abigail <abigail@fnx.com> wrote:
>snip<
: I tend to use:
: ($VERSION) = '$Revision: 1.2 $' =~ /([\d.]+)/;
This limits you to a maximum of 10 minor revision numbers
before it causes serious problems.
If you don't check in your code often, this works fine. But if you
do then you'll need something that can at least get you past the
1.9 to 1.10 step or perl will think you just jumped back quite a
few revisions. Thus, if 1.2 is installed, and a program asks for
1.10 perl will not complain. Similarly, if the program asks for
1.9 and 1.10 is installed, perl will complain incorrectly.
I tried creating a VERSION() method that could handle this correctly
as well as 1.2.3.x formats so they could be called as:
use My::Module 1.2.3;
This can actually work, but to do so the version number must be
quoted like this:
use My::Module '1.2.3';
Which personally I think is asking a bit much from users as it
breaks convention.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Mon, 20 Jul 1998 03:30:26 GMT
From: kanak@pobox.com
Subject: Re: Perl CGI's under Windows NT
Message-Id: <6oudki$5s$1@nnrp1.dejanews.com>
Folks have told me that they do run under PWS, but I don't know, I'm beginning
to have my doubts. I'd do it under IIS, but it installs only on Windows 4.0
Server edition and I'm using client. This is just a personal box and I don't
own NT Server. Thanks though...
In article <6ora15$6am$1@taliesin.netcom.net.uk>,
"Clinton Gormley" <*clinton@consol.co.uk> wrote:
> When I tried to do this with Personal Web Sever under Win95, Microsoft told
> me that PWS wouldn't run Perl scripts. Don't know about NT?
>
> Why not use IIS?
>
> kanak@pobox.com wrote in message <6or7vh$fgl$1@nnrp1.dejanews.com>...
> >Hi,
> >
> >If I'm in the wrong group, I apologize, and would appreciate it if someone
> >would be able to direct me to a more appropriate group.
> >
> >I've been having a problem getting Perl scripts to run as cgi's under
> Windows
> >NT with Micro$oft Personal Web Server. The .pl files and .cgi files run
> fine
> >by hand. But when launched from the web server, the symptom is that the
> web
> >server will try to do an http transfer of a .pl file, and will whine about
> >the .cgi file with a "%1 is not a valid Windows NT application.".
> >
> >-My two local guru's remember having this problem but don't remember how to
> >get around it!
> >
> >-All directories in the Personal Web Server are checked execute.
> >
> >-I've added d:\perl\bin\perl.exe %s %s to
> >My Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet
> >\Services\W3SVC\Parameters\ScriptMap for .plx, .pl and .cgi
> >
> >-I've manually associated .pl and .cgi with the perl binary
> >-I've run a little registry script like this:
> >REGEDIT4
> >
> >[HKEY_CLASSES_ROOT\.PL]
> >@ = "PL_auto_file"
> >
> >[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PL_auto_file]
> >@ = ""
> >
> >[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PL_auto_file\shell]
> >
> >[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PL_auto_file\shell\open]
> >@ = ""
> >
> >[HKEY_CLASSES_ROOT\PL_auto_file\shell\open\command]
> >@ = "\"D:\\perl\\bin\\perl.exe\" %1 %*"
> >
> >
> >Please if anybody has any ideas for this, I'd really like to know!
> >
> >-----== Posted via Deja News, The Leader in Internet Discussion ==-----
> >http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Mon, 20 Jul 1998 14:23:40 +0800
From: Raymond Ip <raymond_wmip@hotmail.com>
Subject: Perl script to POP3
Message-Id: <35B2E26C.AF4CB468@hotmail.com>
Can I use Mail::POP3Client to check the status (Read or Unread) of each
message ? and can I update the status (mark unread to read) ? If yes,
how
can I do ?
Best Regards
Raymond Ip
------------------------------
Date: Mon, 20 Jul 1998 00:35:05 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Reading in an email message into a Perl program
Message-Id: <1dcfv7y.1k13cq312368b9N@bay2-86.quincy.ziplink.net>
- <root.noharvest.\@not_even\here.com> wrote:
> rjk@coos.dartmouth.edu (Ronald J Kimball) Said this:
>
> First, I goofed.... I snipped the code from a script I'm currently
> developing, as opposed to the original working script:
>
> while (<>) # Get headers
> {
>
> last if /^$/;
> push(@headers, $_);
> $header .= $_;
> ($field, $value) = /^(\S*)\s*(.*)/;
> if (length($field) > 1) { $fields{$field} = $value; }
> else { $fields{$field} .= " $value"; }
> }
It still doesn't quite work; you didn't address the bug I pointed out.
For multiline headers all lines after the first are concatenated onto
$fields{''}.
DB<1> l
1==> while (<>) # Get headers
2 {
3
4: last if /^$/;
5: push(@headers, $_);
6: $header .= $_;
7: ($field, $value) = /^(\S*)\s*(.*)/;
8: if (length($field) > 1) { $fields{$field} = $value; }
9: else { $fields{$field} .= " $value"; }
10 }
DB<1> l
11
12: 1;
DB<1> c 12
main::(Dev:Pseudo:12): 1;
DB<2> x \%fields
0 HASH(0x1e2c548)
'' => ' by coos.dartmouth.edu (8.8.8/8.8.8) with ESMTP id TAA0000 for
<rjk@coos.dartmouth.edu>; Sun, 19 Jul 1998 19:14:41 -0400 by
mail.example.com (8.8.6/8.8.6) with SMTP id QAA0000 for
<rjk@coos.dartmouth.edu>; Sun, 19 Jul 1998 16:14:39 -0400'
'Date:' => 'Sun, 19 Jul 1998 16:15:08 -0400'
'From' => 'someone@example.com Sun Jul 19 19:14:43 1998'
'From:' => 'someone@example.com'
'Received:' => 'from 0.0.0.0 (somwhere.example.com [0.0.0.0])'
DB<3>
Note the very first key/value pair in the hash.
(Here is the input used:
>From someone@example.com Sun Jul 19 19:14:43 1998
Received: from mail.example.com (mail.example.com [0.0.0.0])
by coos.dartmouth.edu (8.8.8/8.8.8) with ESMTP id TAA0000
for <rjk@coos.dartmouth.edu>; Sun, 19 Jul 1998 19:14:41 -0400
Received: from 0.0.0.0 (somwhere.example.com [0.0.0.0])
by mail.example.com (8.8.6/8.8.6) with SMTP id QAA0000
for <rjk@coos.dartmouth.edu>; Sun, 19 Jul 1998 16:14:39 -0400
Date: Sun, 19 Jul 1998 16:15:08 -0400
From: someone@example.com
)
I corrected this bug in the post you replied to, but I didn't quite get
it right the first time. The response I posted to my message contains
the fix for that error.
> >
> >I believe he is dealing with multi-line headers, such as:
> >
> >X-Face: *spJTl5BP|H]tv^0$Q6a-pzBFK8I5fHa$8}}%f[=uE!o{BT`.GS9L}atGt.A*
> > lE.l,Qi{"Ge2>hK*$qvJx\ev\>+b87D,fxSfXItRacBv*Z%`bZK*@B
> >
> >On the first line, the regex match sets $field to 'X-Face:' and $value
> >to '*spJTl5BP|H]tv^0$Q6a-pzBFK8I5fHa$8}}%f[=uE!o{BT`.GS9L}atGt.A*'.
> >
> >The length of $field is greater than 1, so the hash now looks like
> >
> >(
> > 'X-Face:' =>
> > '*spJTl5BP|H]tv^0$Q6a-pzBFK8I5fHa$8}}%f[=uE!o{BT`.GS9L}atGt.A*',
> >)
> >
> >On the second line, the regex match sets $field to '' and $value to
> >'lE.l,Qi{"Ge2>hK*$qvJx\ev\>+b87D,fxSfXItRacBv*Z%`bZK*@B'.
> >
> >The length of $field is not greater than 1, so the value should be
> >concatenated to the hash value of the previous field. Unfortunately,
> >the name of the previous field has been replaced with '', so the hash
> >now looks like
> >
> >(
> > 'X-Face:' =>
> > '*spJTl5BP|H]tv^0$Q6a-pzBFK8I5fHa$8}}%f[=uE!o{BT`.GS9L}atGt.A*',
> > '' =>
> > ' lE.l,Qi{"Ge2>hK*$qvJx\ev\>+b87D,fxSfXItRacBv*Z%`bZK*@B',
> >)
> >
> >The first line of each field will be associated with the proper key, but
> >any subsequent lines in multiline fields will be appended to the value
> >of the null string key.
> >
[...]
> Like i mentioned above, I've been using this for 2 years, and I've
> never had it "break" in any way. Of course, I'm not keying into the
> Received: lines or any other multiline header data.
I guess that is why you've never seen the above bug manifested. Fair
enough. I made the same sort of mistake with my initial correction!
:-)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 20 Jul 1998 03:02:14 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: sub's and rsh rlogin
Message-Id: <6oubvm$8hj$1@nswpull.telstra.net>
Please, set up your news reader correclty, so that it wraps lines at a
reasonable length.
In article <35B297F0.97421E41@nospam.com>,
me <nospam@nospam.com> writes:
> Hi guys,
Not interested in answers from the women? :)
> 1)
> any of the books I have) am I allowed to use integers as the
> name of a sub? The reason I say this is because when I change
> the name of the sub to something else (like "a" for example) it
> works fine.
see below.
> 2) The next thing I will have to do is call these scripts from several
> different
> macines. I have looked into "rsh" and "rlogin" but again I get
> errors:
>
> "rsh -l username hostname command" results in "permission denied".
This is a question about rsh, not about perl. Please consult your
local rsh and rlogin documentation. (did you set up a .rhosts file?)
> "Can't locate object method "username" via package "hostanme" at
> ./zonegen line 24, <> chunk 1."
hostanme? Looks like a typo.
> open (MENU,"menu");
You should always check the return value of an open.
open(MENU, "menu") || die "Cannot open menu: $!";
> while (<MENU>) {
> print;
> }
You should probably close MENU here.
> print "\n\nEnter Selection: ";
> chomp($selection=<>);
If you want to read from STDIN, maybe you should say so. <> and
<STDIN> are _not_ the same thing.
> print ("\n\n");
> if ($selection < 22) {
> &$selection;
> }
Ok, so here you are trying to execute a subroutine with a numerical
name. That part of names are called identifiers, and the rules for
identifiers are somewhat spread out over the perl documentation.
You can pick up stuff from perldata, perlsyn, perlsub, and maybe one
or two others.
Normally an identifier is a string, beginning with a letter
or underscore, and containing letters, underscores and digits. There
are exceptions, but none that are pertinent to this discussion.
You can solve this by having a map from numbers to names of
subroutines, or prefixing every subroutine name with a valid string.
Your choice.
If you use a map, with an array or something, you have the added
advantage that you can easily check whether the sub is 'defined'. At
least in the map.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | You can't have everything, where would
Commercial Dynamics Pty. Ltd. | you put it?
NSW, Australia |
------------------------------
Date: 19 Jul 1998 23:53:36 GMT
From: orwant@rocky-horror.media.mit.edu (Jon Orwant)
Subject: The Perl Job Board
Message-Id: <ORWANT.98Jul19195336@rocky-horror.media.mit.edu>
I've set up a Perl Job Board on the TPJ web site.
It will help Perl programmers find jobs.
It will help companies find Perl programmers.
It's free.
It's also in a very alpha state. Since it's hard to guess
what programmers and companies will want to say about
themselves, the site will change rapidly over the next few
weeks in response to any feedback sent to jobs@tpj.com.
http://tpj.com/tpj/jobs
Enjoy,
-Jon
------------------------------------
Jon Orwant http://tpj.com
Editor & Publisher, The Perl Journal
--
------------------------------
Date: Mon, 20 Jul 1998 00:35:07 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Web Components
Message-Id: <1dcfw26.18baye61g7xu5tN@bay2-86.quincy.ziplink.net>
Tad McClellan <tadmc@flash.net> wrote:
> I've seen calls to boycott Amazon in the past, but I had not seen
> first hand any abuses by them.
>
> Now I have.
>
> Boycott Amazon!
It's possible that the spammer is unafiliated with Amazon.com, and is
instead the publisher or one of the authors.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
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 3201
**************************************