[6375] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 997 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 23 18:17:10 1997

Date: Sun, 23 Feb 97 15:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 23 Feb 1997     Volume: 7 Number: 997

Today's topics:
     compiling perl (Hanspeter Niederstrasser '98)
     Re: debugger question <rootbeer@teleport.com>
     Re: forwarding a mail message with PERL (Neil S. Briscoe)
     Re: futur de perl et java-script (Kevin Buhr)
     Re: futur de perl et java-script <tchrist@mox.perl.com>
     how long before I can put down the books? (Richard Morin)
     Re: how long before I can put down the books? (Nathan V. Patwardhan)
     Re: how long before I can put down the books? (brian d foy)
     How to control attempt to download <valeri@cyber2.servtech.com>
     Re: How to spam - legitimately (Terry Carroll)
     Re: How to spam - legitimately <miles@gnu.ai.mit.edu>
     Re: HOW TO SPLIT A SIMPLE STRING <tom@geronimo.uit.no>
     Re: Nested if in compound if statement <tom@geronimo.uit.no>
     Re: Opening a file to an exact location HELP?! <rootbeer@teleport.com>
     Re: Perl - Do I want to use it????? <sajaa@sn.no>
     Re: PERL / OLE <billc@tibinc.com>
     Random Temp File in Perl 5.002 (Mark Thompson)
     Re: Record Length <rootbeer@teleport.com>
     Re: simple new question! (Kevin Buhr)
     Re: simple new question! <tchrist@mox.perl.com>
     Re: split() matches, but returns no values <billc@tibinc.com>
     Re: Strange pack/unpack behavior <rootbeer@teleport.com>
     Re: syntax error <rootbeer@teleport.com>
     Time-efficiency question (Sara Young)
     Username / Password change program (Mark Thompson)
     Re: Username / Password change program (Nathan V. Patwardhan)
     WEB DEVELOPER'S VIRTUAL LIBRARY is Top Dog's Site Of Th (Rich)
     Re: WEB DEVELOPER'S VIRTUAL LIBRARY is Top Dog's Site O (Mike Heins)
     Win95 Build 110: `cd` fails in install (Charles Henkel)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 23 Feb 1997 21:33:49 GMT
From: nieder@princeton.edu (Hanspeter Niederstrasser '98)
Subject: compiling perl
Message-Id: <5eqd3t$298@cnn.Princeton.EDU>

Is there a way to compile (not interpret) a perl script into a win32 .exe?  I 
don't need to know about perl5 from Activeware<sic>  I got it and runs fine, 
I'm just looking for a way to make scripts that were called from my server run 
a little faster and cleaner than having the whole perl.exe run each time.

About 6 months ago I saw someone post a similar question here, and got a 
negative, and the last week or so, after reading this ng and looking through 
basically every perl page I could find, have not seen either a negative or 
affirmative to this question.


-- 
+-----------------------------------+-----------------------------------+
| Hanspeter Niederstrasser          | nieder@phoenix.princeton.edu      |
| Princeton University '98          | http://www.princeton.edu/~nieder/ |
+-----------------------------------+-----------------------------------+
| The appearance of the concept of good and evil, interpreted by man as |
| his expulsion from Paradise, was probably a molecular disease that    |
| turned out to be evolution.       - E. Zuckerkandl and L. Pauling     |
+-----------------------------------+-----------------------------------+



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

Date: Sun, 23 Feb 1997 13:40:12 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike Bartolone 5-4266 <bartolonem@med.ge.com>
Subject: Re: debugger question
Message-Id: <Pine.GSO.3.95q.970223133612.18178H-100000@kelly.teleport.com>

On Fri, 21 Feb 1997, Mike Bartolone 5-4266 wrote:

> If any of you use the built-in perl debugger, can you tell me if there
> is a command to list the current values of all of the currently defined
> variables? 

Yes, there is, if your version of the debugger is the same as mine. On
mine, the 'h' command will tell you about many commands for the debugger. 
Hint: Since some debugger commands (such as 'h') can produce lengthy
output, you may want to use a pager (such as 'more' or 'less') to read the
output. Use the vertical bar before a debugger command if you want to send
its output to your pager, as in '|h'. 

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 23 Feb 1997 21:51:56 GMT
From: neilb@zetnet.co.uk (Neil S. Briscoe)
Subject: Re: forwarding a mail message with PERL
Message-Id: <memo.970223215030.10567A@zetnet.co.uk>

In article <330DF331.1443@fys.kuleuven.ac.be>,
geert.nijs@fys.kuleuven.ac.be (Geert Nijs) wrote:

> Hi all,
>
> I want to forward a mail message to another account using
perl.
>
> The mail arrives at a Linux account and is transfered to
> a PERL Script. (this was easy).
>
> This PERL script can examine the mail by reading STDIN, but
this is
> not necessary. What I want to do is the following:
>   just forward everything (that can be read from STDIN) to
>   another e-mail account (so: without changing any of the
headers)
>
> I already tried the following:
>    I save STDIN to a file and send this file to an account
xxx using
>    the mail program, but this has the adverse affect that
the headers
>    and any attachements of the original message get lost,
because
>    fundamently I just send a file to account xxx.
>
> Can you still follow ? I hope you can help me.
>
> Hoping to hear from you soon,
>

Get libnet module from CPAN - it contains, amongst other
things, Net::SMTP which will allow you to do whatever you
want.

Regards
Neil



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

Date: 23 Feb 1997 14:54:36 -0559
From: buhr@stat.wisc.edu (Kevin Buhr)
Subject: Re: futur de perl et java-script
Message-Id: <vbabu9b2qgj.fsf@mozart.stat.wisc.edu>

abigail@ny.fnx.com (Abigail) writes:
> 
> ++                            our lex loci hereabouts is that postings
> ++ be in English rendered
> 
> *ploink*
> 
> I've always seen Usenet as being a international medium. Too bad there
> are still arrogant people who think it's a US-only thingy.

It's not a US-only thingy, but most of it is an English-centric
thingy.  You can stomp around indignantly to your heart's content, but
if you want to reach the largest audience possible with your question
without waiting for someone to post an intermediate translation (and
most of the time, someone will), you'll want to post in English.

Kevin <buhr@stat.wisc.edu>


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

Date: 23 Feb 1997 21:09:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: futur de perl et java-script
Message-Id: <5eqbmr$3p0$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    abigail@ny.fnx.com writes:
:On 21 Feb 1997 17:57:30 GMT, Tom Christiansen wrote in comp.lang.perl.misc:
:
:++                            our lex loci hereabouts is that postings
:++ be in English rendered
:
:*ploink*
:
:I've always seen Usenet as being a international medium. Too bad there
:are still arrogant people who think it's a US-only thingy.

The net is certainly international.  But as I said in the cited posting,
apart for those newsgroups in the national hierarchies and the odd
soc.culture group, the language of exchange on Usenet is English.  Do you
deny that?  English is the world's #1 second language, which means that,
even apart from national demographics, that postings in English will
reach the most people.  

If you really want this to become a Newsgroup of Babel, then I'd be sehr
feliz to continue my polyglot postings that quasi no one can legere.  :-)  
How many rec.humor.funny postings to see in Swahili?  Ever wonder why?
Because the goal of Usenet is communication.  If you aren't understood,
then you've failed.  Why do you think there exist perl groups like
de.comp.lang.perl?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "A pithy saying is worth its weight in gold." --Larry Wall


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

Date: 23 Feb 1997 19:36:34 GMT
From: qnc496@joanrich.kite.ml.org (Richard Morin)
Subject: how long before I can put down the books?
Message-Id: <5eq682$4dt@nr1.toronto.istar.net>

Hi folks, Sorry for the non-specific question, but I'm kinda 
curious about something.  How long before most folks felt even
slightly proficient and could take the llama and camel books 
off the desk beside them?  I feel kinda lame havin' to go back
to them all the time.  Does everyone do this?
Rich M
qnc496@durhamnews.net


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

Date: 23 Feb 1997 20:43:02 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: how long before I can put down the books?
Message-Id: <5eqa4m$3n7@fridge-nf0.shore.net>

Richard Morin (qnc496@joanrich.kite.ml.org) wrote:

: slightly proficient and could take the llama and camel books 
: off the desk beside them?  I feel kinda lame havin' to go back
: to them all the time.  Does everyone do this?

Don't feel bad.  Good programmers refer to documentation when they get
stuck.  Sometimes I'm too cranky (and my eyes are too red) to decipher
Unix manpages, so I check resources on the net or anything from O'Reilly.

--
Nathan V. Patwardhan
nvp@shore.net
"A stitch in time saves nine."


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

Date: Sun, 23 Feb 1997 16:26:21 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: how long before I can put down the books?
Message-Id: <comdog-2302971626210001@nntp.netcruiser>

In article <5eq682$4dt@nr1.toronto.istar.net>, qnc496@durhamnews.net wrote:

> Hi folks, Sorry for the non-specific question, but I'm kinda 
> curious about something.  How long before most folks felt even
> slightly proficient and could take the llama and camel books 
> off the desk beside them?  I feel kinda lame havin' to go back
> to them all the time.  Does everyone do this?

some of us keep one at the office, one at home, one in the breifcase...

be proud that you use the proper resources! certainly you'll quickly
pick up the things that you do a lot, but as you progress you'll think of
new tricks and ways to do things, so you'll still want to read the book.
the Camel is a great reference book, so don't let anyone make you feel
self-conscious for using it. (well, maybe you should only use the quick
reference card during job interviews :)  ).

-- 
brian d foy                              <URL:http://computerdog.com>                       
unsolicited commercial email is not appreciated


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

Date: Sun, 23 Feb 1997 15:36:51 -0500
From: Valeri <valeri@cyber2.servtech.com>
Subject: How to control attempt to download
Message-Id: <3310AA63.3493@cyber2.servtech.com>

Hi perl folks,

Have a question - is it possible to control somehow attempt to download
images or just pages by user from my web site ?

If yes - how to write a perl script to to do this work ?

Thank you for possible help

Valeri


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

Date: Sun, 23 Feb 1997 18:57:33 GMT
From: carroll@tjc.com (Terry Carroll)
Subject: Re: How to spam - legitimately
Message-Id: <331192c1.44849480@samba.rahul.net>

On 22 Feb 1997 05:09:42 GMT, Tom Christiansen <tchrist@mox.perl.com>
wrote:

> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, Valdis Kletnieks <valdis.kletnieks@vt.edu> writes:
>:> All of these emails will be different based on user preferences.
>:Well.. if you have 18,000 different emails, 
>
>Why does this sound wrong to my ear?

Because you haven't noticed the adaption of the English language?

It's pretty common now to hear "email" as a noun.  "eletter" would be an
abomination.


--
Terry Carroll       | "Al Gore is doing for the federal government what
Santa Clara, CA     | he did for the Macarena.  He's removing all the
carroll@tjc.com     | unnecessary steps."
Modell delenda est  |                - Bill Clinton, September 20, 1996


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

Date: 23 Feb 1997 16:21:36 -0500
From: Miles Bader <miles@gnu.ai.mit.edu>
Subject: Re: How to spam - legitimately
Message-Id: <sq4k9nzuskf.fsf@ethanol.gnu.ai.mit.edu>

carroll@tjc.com (Terry Carroll) writes:
> It's pretty common now to hear "email" as a noun.  "eletter" would be an
> abomination.

Every native english speaker I've ever heard use the word `email', treats it
either exactly like `mail' (`send me some email', `I got email'), or uses it
to indicate a single piece of email (`send me an email').  I presume the
latter is used because it's a very commonly needed construction, and easier
to say than `a piece of email' (and as you say, `eletter' sounds really
wierd), but for less common uses, I've always heard the mass-noun usage.

After all, the dominate part of the word's sound is `mail', not `e', and this
must surely be a strong influence on people's bogosity detection circuits...

-Miles
-- 
Miles Bader / miles@gnu.ai.mit.edu / (617) 253-8568
Fast, small, soon; pick any 2.


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

Date: 23 Feb 1997 22:04:07 +0100
From: Tom Grydeland <tom@geronimo.uit.no>
Subject: Re: HOW TO SPLIT A SIMPLE STRING
Message-Id: <ofb7mjz8cag.fsf@geronimo.uit.no>

Bill Cowan <billc@tibinc.com> writes:

> Aron Griffis wrote:
> > > I have a a six character string,
> > > say 012345, that I want to split into three variables, $one, $two, $three
> > > that would then have 01, 23, 45.  The original string has no
> > > delimiters, though.

[...]

> Two others options are substr and unpack functions:

> $s1 = substr($longstring, 0, 2);  # zero-based position
> $s2 = substr($longstring, 3, 2);
                            ^      of course you ment
  $s2 = substr($longstring, 2, 2);

> $s3 = substr($longstring, 5, 2);
                            ^      and
  $s3 = substr($longstring, 4, 2);

> Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143

--
//Tom Grydeland <Tom@nospam.eiscat.no>  delete 'nospam.' to mail me


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

Date: 23 Feb 1997 22:31:35 +0100
From: Tom Grydeland <tom@geronimo.uit.no>
Subject: Re: Nested if in compound if statement
Message-Id: <ofb67zj8b0o.fsf@geronimo.uit.no>

Timothy Shell <tshell@mcs.net> writes:

> I have two segments of code like this that I need to combine:
> 
> 
> Each segment in my actual program seems to work, but I have had no luck
> combining them.
> 
> The program should match a record if the four conditions in segment one
> are met, and then check to see which condition of segment two must be
> met, and then check that condition.

Excuse me? "which condition of segment two must be met"?  "check that
condition"?

If I understand you right, you want to perform different tests
depending on the values of $one and $two.  However, you perform these
tests and throw away the result.  If you want to do something based on
these tests, you must either do it there and then, or save the result
for later.

If you want to nest conditionals, what's wrong with:

undef $res;	# to distinguish from legal results of comparisons below.

if (($a =~ /\balpha\b/) && ($b =~ /\bbeta\b/) && 
		($c =~ /\bgamma\b/) && ($d =~ /\bdelta\b/) ) {

	# matched a record

	if ($one == 1) {
		$res = (dog >= cat);
	}
	elsif ($two == 1) {
		$res = (dog <= cat);
	}
	else {
		$res = (dog == cat);
	}
}
else {
	# whatever, perhaps even touching $res
}

# Use $res for your own purposes
if ($res) {
	# the condition tested above was true
}


> Timothy Shell : tshell@mcs.net

--
//Tom Grydeland <Tom@nospam.eiscat.no>  delete 'nospam.' to mail me


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

Date: Sun, 23 Feb 1997 14:42:38 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Paul J Tomsic <pjtst5+@pitt.edu>
Subject: Re: Opening a file to an exact location HELP?!
Message-Id: <Pine.GSO.3.95q.970223144037.18178K-100000@kelly.teleport.com>

On 23 Feb 1997, Paul J Tomsic wrote:

> I'm having a hard time opening a file and inserting information into an
> exact spot into that file..

That's probably because Unix-type filesystems (and most others, for that
matter) have no concept of lines, and no way to insert new ones. You
probably want to write a modified copy of the file, and then copy it over
the top of the original. But check out perl's -i option in perlrun(1), and
the closely-related $^I in perlvar(1). Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 23 Feb 1997 19:48:17 GMT
From: "Jarle Aasland" <sajaa@sn.no>
Subject: Re: Perl - Do I want to use it?????
Message-Id: <01bc21c2$9ae17490$6918f8c2@jaasland>

I have some very general thoughts on your questions:

I have been in about the same situation as yourself (running NT and IIS,
wanting to learn some CGI/Perl programming). My needs were maybe a little
different, as my company is running a rather large web-service on a
Unix-machine. Therefore, I had no interest in messing around with
Microsoft's PC-plattform tools and techniques.

In my opinion, if you intend to aquire knowledge for general web-publishing
purposes, you should concentrate your efforts learning CGI/Perl-scripting.
I had very little programming experience (a few hours with VB and some more
with Delphi 2.0. The only thing I knew really well was HTML, and that
hardly counts as "programming"). Still, I find Perl quite simple (although
I have a very long road ahead of me) and flexible for my needs.

I bought the excellent book "Teach yourself Perl 5 in 21 days" (SAMS
Publishing), and now I am completely hooked. 

With your previous excperience, this should really be a walk in the park. I
am testing my scripts locally on my NT, and with minor adjustments running
them on the Unix-server. It's really great to be this
plattform-independent.

Good luck!

Sincerely
Jarle Aasland
NORWAY


> MY GOAL:  To create a web site hosted on either my ISP or another
> hosting service withdynamic content (CGI scripting most likely). 


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

Date: Sun, 23 Feb 1997 13:24:19 -0500
From: Bill Cowan <billc@tibinc.com>
To: Brian Shepard <brian@shepmark.com>
Subject: Re: PERL / OLE
Message-Id: <33108B53.19E2@tibinc.com>

Brian Shepard wrote:
> 
> Does Perl come with OLE set up? or are there OLE extensions?
> 
> Where would I find the OLE extensions and is their a web site with info
> pertaining to this?
> 
> Any help would be greatly appreciated!
> 
> Thanks in advance!!

The Win32 port (NT/Win95) has module extensions for OLE.  I have not
used Perl/OLE myself, but have seen the doc in ActiveWare port and in
FAQ.

Useful URLs for Win32 Perl (NT Perl)
------------------------------------
Win32 Perl for Windows NT:
    http://www.activeware.com/    [also online web pages]
    http://www.perl.com/CPAN/ports/win32/Perl5/

Searchable Archive for Perl-Win32-users Mailing List:
    http://www.divinf.it/perl-win32/index.sht

Evangelo's Frequently Asked Questions (FAQ):
    http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html

Database access via ODBC by Dave Roth's Win32::ODBC module:
    Win32::ODBC Home Page with Online Documentation:
        http://www.roth.net/odbc/

    Download from:
        http://www.perl.com/CPAN/authors/Dave_Roth/

    Also see FAQ for database questions.


-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: Sun, 23 Feb 1997 19:51:40 GMT
From: mwt@cyberg8t.com (Mark Thompson)
Subject: Random Temp File in Perl 5.002
Message-Id: <33109eb7.3091020@news.alt.net>

Hi,

I need to make a random temporary file, sortof like tmpnam() in C.
Does Perl offer this functionality?  If not, any suggestions on how to
implement something like this?

Thanks,

Mark Thompson




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

Date: Sun, 23 Feb 1997 14:51:09 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Henry Lifton <henlif@elsfl.com>
Subject: Re: Record Length
Message-Id: <Pine.GSO.3.95q.970223144633.18178L-100000@kelly.teleport.com>

On Sun, 23 Feb 1997, Henry Lifton wrote:

> Newsgroups: comp.lang.perl.misc, comp.lang.perl.modules, comp.lang.perl

There is no comp.lang.perl. You'll do yourself and many others a favor by
asking your newsadmin to read the frequent posting in
news.announce.newgroups about bogus newsgroup names. 

> It has been a year or so since I wrote a program in Perl. It was in Perl
> 4.  At that time there was a limitation to the length of a record in a
> data base

I think you're talking about a limit in DBM files. To my knowledge, Perl
has never had such a limitation, but many implementations of databases
have limitations. 

> Is there still such a limit in Perl 5.x or has that been removed?

Now you can use tie() to connect your hash to the database of your choice. 
If you can't find a module on CPAN to your liking, you're welcome to cook
up and submit one of your own. Have fun! 

   http://www.perl.org/CPAN/
   http://www.perl.com/CPAN/

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 23 Feb 1997 14:49:44 -0559
From: buhr@stat.wisc.edu (Kevin Buhr)
Subject: Re: simple new question!
Message-Id: <vbahgj32qon.fsf@mozart.stat.wisc.edu>

m9418@abc.se (Jonas Bofjall) writes:
> 
> I don't understand your program very much at first sight :) but I downloaded
> it to my local disk and will check it out later, to find out if it makes
> multiple passes too.

My program does, in fact, make a single pass.  The line

     s/$fookeys/$foo{$&}/g;

basically means: replace each occurrence of something matching
"$fookeys" with "$foo{$&}", all in one pass (see perlop(1)).  Now,
"$fookeys" has value "a|c|g" which is a regular expression matching
'a', 'c', or 'g', so when one of these characters (let's say 'a') is
matched, it will be replaced by "$foo{$&}".  Now, the fun part is that
"$&" is a special variable (see perlvar(1)) containing whatever was
last matched ('a', in this example), and "$foo{'a'}" is the value, in
the hash "%foo" (see perldata(1)), associated with the key 'a'.
Fortunately enough, this value is 'b', so 'a' gets replaced with 'b'.
The matching process continues, replacing other 'a's with 'b's and
'c's with 'de's and 'g's with 'ijkl's.

See?  Cartoon music!  Only in Perl could you get away with a nonsense
statement like "s/$fookeys/$foo{$&}/g" and expect it to work.  The
best part is this: crazy stuff like this is a common occurrence in
Perl programs, where other programming languages would just get in
your way.  If you tried anything clever like that in C or Pascal, the
compiler would probably erase all your files and reboot your computer,
but Perl *encourages* stuff like this.

> It mentions the strict mode, which I tried. When using strict mode my
> program fills the screen with compiler errors ;) ! I don't understand most
> of them, but one is very interesting. It says something like
> "bareword TRUE not allowed". I think my problem is here, and that the TRUE
> symbol doesn't work like I thought it did.

Right, a "bareword" is something that doesn't make any sense to Perl
except as a string value, and that's how Perl treats it.  For example,
the statement:

	$a = TRUE;

assigns "$a" the string value "TRUE" because Perl doesn't know what
"TRUE" means, while

	$a = FALSE;

assigns "$a" the string value "FALSE" for the same reason.  However,
if "TRUE" or "FALSE" are subroutine names, then Perl *does* know what
"TRUE" and "FALSE" mean, so the appropriate subroutines will be
executed and the return values assigned to the variable.  In other
words, the program:

	$a = FALSE;
	if($a) { 
		print "FALSE is TRUE?  Perl never does what I want!\n";
	}

produces unwanted output (because it assigns "$a" the string value
"FALSE", and Perl interprets all strings except "0" and "" as being
true).  On the other hand, the program:

	sub FALSE { 0 }   # FALSE is now a subroutine returning "0"
	$a = FALSE;
	if ($a) {
		print "You'll never see this!\n";
	}

does what you expect (because now "FALSE" is a subroutine that returns
the value "0", which Perl interprets as being false).  This is just
one of the many reasons barewords are *discouraged*, while the use of
tools like the "-w" command line argument and the pragma "use strict;"
---which will warn you about barewords---are encouraged.

> Yes, I will do that if the TRUE symbol stuff isn't the right way to go.

Look at the perldata(1) manpage, and search for the first occurrence
of the word "Boolean".  This explains when Perl interprets a value to
be "true" and when it interprets a value to be "false".  Bizarrely
enough, all the following values are true:

	TRUE 1 FALSE 00 X -5.3 100000

while only "0", the empty string "", and an undefined value are false.

If you like using "TRUE" and "FALSE" for boolean values, stick:

	sub TRUE { 1 }
	sub FALSE { 0 }

at the beginning of your scripts, and hack away.

Kevin <buhr@stat.wisc.edu>


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

Date: 23 Feb 1997 22:45:25 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: simple new question!
Message-Id: <5eqha5$5sr$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

For the sake of efficiency, using $1 rather than $& can make a significant
difference.  Figuring out a /o or closure application may also help in
some (most) cases, but the $& thing is a time killer.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
If you want to see useful Perl examples, we can certainly arrange to have
comp.lang.misc flooded with them, but I don't think that would help the
advance of civilization.  :-) --Larry Wall in <1992Mar5.180926.19041@netlabs.com>


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

Date: Sun, 23 Feb 1997 14:26:05 -0500
From: Bill Cowan <billc@tibinc.com>
To: Daniel Macks <dmacks@netspace.org>
Subject: Re: split() matches, but returns no values
Message-Id: <331099CD.48BC@tibinc.com>

Daniel Macks wrote:
> 
> Say I've got a string that is a colon-delimited set of fields in a
> database (relax...this is *not* a sort() question:) I want to split up a
> line into its component fields, so I figured I'd use split(), but the
> (external non-modifiable) program that generates the strings passes a set
> of all null fields, the result of split() is a 0-item list.
> 
> Example (perl 5.002)
>   @foo = split( ':', 'this:one:seems:normal' ));
>   @bar = split( ':', ':::fine' ));
>   @ack = split( ':', ':::' ));
> gives
>   @foo = ( 'this', 'one', 'seems', 'normal' );
>   @bar = ( undef, undef, undef, 'fine' );
>   @ack = ();
> Why doesn't @ack=(undef,undef,undef,undef)?
See info below and debugger example.

> 
> The number of fields varies (and could be zero) so I can't think of a
> simple way to just define an all-undef array of the correct length.
> 
> Any elegant ways to get all the undefs?
You may need to have special case logic for this (or when you have
trailing empty fields).  Probably based on "if scalar(@ack) == ...".

If you know the number of expected fields, you can do
	push(@ack, '');
as much as needed. 

To get number of expected fields, you could count the number of
delimiters with something like:

  DB<49> @temp = "::::" =~ m/:/g;

  DB<50> $count = scalar(@temp) + 1

  DB<51> print $count
5

> 
> dan
> --
> Daniel Macks
> dmacks@a.chem.upenn.edu
> dmacks@netspace.org
> http://www.netspace.org/~dmacks

Simple test out of the debugger:

  DB<13> @array = split(':', '::c');

  DB<14> V main array
@array = (
  0     ''
  1     ''
  2     'c'
)
  DB<16> @array = split(':', '::');

  DB<17> V main array
@array = (
)
  DB<18> print scalar @array;
0

For case of split(':', '::c'), you get two array elements that are
*empty* strings (which are different from "undef" in some ways).

To test for case of all empty fields as in split(':', '::'), perl man
page for split() has:

SYNOPSIS 

split /PATTERN/,EXPR,LIMIT 
split /PATTERN/,EXPR 
split /PATTERN/ 

DESCRIPTION 

Splits a string into an array of strings, and returns it. 
[SNIP]
If LIMIT is unspecified, trailing null fields are stripped (which
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   
potential users of pop() would do well to remember). 

To illustrate in debugger:

  DB<32> print scalar(split(':', '::a'));
3
  DB<33> print scalar(split(':', ':a:'));
2
  DB<34> print scalar(split(':', 'a::'));
1
  DB<35> print scalar(split(':', '::'));
0


-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: Sun, 23 Feb 1997 14:04:05 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Craig Votava <craig@lucent.com>
Subject: Re: Strange pack/unpack behavior
Message-Id: <Pine.GSO.3.95q.970223134151.18178I-100000@kelly.teleport.com>

On Sat, 22 Feb 1997, Craig Votava wrote:

> Tom Phoenix wrote:

> > When you say 'pack("B2", "10")', you're asking perl to return to you a bit
> > vector with the first two bits set to 1 and 0. When you ask to unpack with
> > "H1", you're asking to unpack four bits, so two extra (zero) bits are
> > added, to fill the gap. So, unpack is working on binary 1000, and gets 8.
> 
> I wonder if it might be better for unpack to assume it should prepend
> any needed fill zeros, instead of appending them. 

I see that what I wrote was unclear. Pack starts at the beginning (not too
surprising), and it can only return whole bytes. (Perl's bitstrings are
just strings, so they have to be a whole number of bytes long.) So, the
output of 'pack("B2", "10")' is a byte with the first two bits set to
'10'.

It's not too hard to find out how many padding bits to add, as you show in
your workaround. So, we probably don't need to add something to pack. And
besides, some would say that pack and unpack have too many formats
already! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/




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

Date: Sun, 23 Feb 1997 14:37:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: mpanfilo@mailbox.syr.edu
Subject: Re: syntax error
Message-Id: <Pine.GSO.3.95q.970223140953.18178J-100000@kelly.teleport.com>

On 22 Feb 1997, Maksym Panfilov wrote:

> I just could not come up with that simple suyntax error problem. Perl
> says: syntax error in file cg.cgi at line 30, next 2 tokens "]["
> 
> But I don't get what's wrong with that line.
> Line 30 is: $grade[$j][$quiz] = $score;

Nothing _wrong_ wrong there, but maybe it's something earlier in your
script that's confusing Perl. Usually Perl knows where the problem was,
but not always. These things can be devilishly hard to track down when
they crop up. Here's an example that bit me once. 

    # Converting elapsed time to hours, minutes, 
    # and seconds (the hard way, shoulda used a module).
    $s = time - $start;
    $m = int($s/60);    $s -= 60 * $m;
    $h = int($h/60);    $m -= 60 * $h;
    $duration = sprintf "%02d:%02d:%02d", $h, $m, s;
    print "That procedure took $duration.\n";
    print "This may vary depending upon system load.\n";
    print "Why is there a syntax error on _this_ line?!\n";

[ Answer, in ROT13 so as not to spoil the puzzle for you sharp-eyed
readers of c.l.p.misc: Gur ceboyrz vf gung V yrsg bss n qbyyne fvta ba gur
fcevags yvar. Crey gubhtug V jnf znxvat n fhofgvghgvba jvgu frzvpbybaf nf
qryvzvgref. ]

I can't say whether that (or something similar) is what's happening in
your case, but it's one possibility. Try tinkering with your script to see
whether you can get a different error message out of it; Perl is likely to
figure out what you meant sooner or later. Another thing you could try is
to make a backup copy of your script, then see how much code you can cut
out and still retain your bug.

Also (and this has happened to every programmer, I'm sure) could you check
that the copy of the script that you're looking at is the same as the one
Perl is complaining about? It's easy to be reading an old copy while
running a new one, or the other way around.

Good luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/





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

Date: Sun, 23 Feb 1997 18:14:18 GMT
From: syoung@actcom.co.il (Sara Young)
Subject: Time-efficiency question
Message-Id: <E62Inu.8Mz@actcom.co.il>

I have a Perl CGI script that reads an HTML form, inserts data into it,
and then prints it out to the browser.

The form looks something like this:

<HTML><BODY>
some stuff
<!-- data1 here -->
some more stuff
<!-- data2 here -->
some more stuff
</BODY></HTML>

The question is this: what is the most time-efficient way to do this?

1. open(FILE, $file);
   while <FILE> {
      if (/!-- data1 here -->/) {
         print something;
      } elsif (/!-- data2 here -->/) {
         print something_else;
      }
      print;
   } 
   close(FILE);

2. open(FILE, $file);
   @fileLines = <FILE>;
   $fileString = join(" ",@fileLines);
   $fileString =~ s/<!-- data1 here -->/something/;
   $fileString =~ s/<!-- data2 here -->/something else/;
   print "$fileString";

I have a feeling that #2 is faster, but I don't know how costly the join
is, and how costly it is to do a substitution on a long string.

Thanks in advance,

Sara


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

Date: Sun, 23 Feb 1997 20:40:52 GMT
From: mwt@cyberg8t.com (Mark Thompson)
Subject: Username / Password change program
Message-Id: <33119fd4.3376243@news.alt.net>

Hi,

I'm trying to write a program that lets a user change his or her
username and/or password in UNIX from a Web Page.  Not the FTP or the
general password for UNIX, but a password that's used by an .htaccess
file by the web server.

The logic I'm thinking of for this is as follows:

	Get all of the username and password information from CGI
	Open a temporary file
	Do preliminary check of password file to avoid duplicates
	use flock() to lock both the existing password and temp files
	Cycle through each record
		Determine whether record matches old username
			If so, make change to that record and copy.
			If not, copy to temp file unchanged.
	Rename temp file to existing filename
	Un-flock() everything
	Return information through CGI to user


Any thoughts on whether this is a good way to approach this?  Also, if
anyone has any code snippets to send me that do any part of this,
could you send them to me?  (I'm especially needing code to create the
temp file since I don't know how to make a temp file in Perl like you
can in C.)

Thanks,

Mark Thompson


	


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

Date: 23 Feb 1997 20:46:46 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Username / Password change program
Message-Id: <5eqabm$3n7@fridge-nf0.shore.net>

Mark Thompson (mwt@cyberg8t.com) wrote:

: Any thoughts on whether this is a good way to approach this?  Also, if
: anyone has any code snippets to send me that do any part of this,
: could you send them to me?  (I'm especially needing code to create the
: temp file since I don't know how to make a temp file in Perl like you
: can in C.)

Yes.
(1) Grab the NCSA httpd package from http://hoohoo.ncsa.uiuc.edu and
    take a look at change-passwd.c.  Sure, it's written in C, but the 
    code is pretty simple to follow, and it does exactly what you want.
(2) Check out the CPAN sites for htpasswd.pl (or any module that does
    AUTH'ing or htpasswd stuff).
(3) Check out the archives for comp.lang.perl.misc, and in particular
    comp.infosystems.www.authoring.cgi -> http://www.dejanews.com

--
Nathan V. Patwardhan
nvp@shore.net
"A stitch in time saves nine."


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

Date: Sun, 23 Feb 1997 22:29:10 GMT
From: rich@cris.com (Rich)
Subject: WEB DEVELOPER'S VIRTUAL LIBRARY is Top Dog's Site Of The Day @ http://www.statsplus.com/TopDog/
Message-Id: <3310c4a5.23624368@news.concentric.net>

The Web Developer's Virtual Library is a great resource for
webmasters and Internet developers, with over 500 pages and thousands
of references.
http://www.statsplus.com/TopDog/


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

Date: 23 Feb 1997 21:57:16 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: WEB DEVELOPER'S VIRTUAL LIBRARY is Top Dog's Site Of The Day @ http://www.statsplus.com/TopDog/
Message-Id: <5eqefs$9hm@vixen.cso.uiuc.edu>

Rich (rich@cris.com) wrote:
: The Web Developer's Virtual Library is a great resource for
: webmasters and Internet developers, with over 500 pages and thousands
: of references.
: http://www.statsplus.com/TopDog/

How come I don't believe that? Does it have something to do with
the promoters of it not knowing enough about the Internet to cross-post
rather than post separately to different groups?

-- 
Regards,                                                      ___       ___
Mike Heins     [mailed and posted]  http://www.iac.net/~mikeh|_ _|____ |_ _|
                                    Internet Robotics         | ||  _ \ | |
This post reflects the              Oxford, OH  45056         | || |_) || | 
opinion of my employer.             <mikeh@iac.net>          |___|  _ <|___|
                                    513.523.7621 FAX 7501        |_| \_\   


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

Date: Sun, 23 Feb 1997 13:42:54 GMT
From: csh@henktech.com (Charles Henkel)
Subject: Win95 Build 110: `cd` fails in install
Message-Id: <3310495a.271600@news.avana.net>

Context:
	P6 Pentium Pro
	Win 95
	Perl 5.001m build 110

Problem:
	On some machines, the perl installation script "install.bat"
fails to determine the current directory name.  The script is doing
something like "$curdir = `cd`", and it's the command substitution
that fails.  

Invoking the perl debugger and issuing a similar command by hand, the
correct result of the "cd" command is displayed on the screen, but not
assigned to the string var.

Has anyone else seen this? Odd thing is that in a collection of half a
dozen or so supposedly identical machines, it works fine on four of
them and fails on the other two.

Please also email responses.



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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 V7 Issue 997
*************************************

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