[9600] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3194 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 18 13:07:20 1998

Date: Sat, 18 Jul 98 10:00:21 -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           Sat, 18 Jul 1998     Volume: 8 Number: 3194

Today's topics:
    Re: ($| = 1 || $| = 0) <zenin@bawdycaste.org>
    Re: ($| = 1 || $| = 0) <flavell@mail.cern.ch>
        [Fwd: . /etc/profile equivelent] <richj@advsoftech.com>
        Anybody using perl-ldap.pm? <hannum@oak.cat.ohiou.edu>
    Re: Can a Crontab run perl script (Ronald J Kimball)
        CCov, how to install <hkhidhir@csi.uottawa.ca>
        Interpolating variables in strings.... <hkhidhir@csi.uottawa.ca>
    Re: Interpolating variables in strings.... (Larry Rosler)
    Re: Interpolating variables in strings.... <zenin@bawdycaste.org>
    Re: OFFTOPIC: Re: HELP: Internet Database Design questi <dcrombie@chirp.com.au>
    Re: Perl Beautifier Home Page <zenin@bawdycaste.org>
    Re: Perl Beautifier Home Page <tim.maher@halcyon.com>
    Re: Perl5  on Netware Web Server: real or half-broke po <burt@netonecom.net>
    Re: Premature End of Script Header problem <flavell@mail.cern.ch>
    Re: Reading in an email message into a Perl program (Larry Rosler)
    Re: Reading in an email message into a Perl program (Ronald J Kimball)
    Re: Remote login question (-)
    Re: string manipulation, newbie question (Ronald J Kimball)
    Re: upload in CGI perl <bowlin@sirius.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 18 Jul 1998 14:21:11 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: ($| = 1 || $| = 0)
Message-Id: <900772250.546900@thrush.omix.com>

Ekenberg <joreb@algonet.se> wrote:
	>snip<
: When calling this like a cgi, it sleeps first and writes everything second,
: no matter if I set $| to true or false.

	This is do to the web server design, not any stdio buffering or
	flushing.  Most all modern web servers collect *all* of a CGI's
	output before sending any of it to the user.  The reasons
	for this are the topic of another thread.  If you what a direct
	pipe to the client, you'll need to use a "No Parsed Header"
	script or similar, at least under Apache.  Not all web servers
	support such a concept and each one does it differently.  Check
	your server's docs.

: When executed at commandline, it
: writes, sleeps, and writes again, again no matter how I set $|.

	You misunderstand the use of auto flushing.  It's mainly useful
	to make sure when you write data out that it goes out right then
	and doesn't get buffered.  This is mostly useful to make sure
	that multiple processes writing to the same file/pipe get sent
	in order.

	To turn off auto flushes (the default, as $| is false), does not
	mean that stdio *will* buffer data, just that it is allowed to.
	If you don't want to write at a particular point in time, don't
	write then. :-)

: I wanted it to write, sleep, and write again when called as cgi, but no.
: Thats also how I understood from explanations in books and script-comments
: that it would do. Why else is it include in so many scripts?

	If a script calls another process (such as in a system() call), the
	calling script doesn't want that process's output showing up
	in the streem before output that the script might have sent *before*
	even calling the other process.  Without flushing your writes,
	you may have such output out of order.
-- 
-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: Sat, 18 Jul 1998 16:50:46 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: ($| = 1 || $| = 0)
Message-Id: <Pine.HPP.3.95a.980718164319.20741K-100000@hpplus01.cern.ch>

On 18 Jul 1998, Ekenberg wrote:

 ..
> I tried with this little code snippet:
 ..
> When calling this like a cgi, it sleeps first and writes everything second,
> no matter if I set $| to true or false. 

Right, because you executed it as a CGI.  It isn't a perl issue, it's
a question about your server (HTTPD).

Some servers need scripts to be executed as nph- scripts (no-parsed-
headers) before they'll pass the script output along immediately.

> I wanted it to write, sleep, and write again when called as cgi,

Well, it still isn't necessarily going to work in an accurate way, after
all you can't control the network bottlenecks between the server and the
client, so it's hopeless to think you could accurately control the
chronology of the display like this. 

But yes, you _can_ get output to display incrementally, and in some
situations it's very useful to do so. But, as I say, if your web server
is buffering the output, it won't be sufficient to merely unbuffer perl: 
you may need to convert to nph- scripts.  More details in the standard
CGI tutorials, eg at http://hoohoo.ncsa.uiuc.edi/cgi/




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

Date: Sat, 18 Jul 1998 11:28:08 -0500
From: Richard June <richj@advsoftech.com>
Subject: [Fwd: . /etc/profile equivelent]
Message-Id: <35B0CD18.1173BB62@advsoftech.com>

This is a multi-part message in MIME format.
--------------F63716ED2D26CD08398F953E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

-- 
"I love it when the point and click commandos attempt to portray
themselves as real computer experts. Using a mouse only makes you a
computer user, not a computer expert"
			Someone in comp.unix.advocacy
--------------F63716ED2D26CD08398F953E
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Path: news.megsinet.net!not-for-mail
From: Richard June <richj@advsoftech.com>
Newsgroups: comp.lang.perl
Subject: . /etc/profile equivelent
Date: Sat, 18 Jul 1998 11:26:39 -0500
Organization: MegsInet, Inc. - Low Cost, High Performance Internet Services
Message-ID: <35B0CCBF.2E9172F6@advsoftech.com>
NNTP-Posting-Host: 162.142.131.45
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 4.05 [en] (X11; I; FreeBSD 2.2.2-RELEASE i386)
Xref: news.megsinet.net comp.lang.perl:3724

I'm new to perl and I am working on software to control a  UNIX server
via http. I have a few questions, one where can I find a good tutorial
on regulare expressions and such, I have 15 shell scripts to do stuff I
know can be done in perl. two, in bourne if you run " . <path>" you can
read in a profile file and set environment variables(in essence a config
file) is there anything like it in perl or do I have to open the file
read in everything et. all?
TIA
-- 
"I love it when the point and click commandos attempt to portray
themselves as real computer experts. Using a mouse only makes you a
computer user, not a computer expert"
			Someone in comp.unix.advocacy

--------------F63716ED2D26CD08398F953E--



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

Date: Tue, 14 Jul 1998 15:08:20 GMT
From: "Dave" <hannum@oak.cat.ohiou.edu>
Subject: Anybody using perl-ldap.pm?
Message-Id: <Ew38I8.By2@boss.cs.ohiou.edu>

Hello all,

I have an application to use perl-ldap.  I have a directory which I have
written using DBD::Informix and DBI for a database.  However, I need to
capture some initial info on the user from LDAP on an x.500 system as they
log in using DCE.  I capture the ID from the DCE login and need to search
LDAP for the matching UID which is the key, then return name, degree, title,
etc.

Can somebody help me get started?  I can find almost no documentation on
perl-ldap.  Is anybody using it that would be willing to help?

Thanks,
Dave H.





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

Date: Sat, 18 Jul 1998 11:17:47 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Can a Crontab run perl script
Message-Id: <1dccyv8.a4l64q13fhqbkN@bay2-83.quincy.ziplink.net>

- <root.noharvest.\@not_even\here.com> wrote:

> Anywhere in the script where you use "relative" paths, you will need
> to make them full paths..... 
> 
> open (IN, "somefile.pl");
> 
> needs to be changed to 
> 
> open (IN, "/full/dir/to/somefile.pl");

A similar solution would be to chdir("/full/dir/to") at the beginning of
the script.

-- 
 _ / '  _      /         - 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: Fri, 17 Jul 1998 19:51:06 -0400
From: Khalid Khidhir <hkhidhir@csi.uottawa.ca>
Subject: CCov, how to install
Message-Id: <Pine.SUN.3.96.980717194832.7356A-100000@grdb.csi.uottawa.ca>

Hi There, anybody is using the CCov package?
I am trying to install it under Win nt, I do not have a compiler.
It will be nice If I can get the binaries.
Appriciate your help
Thanks


+------------------------------------+
|  Khidhir Khalid                    |
|  Department of Computer Science    |
|  University of Ottawa              |
|  E-mail: hkhidhir@csi.uottawa.ca   |
+------------------------------------+



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

Date: Fri, 17 Jul 1998 16:43:16 -0400
From: Khalid Khidhir <hkhidhir@csi.uottawa.ca>
Subject: Interpolating variables in strings....
Message-Id: <Pine.SUN.3.96.980717163545.5989A-100000@grdb.csi.uottawa.ca>

Hi All, I have a questioN about interpolating strings, I guess the best
way is to shw you my code and then ask the question:

my $str = "AAbbAA";
my $string = "this is a string that contain \$str, in it";

print "Str = $str\n";
print "String = $string\n";

The last print statment will print $string with $str.

My question is how can I force the interpolation of the variable
$str inside $string.

The reason I am doing this is I need to manipolate $string without the
contents of $str, then at the end after I finish I need the contents of
$str, and that is why I am having this problem

I really appriciate your help.
Thanks

+------------------------------------+
|  Khidhir Khalid                    |
|  Department of Computer Science    |
|  University of Ottawa              |
|  E-mail: hkhidhir@csi.uottawa.ca   |
+------------------------------------+



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

Date: Sat, 18 Jul 1998 08:12:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Interpolating variables in strings....
Message-Id: <MPG.101a5b1cec2c3925989759@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <Pine.SUN.3.96.980717163545.5989A-100000@grdb.csi.uottawa.ca> 
on Fri, 17 Jul 1998 16:43:16 -0400, Khalid Khidhir 
<hkhidhir@csi.uottawa.ca> says...
> Hi All, I have a questioN about interpolating strings, I guess the best
> way is to shw you my code and then ask the question:
> 
> my $str = "AAbbAA";
> my $string = "this is a string that contain \$str, in it";
> 
> print "Str = $str\n";
> print "String = $string\n";
> 
> The last print statment will print $string with $str.
> 
> My question is how can I force the interpolation of the variable
> $str inside $string.

Perhaps you will find the answer to this Frequently Asked Question in 
perlfaq4: "How can I expand variables in text strings?"

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


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

Date: 18 Jul 1998 15:16:13 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Interpolating variables in strings....
Message-Id: <900775553.7713@thrush.omix.com>

Khalid Khidhir <hkhidhir@csi.uottawa.ca> wrote:
: print "String = $string\n";
	>snip<

	print eval "qq(String = $string\n)";

	But you probably don't want that.  See below for a better way.
 
: The reason I am doing this is I need to manipolate $string without the
: contents of $str, then at the end after I finish I need the contents of
: $str, and that is why I am having this problem

	Normally I just would make $string a printf format with %s
	instead of $str.  Something like:

	my $str = "AAbbAA";
	my $string = "this is a string that contain %s, in it\n";

	print "Str = $str\n";
	printf $string, $str;

	This is a much preferred method, as using a string eval() can
	cause all kinds of trouble if you aren't really carful.  This
	also isn't scope dependent, so you could easily pass $string
	and $str to a function by value and it would work fine.  That
	is, there would be no dependence on exact variable names just
	there values.  You also gain better name checking if you're
	using use strict and/or -w.

-- 
-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: Sat, 18 Jul 1998 17:15:38 +1000
From: Duncan Crombie <dcrombie@chirp.com.au>
Subject: Re: OFFTOPIC: Re: HELP: Internet Database Design questions...
Message-Id: <35B04B94.4B988E4A@chirp.com.au>

Yes but Unix fixed that bug years ago wheras MS released a mail server
this(last?) year with all the security holes everyone else has fixed over the
years still there!

Duncan Crombie
dcrombie@chirp.com.au

Jamie Cruise wrote:
> 
> Hi C,
>     The bug that you outline is indeed quite serious, though also quite
> easily resolved. To dismiss a platform because of such a bug is still
> however somewhat naive. For example I cannot see how this is in any way as
> serious as some previous unix security holes (e.g. sendmail) I mean,
> viewing the contents of a script instead of executing is indeed a big issue,
> but not quite as big as allowing remote users to su root and rm -rf /.
> However those issues are pretty much resolved and the world has moved
> on...Like you should.
> 
> Regards J
> 
> C. Abney wrote in message <6ojl4j$iku$1@news.infonex.net>...
> >In article <6ogl04$69d$1@bvbsd2.kc.bv.com>,
> > "dogmat" <macdonaldrj@bv.com> writes:
> >> - wrote in message <35aa9523.19867848@nntp.idsonline.com>...
> >
> >>>Just because you've had a pc on your desk for a couple years does not
> >>>make you technically literate.  Using word, or netscape is not a
> >>>computer skill, it's being a computer user.  Being a computer user
> >>>does not qualify you to make suggestions about network environments.
> >
> >> Such insight. You probably hang out with your other lonely guy colleagues
> >> making fun of all those silly users.
> >> Grow up. And if you have any brains, keep an eye on NT. It may not be
> better
> >> than Unix, but it wasn't any better than the Mac either.
> >
> >If you *really* want to know why you shouldn't want to do anything using
> >NT, or IIS, or any of MS offalings, just point your browser at:
> >
> >http://www.any.site.stupid.enough.to.serve.asps/default.asp::$DATA
> >
> >and you will understand that what you don't see is often what you get
> >when you buy from MS.  Using a computer on the web is /not/ the act of a
> >pedestrian.  Frightening.  Kind of makes one want to stick with perl if
> >only to stay away from VBscript ( among its other weaknesses.  I don't
> >really know if this works for _any_ scripted page on IIS or not, I am
> >only trying to bring the discussion a little closer to on topic. :)
> >
> >-C
> >--
> >All your qualifications for kookiness seem to be aimed at eliminating
> >yourself simply because you advocate a mainstream product.  That is sort
> >of just being a kook who is a conformist.  A bit of a contradiction in
> >terms, but a valid description. -Bob O                        C. Abney
> >


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

Date: 18 Jul 1998 15:32:42 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl Beautifier Home Page
Message-Id: <900776541.515605@thrush.omix.com>

Russ Allbery <rra@stanford.edu> wrote:
: It's *definitely* not.  There's no reason whatsoever to use more than 80
: columns.

$VERSION = do { my @r = (q$Revision: 2.0 $ =~ /\d+/g); sprintf '%d.%03d'.'%02d' x ($#r-1), @r};

	Try putting that on multiple lines.  Hint: check with MakeMaker.

	:-)

-- 
-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: Sat, 18 Jul 1998 09:42:17 +0100
From: Tim Maher <tim.maher@halcyon.com>
To: Andrew Ward <adward@nortel.com>
Subject: Re: Perl Beautifier Home Page
Message-Id: <35B05FE9.AC8A3717@halcyon.com>



Andrew Ward wrote:

> Maybe I'm evil for doing this, but it turned

Yes, you are  . . .

>
>
> split(/;/);
>
> into
>
> ($_, $null) = split(/;
>                                             /);
>
> which is noticeably wrong.  I also tried
>
> split(/\;/);
>
> which didn't help.

If you had left out the () in the first place, and inserted a space after
split,
all would have been fine.  Why did you use parentheses?

>
>
> Otherwise, though, it doesn't look like it did any other strange things.
> Looks good!
>
> ----------------------------
> Andrew Ward
> Northern Telecom
> adward@nortel.com



--
====================================================
|  Tim Maher         Email: Tim.Maher@halcyon.com  |
====================================================




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

Date: Sat, 18 Jul 1998 12:14:07 -0400
From: Burt Adsit <burt@netonecom.net>
Subject: Re: Perl5  on Netware Web Server: real or half-broke port? Does anyone know/is Novell telling?
Message-Id: <35B0C9CF.C1354325@netonecom.net>

I did get some perl up and running on this lashup but haven't had much
luck getting info from others in the ng on this subject. Don't think too
many are doing this. 

You have to install any libs that you want. I found a strangely named
cgi-lib but that's all. I don't think that Novell is very serious about
their web server. More of a marketing checklist thing than anything
else.

Burt

Kerry Lester wrote:
> 
>     I have Novell WEB Server 3.1, installed it for the sole reason
> that it includes a Perl5.NLM.  Naturally,  running a Perl script thru
> CGI works OK, but what I really want is to cron job some perl scripts,
> and so far haven't been able to find a means of executing a Perl
> script other than thru a web page link - it's the damndest thing...
> would someone really do that?  It doesn't make sense.   Is anyone in
> the know about this port of Perl?
>    Likewise, there are a couple of obscure references among Novell
> Knowledge Base docs to "ability to specify additional library paths",
> i.e. other than YourServer/volume:inw_web/shared/Lcgi/Perl5 (home of
> Perl5.NLM).  So far that's all I've found that even hint that maybe
> this "Perl5.NLM" can use modules, hence: (1) Novell calls it Perl5, so
> can it use modules? (2) The same Carp.pm, net.pm, Socket.pm, etc
> module files that works on Wn95, Linux, etc.? (3) So where do you have
> to put these or how do you specify add'l lib paths? Huh?


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

Date: Sat, 18 Jul 1998 16:41:08 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Premature End of Script Header problem
Message-Id: <Pine.HPP.3.95a.980718161607.20741J-100000@hpplus01.cern.ch>


Please do NOT send email copies of your posted abuse.

On Fri, 17 Jul 1998, David Hemmer wrote:

> Here's that exact error message for those actually interested in helping:
> 
> [Fri Jul 17 04:25:28 1998] access to
> /home/mastered/public_html/cgi-bin/status.cgi failed for p12pm3.paclink.com,
> reason: Premature end of script headers
> exec of /home/mastered/public_html/cgi-bin/status.cgi failed, reason: Exec
> format error (errno = 8)

So why didn't you say that in the first place?  We aren't telepathic,
and by posting all that irrelevant detail in the first posting, I think
I'm entitled to say that you managed to obscure the actual problem. 

> Im still researching on my own to find the problem but will still entertain
> suggestions on how to fix this problem.

Gosh, how generous of you.  No wonder they devised the moderated group.

Now, let's see.  You stated that:

> This script I have comes out ok when I 'perl -c status.cgi' it and it
> outputs what it is supposed to when I run it as 'perl status.cgi' but
> when I try running it through a web browser, it kicks back with Internal
> Server Error and the error log says it died because of a premature end
> of script header.

So, what does it say when you execute it by hand _without_ prefixing it
with the command "perl"?  That, after all, is what the web server is
going to do.

>  #/usr/bin/perl

Where did you get _that_ model from?

Assuming that /usr/bin/perl is the correct path to perl on your system,
then what you wanted there was

#!/usr/bin/perl

(or more likely

#!/usr/bin/perl -wT

for the reasons explained ad nauseam in tutorials).

> AND PLEASE REMEMBER THIS NEXT TIME YOU ANSWER A NEWBIE QUESTION!!!!! 

Nope.  Either give an impression you're making a decent attempt to help
yourself, or accept the advice you're given.  You seem to be doing
neither.  There is no shame in being a beginner - I'm pretty much a perl
beginner myself still - but being a lamer who refuses to benefit from
the advice they are given, and then aggravates the offence by being rude
with it, is inexcusable IMO.  This isn't some free advice desk where you
can demand to get answers on your own terms.  The FAQs have been
designed to protect newbies from themselves, but you clearly don't wish
to take advantage of that protection.  Too bad - not only for yourself.



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

Date: Sat, 18 Jul 1998 07:19:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reading in an email message into a Perl program
Message-Id: <MPG.101a4ee9b0140503989757@nntp.hpl.hp.com>

In article <35b0a027.365057467@news2.cais.com> on Sat, 18 Jul 1998 
13:24:45 GMT, root.noharvest.\@not_even\here.com (-) 
<root.noharvest.\@not_even\here.com (-)> says...
 ... 
> now... the enlightening portion of this message! :)
> 
> The below code will do everything you need:
> 
> #!/usr/bin/perl
> 
> $header = '';

Initialized but not used.

> $body = '';
> 
> while (<>)    # Get headers
>       {
> 
>       last if /^$/;
>       ($field, $value) = /^(\S*)\s*(.*)/;
>       if (length($field) > 1) { $fields{$field} = $value; }
>       else { $fields{$field} .= " $value"; }

Please enlighten about this portion of this code.  "If the name of the 
header is more than one character long, use it as the key for the value 
of the header.  Otherwise [is it then just a ':'?] concatenate a space 
and the value to the existing value (if any)."  Will this do everything 
needed, such as multiple addresses?  Hmmm...

Could you possibly have had a different condition in mind, along the 
lines of:
        if (!exists $fields{$field}) ...

Could you possibly have tested this code before posting it for the world 
to see?

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


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

Date: Sat, 18 Jul 1998 11:17:53 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Reading in an email message into a Perl program
Message-Id: <1dcczbk.9nu5ii1gqietcN@bay2-83.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> In article <35b0a027.365057467@news2.cais.com> on Sat, 18 Jul 1998 
> 13:24:45 GMT, root.noharvest.\@not_even\here.com (-) 
> <root.noharvest.\@not_even\here.com (-)> says...
> ... 
> > now... the enlightening portion of this message! :)
> > 
> > The below code will do everything you need:
> > 
> > #!/usr/bin/perl
> > 
> > $header = '';
> 
> Initialized but not used.
> 
> > $body = '';
> > 
> > while (<>)    # Get headers
> >       {
> > 
> >       last if /^$/;
> >       ($field, $value) = /^(\S*)\s*(.*)/;
> >       if (length($field) > 1) { $fields{$field} = $value; }
> >       else { $fields{$field} .= " $value"; }
> 
> Please enlighten about this portion of this code.  "If the name of the
> header is more than one character long, use it as the key for the value
> of the header.  Otherwise [is it then just a ':'?] concatenate a space
> and the value to the existing value (if any)."  Will this do everything
> needed, such as multiple addresses?  Hmmm...

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.

Even if it did work properly, the multiline headers would be slightly
munged, as newlines would be replaced with spaces.

> Could you possibly have had a different condition in mind, along the 
> lines of:
>         if (!exists $fields{$field}) ...

His condition did make sense for what he was trying to do.  I missed the
other problem, which your text above revealed.  Some headers appear more
than once, such as 'Received:', but his script will only save the last
occurence.

Here is code that fixes both of these problems.  A header which appears
more than once gets a reference to a list.

Also, if by chance the first line begins with whitespace, the rest of
the line will appear in the hash under the key 'OOPS'.


$prevfield = 'OOPS';
while (<>) {
    last if /^$/;
    ($field, $value) = /^(\S*)\s*(.*)/;
    if (length $field) {                   # is this line a new field?
        if (exists $fields{$field}) {      # repeat occurence of field?
            $fields{$field} = [ $fields{$field}, $value ];
        } else {
            $fields{$field} = $value;
        }
        $prevfield = $field;               # save field name
    } else {
        (ref $fields{$prevfield} ?         # is value a ref (to array)?
         $fields{$prevfield}[-1] :         # append to last element
         $fields{$prevfield}               # append directly to value
        ) .= "\n$value";
    }
}

> Could you possibly have tested this code before posting it for the world
> to see?

I think we can assume he didn't.  It was a good starting point, although
not quite ready for posting.

-- 
 _ / '  _      /         - 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: Sat, 18 Jul 1998 13:48:00 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Remote login question
Message-Id: <35b0a645.366599095@news2.cais.com>

eharley@pacbell.net (Eric Harley) Said this:

>> Is there a way to login  on a remote machine thru perl 
>> apart from telnet and rsh?
>
>Is there a way to login on a remote machine thru the shell apart from
>telnet and rsh?
>

Is there a way to login on a remote machine apart from the shell 

is there a way to login apart from a remote machine?

is there a way apart from login?

Is there?

Is?

Is there a way to login on a remote machine apart from the user?

Can I run perl on my toaster?



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

Date: Sat, 18 Jul 1998 11:17:56 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: string manipulation, newbie question
Message-Id: <1dcd0jd.19pgydx1jjcmizN@bay2-83.quincy.ziplink.net>

Rick Harrison <rick@harrison.net> wrote:

> I have a bilingual dictionary file that is formatted like this...
> 
> vial : hettuglas
> vibration : titringur
> victim : tj&oacute;n&thorn;oli
> 
> What's the most efficient way to get a string from any line of this
> file that consists only of the part before the colon?

How about split?

($lang1, $lang2) = split /\s*:\s*/, $_;
 
> Also, is it better (with regard to conservation of web server resources)
> to suck the whole file into an array before combing through it to
> find pattern matches, or better to pull one line at a time from the
> disk file?

I guess that depends which resources you're most interested in
conserving.  If you're worried about memory, you probably don't want to
slurp in the whole file.  If you're worried about time, it's probably
more efficient to read the whole file in at once.  It also depends what
you're going to do with the lines once you read them in.  Are you
searching for a single specific line?  Do you need to make use of all
the lines?  You'll have to figure out which solution best fits your
needs.

-- 
 _ / '  _      /         - 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: Sat, 18 Jul 1998 08:47:38 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Indra Rosadi <rosadi@students.uiuc.edu>
Subject: Re: upload in CGI perl
Message-Id: <35B0C39A.CC89FF54@sirius.com>

Indra Rosadi wrote:
> 
> Hi,
> I am just wondering if somebody can give me a small example about
> uploading files in CGI perl.. I keep getting stuck in this problem..
> Thanks a bunch..
> 
> Indra

Take a look at CGI.pm 

http://www-genome.wi.mit.edu/ftp/pub/software/WWW/

follow the link to "more script examples" and you will
find working examples of file upload with source code.

HTH -- Jim Bowlin


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

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

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