[9293] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2888 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 17 02:07:42 1998

Date: Tue, 16 Jun 98 23:00:26 -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           Tue, 16 Jun 1998     Volume: 8 Number: 2888

Today's topics:
    Re: $a: numeric or NOT ? (Ronald J Kimball)
        Can't use subscript on split - what split? (Peter Scott)
    Re: Can't use subscript on split - what split? (Tad McClellan)
    Re: Can't use subscript on split - what split? (Ronald J Kimball)
    Re: Can't use subscript on split - what split? <uri@sysarch.com>
    Re: getting first letter of a string (Ronald J Kimball)
    Re: grep question (Tad McClellan)
    Re: htpasswd in perl? <psdspss@execpc.com>
    Re: Input type="file" luong@my-dejanews.com
    Re: Loop / Parsing Newbie Question (Patrick Timmins)
    Re: More efficient search - binary search?? <uri@sysarch.com>
    Re: More efficient search - binary search?? (Matt Knecht)
    Re: Multiple $ENV{PATH} entries on Win NT (Larry Rosler)
    Re: Perl Cmd line - Help (Tad McClellan)
    Re: Perl Contract Programmer Available (Tad McClellan)
        Placing variables in system calls <wesley.posvar@worldnet.att.net>
        Q: grep/map and regex recompilation <uri@sysarch.com>
    Re: Reading in multiple lines from file--elegant soluti (Matt Knecht)
    Re: Reading in multiple lines from file--elegant soluti (Larry Rosler)
    Re: Reading in multiple lines from file--elegant soluti <danboo@negia.net>
        Referring to Another Computer (Larry Rosler)
    Re: Returning references to my variables - Safe? (Larry Rosler)
    Re: Sending mail, can I set the $from ? <*@qz.to>
    Re: simple expression matching problem (Tad McClellan)
        Win32:internet Ftp file attr (Tze Weng Foong)
    Re: Windows95, Perl-32 and Personal Web Server (PWS) luong@my-dejanews.com
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Jun 1998 00:37:57 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: $a: numeric or NOT ?
Message-Id: <1daqr6b.nz8r3xglbmtuN@bay1-114.quincy.ziplink.net>

Keith Thompson <kst@king.cts.com> wrote:

> I couldn't find any mention of this issue in the Perl documentation;
> perhaps it should be mentioned in perltrap.

It's in Programming Perl, but not the standard documentation.  :-(

Programming Perl, page 39:

   The underscore only works within literal numbers specified in
   your program, not for strings functioning as numbers or data
   read in from elsewhere.

-- 
 _ / '  _      /         - 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: 16 Jun 1998 21:14:56 GMT
From: psf@euclid.jpl.nasa.gov (Peter Scott)
Subject: Can't use subscript on split - what split?
Message-Id: <6m6n8g$j6n@netline.jpl.nasa.gov>

Encountered this when I forgot a pair of parentheses (abbreviated example):

	print qw(JAN FEB)[1];

Can't use subscript on split at - line 1, near "1]"

I would love to know how Perl interpreted this as a split...

-- 
This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
brain on news.  Any questions?   |  (psf@euclid.jpl.nasa.gov)

Disclaimer:  These comments are the personal opinions of the author, and 
have not been adopted, authorized, ratified, or approved by JPL.


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

Date: Tue, 16 Jun 1998 22:33:10 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Can't use subscript on split - what split?
Message-Id: <mdd7m6.bba.ln@localhost>

Peter Scott (psf@euclid.jpl.nasa.gov) wrote:
: Encountered this when I forgot a pair of parentheses (abbreviated example):

: 	print qw(JAN FEB)[1];

: Can't use subscript on split at - line 1, near "1]"

: I would love to know how Perl interpreted this as a split...


   You would huh?


   Well about 20 seconds was what it took to find the section
   about qw() in the fine Perl documentation that nobody will
   read (perlop), where it says:


-------------------
=item qw/STRING/

Returns a list of the words extracted out of STRING, using embedded
whitespace as the word delimiters.  It is exactly equivalent to

    split(' ', q/STRING/);
-------------------


   So I'm figuring that that is how Perl interpreted that as a split...

   ;-)


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


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

Date: Wed, 17 Jun 1998 00:38:00 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Can't use subscript on split - what split?
Message-Id: <1daqrda.kppdm519h8xfkN@bay1-114.quincy.ziplink.net>

Peter Scott <psf@euclid.jpl.nasa.gov> wrote:

> Encountered this when I forgot a pair of parentheses (abbreviated example):
> 
>   print qw(JAN FEB)[1];
> 
> Can't use subscript on split at - line 1, near "1]"
> 
> I would love to know how Perl interpreted this as a split...

I hope this won't be too shocking to you.  It comes directly from the
documentation for perlop.

  qw/STRING/  

    Returns a list of the words extracted out of STRING, using
    embedded whitespace as the word delimiters.  It is exactly
    equivalent to

        split(' ', q/STRING/);



What you meant to write was

print +(qw(JAN FEB))[1];

-- 
 _ / '  _      /         - 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: 17 Jun 1998 00:38:22 -0400
From: Uri Guttman <uri@sysarch.com>
To: psf@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: Can't use subscript on split - what split?
Message-Id: <x7wwagej7l.fsf@sysarch.com>

>>>>> "PS" == Peter Scott <psf@euclid.jpl.nasa.gov> writes:

  PS> Encountered this when I forgot a pair of parentheses (abbreviated
  PS> example): print qw(JAN FEB)[1];

  PS> Can't use subscript on split at - line 1, near "1]"

  PS> I would love to know how Perl interpreted this as a split...

wouldn't we all. i learned how this happens from an oldert thread about
strange error message on the command line and this was one of them.

it seems that qw(blah) is actually translated into split( ' ', q(blah))
very early on so the error comes from the implied split and not qw().

confusing, eh?

hth,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----  8 Years of Perl Experience, Available Immediately
uri@sysarch.com  ---------  Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net  --------  http://www.northernlight.com


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

Date: Wed, 17 Jun 1998 00:38:02 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: getting first letter of a string
Message-Id: <1daqrra.up99h21pdavp5N@bay1-114.quincy.ziplink.net>

Ritche Macalaguim <ritche@san.rr.com> wrote:

> How can I get the first letter of a string in Perl?

($first) = $string =~ /([a-z])/i;

;-)

-- 
 _ / '  _      /         - 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: Tue, 16 Jun 1998 22:24:32 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: grep question
Message-Id: <gtc7m6.o0a.ln@localhost>

Eli the Bearded (*@qz.to) wrote:


: chmod($input) unless you really want a \n in your search
  ^^^^^

   s/chmod/chomp/;  # ...and they look alike too!


: pattern -- then probably you have some sort of PATH/permission/current-
: working-directory problem.


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


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

Date: Tue, 16 Jun 1998 22:54:02 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: htpasswd in perl?
Message-Id: <6m7e57$3r4@newsops.execpc.com>

Douglas Potts wrote:

> Need help with a script I am working on that will create passwords the
> same as htpasswd executable.
>
> My confusion come in with how to fire-off the crypt function to include
> the proper salt.
>
> And is that all I need to figure out???
>
> Thanks,
>
> Doug
> doug@zmark.com

  First two characters of password in the system are 'salt' of encryption.

Get the password ===> System password
Substring and get the first two chars of password; ==> Salt

Invoke the crypt function as follows
crypt plaintext salt ==> entered password(encrypted)

Then you can compare system password and entered password for validity.

hope that helps
Deva



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

Date: Wed, 17 Jun 1998 03:51:43 GMT
From: luong@my-dejanews.com
Subject: Re: Input type="file"
Message-Id: <6m7egf$nv0$1@nnrp1.dejanews.com>

In article <6m4pkk$3i5$1@news01.deltanet.com>,
  "Andrew Arrow" <andrew@deltanet.com> wrote:
>
> Hi all,
>
> Can anyone tell me where to find information on the:
>
> <input type="file" name="whatever">
>
> It makes a nice text field with a "browse" button next to it, but how do I
> go about reading the file the user selects?
>
> Say the user selects "c:\textfile.txt"  How do I read that file off the
> user's hard drive from my web application?
>
> Please respond to andrew@deltanet.com
>
> Thanks!
>
>
1. for the Theory: RFC 1867
2. for instant use: CGI.pm
3. for development: 1 + Perl 5

I think after reading the RFC 1867, you will find that reading the file
contents uploaded by users is as easy as the way you've been programming with
Perl so far. Pham Thuc Truong Luong

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 17 Jun 1998 02:42:03 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Loop / Parsing Newbie Question
Message-Id: <6m7ads$il4$1@nnrp1.dejanews.com>

In article <3586DAB6.91334AE3@ball.com>,
  Tim Olson <tolson@ball.com> wrote:
>
>
> --------------40475842D36DA0CBF928D077
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> I am relatively new to Perl and the newsgroup.  My question involves
> searching through an ASCII text file for certain matches.  A section of
> the file to be searched is shown below:
>
> %NAME KJ888
>
>    %SYMB REF_6PIN default
>         gate1 GND V_OUT TEMP TRIM VIN O/P_SEL
> %VEND AD494OP/SSS default
>  %INTERNAL 5962-9463601MPA default
>         %COMP   nc_gate 1
>                 nc_gate 7
>                 gate1 4 6 3 5 2 8
>  %TOPCELL DIP8                <---------------------
>  %DESC "IC, AD780"
>         %CPROP  ALTSHAPE=DIP8S
>         %CPROP  matspec=DESC 5962-94636
>         %CPROP  cage=14933
>         %CPROP  notes=F7
>         %CPROP  Cellname=DIP8 <------------------
>         %CPROP  Part no=AD780
>         %CPROP  voltage =
>         %CPROP  Component tol=0.2%
>
> I need to see if the properties following "%TOPCELL and %CPROP
> Cellname" match (pointed to above).  I have figured this out, but it
> gets more complicated it there are multiple %VEND declarations in one
> file.  There is a different "%TOPCELL and %CPROP  Cellname" under each
> declaration that need to be compared and logged to a file.  How do I
> loop through each %VEND declaration, one at a time?  I have tried the
[snip]

If I understand you, what you see below seems to work. Of course, you'd have
to print out to a file handle in the format that you want, but you get the
idea. All of this is assuming that each %VEND has only one %TOPCELL and only
one %CPROP Cellname.

while (<>) {
	if (/^%VEND (.*)\s*$/) { $vend = $1 }
	if (/\s+%TOPCELL (.*)\s*$/) { $topcell = $1 }
	if (/\s+%CPROP  Cellname=(.*)\s*$/) {
		$cellname = $1;
		if ($cellname eq $topcell) {
			print "%TOPCELL and Cellname are both $cellname for
%VEND $vend\n";
		} else {
			print "%TOPCELL and Cellname are different for %VEND
$vend\n";
		}
	}
}

Hope that helps. The two print lines above are wrapping. They should each be
on one line only.

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 17 Jun 1998 00:29:45 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: More efficient search - binary search??
Message-Id: <x7zpfcejly.fsf@sysarch.com>

>>>>> "MK" == Matt Knecht <hex@voicenet.com> writes:

  MK> T. Ames <ames0009@tc.umn.edu> wrote:
  MK> @numbers = (1 .. 5);

  MK> for $keyword (4 .. 6) { print "Got $keyword\n" if grep { $keyword
  MK> == $_ } @numbers or die "Fooey!\n"; }


either of you ever hear of hashes? this is the prefered perl method for
the general question:

is foo in the list.

no loops, no flags, no problem!

(having hash keys as numbers is a bit simplistic but this is the
original poster's code)

$keyword = 3;
@numbers = ("1","2","3","4","5");

@is_a_keyword{ @numbers } = (1) x @numbers ;

print "$keyword is a number\n" if $is_a_keyword{ $keyword } ;

done!!




  MK> Not to drift onto another topic, but...

  MK> When I first wrote this, I had no idea if grep would be
  MK> interpreted in a scalar or list context (Having made this mistake
  MK> before, I'm quite wary of it).  I tried to find out through
  MK> perlsyn; I couldn't find it.  But this code snippet explained it
  MK> quite nicely to me:

  MK> print "list context\n" if is_list(); print "scalar context\n" if
  MK> !is_list();

  MK> sub is_list { wantarray ? 1 : 0 }

  MK> When run, I get "scalar context", so there was no need to say
  MK> 'scalar grep ...'.  Nifty, huh? :)


no. what are you testing anyway? the context of 'if'? 


re: grep, read camel2 p. 178. this is from the perlfun manpage.


Evaluates the BLOCK or EXPR for each element of LIST (locally setting $_
to each element) and returns the list value consisting of those elements
for which the expression evaluated to TRUE. In a scalar context, returns
the number of times the expression was TRUE.

hth,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----  8 Years of Perl Experience, Available Immediately
uri@sysarch.com  ---------  Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net  --------  http://www.northernlight.com


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

Date: Wed, 17 Jun 1998 05:45:12 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: More efficient search - binary search??
Message-Id: <IJIh1.28$qF2.150812@news3.voicenet.com>

Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "MK" == Matt Knecht <hex@voicenet.com> writes:
>
>  MK> T. Ames <ames0009@tc.umn.edu> wrote:
>  MK> @numbers = (1 .. 5);
>
>  MK> for $keyword (4 .. 6) { print "Got $keyword\n" if grep { $keyword
>  MK> == $_ } @numbers or die "Fooey!\n"; }
>
>
>either of you ever hear of hashes? this is the prefered perl method for
>the general question:
>
>is foo in the list.

True enough, but sometimes there exists the need to search an array.  I
imagine that's at least part of the reason grep exists.  After all, if
your data best fits into arrays 90% of the time for a particular
problem, building a hash for one quick search is a waste of time and
memory.  Use the right tool for the job.

>no loops, no flags, no problem!

My code contained no flags, no problems, and the for loop was to
demonstrate the behaviour as $keyword changed.  I'm not sure what you're
talking about here.

>  MK> Not to drift onto another topic, but...
>
>  MK> When I first wrote this, I had no idea if grep would be
>  MK> interpreted in a scalar or list context (Having made this mistake
>  MK> before, I'm quite wary of it).  I tried to find out through
>  MK> perlsyn; I couldn't find it.  But this code snippet explained it
>  MK> quite nicely to me:
>
>  MK> print "list context\n" if is_list(); print "scalar context\n" if
>  MK> !is_list();
>
>  MK> sub is_list { wantarray ? 1 : 0 }
>
>  MK> When run, I get "scalar context", so there was no need to say
>  MK> 'scalar grep ...'.  Nifty, huh? :)
>
>
>no. what are you testing anyway? the context of 'if'? 

Yes.  When executing:

function if condition;

I was unsure if 'condition' would be interpreted in a scalar or list
context.  I couldn't find documentation on it anywhere.

>re: grep, read camel2 p. 178. this is from the perlfun manpage.
>
>
>Evaluates the BLOCK or EXPR for each element of LIST (locally setting $_
>to each element) and returns the list value consisting of those elements
>for which the expression evaluated to TRUE. In a scalar context, returns
>the number of times the expression was TRUE.

Yes, I do know where the documentation for grep is.  In fact, it was the
documentation that made me wonder if I was going to get scalar or list
context out of grep.  That fact that the 'condition' happened to be grep
was secondary.  I was only concerned with how a simple statement
with a modifier (if, unless, while, until) influences what context the
EXPR will be called in.  I'd explain it better, but the original code
fragment says it all I think.

>hth,

Hmmm.

-- 
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"


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

Date: Tue, 16 Jun 1998 20:21:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Multiple $ENV{PATH} entries on Win NT
Message-Id: <MPG.ff0d6066d1db5bc989691@nntp.hpl.hp.com>

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

In article <6lp4ja$1v$1@gte1.gte.net>, ehp@gte.net says...
> In article <MPG.fe993ee9cd30cac9896ba@nntp.hpl.hp.com>, lr@hpl.hp.com says...
 ...
> >> Anybody knows how to add more than one? I am on NT Server 4.0, using
> >> ActiveWare's Perl for Windows, Build 315.
> LR>
> LR>Use semicolon.  Surprise!!!
> 
> Perhaps more precisely, use the $^O variable to test for the OS and if it
> contains "Win32", use a semicolon, else use the colon (simply assuming unix
> platform if not a Win32 platform).

If you're going to respond "Perhaps more precisely", you might as well be
precise, or at least correct.

On my Windows NT system's perl (from MKS), the script

perl -we "print $^O, qq{\n}"

produces

Windows_NT

On my Windows 95 system, the same perl processor and script produces

Windows_95

Perhaps I would trust a test for /\bWin/i (or perhaps not).

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Tue, 16 Jun 1998 13:37:11 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl Cmd line - Help
Message-Id: <n0e6m6.i58.ln@localhost>

Sudhakar (sudhakar@ccs.neu.edu) wrote:
: I type this in the unix command line to replace a "char *VERSION=10"
: Its not replacing. Why? any help...?

: perl -ne '$tm = time(); s/(.*)(VERSION=)(.*)$/$1$2$tm/g;' root.c.tmp


   I don't see that your one-liner produces any output...

   Try -p instead of -n


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


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

Date: Tue, 16 Jun 1998 13:40:33 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl Contract Programmer Available
Message-Id: <17e6m6.i58.ln@localhost>

Michael Fuhr (mfuhr@dimensional.com) wrote:
: Mr James <71022.3700@CompuServe.COM> writes:

: > (P.S. Yes, I've already tried posting this in the jobs groups.)

: That's no excuse for posting in a group where it doesn't belong.


Some folks might get the impression that the original poster is
desperate.

Not a good impression to be conveying to the entire World ...


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


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

Date: Tue, 16 Jun 1998 10:30:45 -0700
From: Wesley Posvar <wesley.posvar@worldnet.att.net>
Subject: Placing variables in system calls
Message-Id: <6m7bas$ks3@bgtnsc03.worldnet.att.net>

I am new to Perl, and was wondering, if there is way to place variables
into system calls with qx. Everything I've tried doesn't work the way I
intended.


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

Date: 17 Jun 1998 00:35:05 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Q: grep/map and regex recompilation
Message-Id: <x7yauwejd2.fsf@sysarch.com>


when you use a regex in the expression of a map or grep, does the regex
get recompiled for each internal iteration? or does it keep the complete
expression and compiled regex and just apply it to each $_ in the loop?

technically it should recompile since the regex expression could be
changed in the expression from iteration to iteration.


i know about /o but a friend's question about matching multiple regexes
brought up this point.  i know well the eval regex loop technique to
test multiple regexes. i am curious if this is a way around that?

the more i think about it, my answer above should be right and this is
not a workaround.


uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----  8 Years of Perl Experience, Available Immediately
uri@sysarch.com  ---------  Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net  --------  http://www.northernlight.com


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

Date: Wed, 17 Jun 1998 02:05:05 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Reading in multiple lines from file--elegant solution?
Message-Id: <lvFh1.6$qF2.37772@news3.voicenet.com>

Larry Rosler <lr@hpl.hp.com> wrote:
>> 	last and print "File didn't terminate with '//'!\n" if eof(FH);
>This 'print' will never be executed.  Preferable would be:
> 	print "File didn't terminate with '//'!\n" and last if eof(FH);
>or (better):
>  	print("File didn't terminate with '//'!\n"), last if eof(FH);

Thanks for the tip, but having seen the _much_ more useful example of
setting $/ I don't think I'll be using that particular snippet in any of
my code anymore.

I do need ask ask why it's better to use a comma instead of 'and' there.
What's the difference?

-- 
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"


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

Date: Tue, 16 Jun 1998 19:13:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reading in multiple lines from file--elegant solution?
Message-Id: <MPG.ff0c640fbf76ee198968f@nntp.hpl.hp.com>

In article <lvFh1.6$qF2.37772@news3.voicenet.com>, hex@voicenet.com 
says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> >> 	last and print "File didn't terminate with '//'!\n" if eof(FH);
> >This 'print' will never be executed.  Preferable would be:
> > 	print "File didn't terminate with '//'!\n" and last if eof(FH);
> >or (better):
> >  	print("File didn't terminate with '//'!\n"), last if eof(FH);
> 
> Thanks for the tip, but having seen the _much_ more useful example of
> setting $/ I don't think I'll be using that particular snippet in any of
> my code anymore.

Of course.

> I do need ask ask why it's better to use a comma instead of 'and' there.
> What's the difference?

I'm glad you asked.  (More accurately, took the bait. :-)

The comma designates sequence.  The second expression is evaluated after 
the first.

The 'and' designates consequence.  The second expression is evaluated 
only if the first operation succeeds (returns TRUE).  As 'print' will 
return TRUE "all the time" (barring mishaps such as writing to a full 
file system), the test is specious.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 17 Jun 1998 00:49:14 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Reading in multiple lines from file--elegant solution?
Message-Id: <35874ACA.6B032E40@negia.net>

sylvia@lsbio.com wrote:
> 
> Hello,
> 
[snip]
> 
> I've done quite a bit of parsing through a file on a line by line basis, and
> that works great most of the time.  But, is there any way I could tell perl
> 
> "read into x until you hit a // "

sure, this is what $/ is for. normally it is set to "\n" but you are
free to change it to "//" if you like. see the perlvar manpage for
more details.

$/ = '//';

while (<DATA>) {
  chomp;              # remove $/ from end
  next unless /\S/;   # or whatever criteria meets your needs
  print "$. $_";      # do something relevant
}

__END__
//
value1: abcdef
value2: arwererbcdef
value3: aweroiupoiwuer
        rweqarsfaserawer
        rweruiwoufoaeu
//
value1: abcdwerweef
value2: abcderweef
value3: aweroiupoiwuer
        rweqarsfaserawer
        rweruiwoufoaeu
//

cheers,

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: Tue, 16 Jun 1998 19:21:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Referring to Another Computer
Message-Id: <MPG.ff0c7ebda1ed548989690@nntp.hpl.hp.com>

> Date: Tue, 16 Jun 1998 18:00:24 -0400
> To: lr@hpl.hp.com
> From: "Caleb J. Newville" <webmaster@briefcasegolf.com>
> Subject: Referring to Another Computer
> 
> I am new to perl and found an auto-responder for NT. I have the following
> line:
> 
> 	$mailprog = '/usr/bin/sendmail';
> 
> and I need it to go to 'yoda.fdt.net/usr/bin/sendmail' Would you happen to
> know how to do this?

It is possible that I missed your posting this query to comp.lang.perl.misc .
In any case, your sending me a private inquiry like this (presumably having
found my name by reading the newsgroup) is very inappropriate.

Perhaps someone else reading the newsgroup will choose to reply to your 
inquiry.  I will not.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Tue, 16 Jun 1998 18:58:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Returning references to my variables - Safe?
Message-Id: <MPG.ff0c28044a1779998968e@nntp.hpl.hp.com>

In article <3586BF28.8A5B0193@sdrc.com>, aaron.becher@sdrc.com says...
> This is a multi-part message in MIME format.
> --------------887E10A8EC2E90D0BE3BF28F
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

Using MIME encoding lengthens and uglifies your message, and may cause 
some readers to ignore it completely.

> I wrote a subroutine in Perl that, given 2 arrays (@a,@b), gives me back
> 3 arrays (@onlya,@onlyb,@both). But I'm not 100% sure that the _way_ I
> return the 3 arrays from the subroutine is safe:
> 
> The subroutine returns references to arrays that are declared with "my"
> _in_ the subroutine.
> 
> I'm going to attach my Arrays.pl file. Can anybody tell me if this will
> always work? It worked just fine in a test-harness script. But I'm a
> little worried that maybe I'm just sneaking pass the garbage collector.
> 
> Thanks!
> Aaron Becher
> aaron.becher@sdrc.com
 ...<lots of code snipped without being read>

In C, pointers to automatic variables (which are allocated on the 
subroutine's calling stack) are invalid as soon as the subroutine is 
exited.  In Perl, references to 'my' variables are guaranteed valid; the 
variables are not garbage collected as long as any references are in 
scope.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: 17 Jun 1998 03:13:58 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Sending mail, can I set the $from ?
Message-Id: <eli$9806162305@qz.little-neck.ny.us>

In comp.lang.perl.misc, Paul Rolfe <prolfe@southwest.com.au> wrote:
> On Mon, 15 Jun 1998 13:50:54 -0400, dolph6@jersey.net (Christopher
> Soeffing) wrote:
(tries to use /bin/mail)
> You can reference sendmail directly:
> 
> open (mail,"|/usr/sbin/sendmail -f$from $to");

Yes, but with the caveat that you now have to generate your own headers.

	print mail <<EOH;
To: $to
From: $from
Subject: $subject

EOH

Also, sendmail is sometimes in other locations, such as /usr/lib and
/usr/bin.

> Which will allow you to set the from address.  It will place a warning
> in the "hidden" headers about this being a possible fake message,

Unless you are member of class 't' and thus trusted.

Elijah
------
/usr/bin/sendmail is often a sendmail compatible front end to something else


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

Date: Tue, 16 Jun 1998 13:42:50 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: simple expression matching problem
Message-Id: <abe6m6.i58.ln@localhost>

Jonathan Feinberg (jdf@pobox.com) wrote:
: gulam.faruque@csfp.co.uk writes:

: > I'm trying to write a replace script in perl.
: > for example. scriptname filename string1 string2
: > 
: > This will search for string1 in filename and replace it with
: > string2 and print the results to the console.

: You don't need to write a script for that.

:    C:\> perl -pe "s/string1/string2/g" filename

: > The problem is string1 and string2 can contain any characters such as \.*[]{}
: > I dont want the person running the script to enter a \  before each special
: > character.

: You want the quotemeta operator.

:    C:\> perldoc -f quotemeta
:    C:\> perldoc perlre


   Or just:

   perl -pe "s/\Qstring1/string2/g" filename
               ^^
               ^^

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


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

Date: Wed, 17 Jun 1998 04:53:39 GMT
From: tfoong-not@patrick.com.au (Tze Weng Foong)
Subject: Win32:internet Ftp file attr
Message-Id: <6m7kpq$lu$1@merki.connect.com.au>

Hello Perlers,

I was wondering if any one knew what the file attr values 
returned by the  FTP->List("*.*", 2) command were.

I am using dada's Win32:internet modules. The 
documentation tells me that I can get the attributes but 
It does not seem to say what the values mean.
I get the values back of 16 for a directory and 128 
for a file but is there documentation or has someone
worked out what the attributes should return for what?

Thanks in advance.

Please send replies to my email address if posible.
Other wise I will check on this news group.

my email address is    tfoong@patrick.com.au

Regards.
Tze Weng Foong


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

Date: Wed, 17 Jun 1998 04:03:42 GMT
From: luong@my-dejanews.com
Subject: Re: Windows95, Perl-32 and Personal Web Server (PWS)
Message-Id: <6m7f6v$oor$1@nnrp1.dejanews.com>

In article <3585F139.A79ECB45@sirius.com>,
  bowlin@sirius.com wrote:
>
> Pete Sattler wrote:
> >
> > I am trying to set-up an environment on Windows 95 for developing web
> > applications.  I have installed ActiveState's Perl for Win32 (build 316)
>                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Hi,
After istalling the MS Personal Web Server on your Windows 95 machine, the
server will act as a system service. To configure the perl environment for MWS
Try this:
- Run regedit
- HKEY_LOCAL_MACHINE
- SYSTEM
- CurrentControlSet
- Services
- Something I don't remembers (but will clearly suggest that it is about MWS)
- Parameters
- Script Map
- Add New String Value (.pl and the location to perl.exe)
  It might looks like this : .pl C:\perl\perl.exe %s %s
- Reboot your computer for the new settings to take affect
- Now locate your .pl programs in scripts directories (excucutable).
- They should work.

Goodluck
Pham Thuc Truong Luong

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2888
**************************************

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