[9849] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3442 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 13 21:08:38 1998

Date: Thu, 13 Aug 98 18:00:19 -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           Thu, 13 Aug 1998     Volume: 8 Number: 3442

Today's topics:
    Re: #!usr/bin/perl is ignored, WHY? <rootbeer@teleport.com>
    Re: 5.002 and 5.004 question <rootbeer@teleport.com>
    Re: 5.002 and 5.004 question (Larry Rosler)
    Re: data integrity <p-fein@uchicago.edu>
        database on the internet <sven.sprandel@metronet.de>
    Re: database on the internet <rootbeer@teleport.com>
    Re: File::Find, wanted(), and parameters (Martin Vorlaender)
    Re: File::Find, wanted(), and parameters (Craig Berry)
    Re: flock vs open <rootbeer@teleport.com>
    Re: freeware documentation (Michael J Gebis)
    Re: freeware documentation <rootbeer@teleport.com>
    Re: Have package use another symbol table? <jdf@pobox.com>
    Re: HELP !!!! HTTP ERROR 404 <rootbeer@teleport.com>
    Re: HELP !!!! HTTP ERROR 404 (Craig Berry)
        How do I validate form input? <tgizaw@us.oracle.com>
        How to append at the top of the logfile ? <terrence@cs.utexas.edu>
    Re: How to append at the top of the logfile ? <rootbeer@teleport.com>
    Re: if/elsif menu? <dagon@halcyon.com>
    Re: if/elsif menu? <rootbeer@teleport.com>
    Re: long story - fork & multiprocessing problem (Larry Rosler)
    Re: long story - fork & multiprocessing problem (Larry Rosler)
        Matts counter - suddenly stopped working <alastair.taylor@cableinet.co.uk>
    Re: Matts counter - suddenly stopped working <rootbeer@teleport.com>
    Re: Newbie Question About 'for' (Martien Verbruggen)
    Re: Perl and catching alarms (Charles DeRykus)
    Re: PLEASE - SOMEONE <rootbeer@teleport.com>
    Re: Run perl script "in-line"? (Andreas Hack)
        SW Eng Mgr - Cutting Edge Pre IPO careers_zland_com@my-dejanews.com
    Re: What is the purpose of Perl (Craig Berry)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 14 Aug 1998 00:08:21 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: #!usr/bin/perl is ignored, WHY?
Message-Id: <Pine.GSO.4.02.9808131707100.10161-100000@user2.teleport.com>

On Sat, 8 Aug 1998, Raik Lietzow wrote:

> Could it be that the first command
> #!usr/bin/perl
> is ignored?

It's possible. If that's happening, though, it's not perl's fault; that's
your system (or some part of it) that's failing to start perl as
requested. The docs, FAQs, and newsgroups about your system, server, or
whatever should be able to get you back on the right track. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 14 Aug 1998 00:18:12 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: 5.002 and 5.004 question
Message-Id: <Pine.GSO.4.02.9808131713190.10161-100000@user2.teleport.com>

On 13 Aug 1998, Eric Sheng wrote:

> 	In PERL 5.002, if you don't define a variable i.e. $my_string and
> do an operation such as:
> 
> 	$my_string .= "\n";
> 
> you'll get an "use of uninitialize value message".
> 
> 	But in PERL 5.004, I don't get it.

Perl got smarter about warnings. It learned to recognize some common code
(such as that) as not being something worth warning about. But it also got
smart enough to warn about other things about which it had previously been
silent. 

Moral of the story: Warnings change from one version of Perl to the next.
Although you should always _develop_ with warnings turned on, leave them
on afterwards only if you're willing to accept whatever new and different
warnings may appear.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 13 Aug 1998 17:39:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: 5.002 and 5.004 question
Message-Id: <MPG.103d2706c30ceac298976b@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <6qviqq$att$1@mark.ucdavis.edu> on 13 Aug 1998 20:37:46 GMT, 
Eric Sheng <shenge@ece.ucdavis.edu> says...
 ...
> 	In PERL 5.002, if you don't define a variable i.e. $my_string and
> do an operation such as:
> 
> 	$my_string .= "\n";
> 
> you'll get an "use of uninitialize value message".
> 
> 	But in PERL 5.004, I don't get it.  Is this a correct explaination
> for the observation I made or is it something?

Yes.  Several such warnings, for example

$hash{'previously undefined'} += $n;

were removed, for consistency.  (In the above case, ++$hash{...} didn't 
get a warning ever.)

However, fastidious programmers who 'use strict;' so they have to define 
their variables also initialize them, if they will be bumped or 
concatenated to.  It isn't much harder to write

my $my_string = "";

than not to initialize.  And concatenation then gets no warning in perl 
5.002 either.

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


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

Date: Thu, 13 Aug 1998 23:09:11 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Re: data integrity
Message-Id: <opg90ks32eg.fsf@harper.uchicago.edu>

dsrenterprises@my-dejanews.com writes:

> 
> Hello.
> 
> Without the advantage of using a Unix-based database application, I have a
> series of tables (flatfiles.txt) that can be related by common fields (parsed
> into variables, as needed).
> 
> I can read from data, and write to data.
> But when we want to read existing records and make modifications to them, when
> resubmitted a duplicate record will be created.

Yeah non-Perl questions!  Anyway, you need to the delete-insert style
of update.  Basically, you delete the record, then insert the new,
changed one.  Slower, and more dangerous from a transactions point of
view.  But if you cared, you wouldn't be using text files to begin with.

-- 
Peter A Fein                                           Summering in SF!
Home:                                                Work: 650-628-2172
p-fein@uchicago.edu                             pfein@us.checkpoint.com
Gilette's Razor: The best a man can get.


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

Date: Fri, 14 Aug 1998 01:24:10 +0200
From: "Sven.Sprandel" <sven.sprandel@metronet.de>
Subject: database on the internet
Message-Id: <35D3759A.5A0FD40E@metronet.de>

Hi

I want to realise a database on the internet.

I could get web-space from hypermart.net including
cgi-ability and Perl 5.003 with cgi.pm module.
Hypermart is using a BSDI 3.1 unix server with apache.

How can I embeed a database without installing additional moduls?
Is I possible? If yes what would I need to do it?
Do I need a comercial SQL-Server?
Or does other free-ware exist?

Thanks for answering, it's greatly appreciated.

Sven





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

Date: Fri, 14 Aug 1998 00:32:29 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: database on the internet
Message-Id: <Pine.GSO.4.02.9808131730500.10161-100000@user2.teleport.com>

On Fri, 14 Aug 1998, Sven.Sprandel wrote:

> How can I embeed a database without installing additional moduls?

Use modules that are already installed. (But what do you have against
installing modules? The FAQ tells you how to do it. Or you can get your
sysadmin to do it.) Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 14 Aug 1998 00:30:02 +0200
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: File::Find, wanted(), and parameters
Message-Id: <35d368ea.524144494f47414741@radiogaga.harz.de>

Thomas Frederick O'Connell (tfo@telalink.net) wrote:
: i would like to be able to have wanted(), the companion function to
: find(), take parameters. is this possible? for example, suppose i wanted
: to simulate the behavior of chown -R.
:
: what i would like to be able to do is pass wanted() the uid and gid for
: the chown function i would like to run on each encountered file.
:
: i.e.
:
: find( \&wanted( $uid, $gid ), '/' );
: sub wanted {
:    my( $uid, $gid ) = @_;
:    chown( $uid, $gid, $_ );
: }
:
: unfortunately, this does not seem to work. and i can't figure out a way to
: get find2perl generate anything remotely related to what i want. is it
: possible to pass parameters to wanted?

Why don't you use global variables for $uid and $gid, and use those in
wanted() without having to pass arguments?

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 OpenVMS: Where do you    | work: mv@pdv-systeme.de
 want to BE today?        |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: 14 Aug 1998 00:35:36 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: File::Find, wanted(), and parameters
Message-Id: <6r00oo$gll$4@marina.cinenet.net>

Martin Vorlaender (martin@RADIOGAGA.HARZ.DE) wrote:
: Why don't you use global variables for $uid and $gid, and use those in
: wanted() without having to pass arguments?

Because passing subroutines values via globals is eeeeeeevil.  (But
unfortunately, it *is* the best solution in this case.)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 14 Aug 1998 00:06:47 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: flock vs open
Message-Id: <Pine.GSO.4.02.9808131704420.10161-100000@user2.teleport.com>

On Thu, 13 Aug 1998, madame philosophe wrote:

> What I want to know is it proper to use flock() before or after opening
> a file? 

It's useless to lock a file you haven't opened. Well, it would be useless
if it were possible. :-)

> and how about closing?

It's useless to lock (or unlock) a file after closing it. And, in Perl,
it's a waste of time to unlock it _before_ closing it, too. Just close the
file, and all will be well. 

> To make it easy for you to anwer me please choose from the following
> options:
> 
> A) open first then lock, close first then unlock.
> B) lock first then open, close first then unlock.
> C) open first then lock, unlock first then close.
> D) lock first then open, unlock first then close.

E) open, lock, work with data, close.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1998 23:33:25 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: freeware documentation
Message-Id: <6qvt45$fd2@mozo.cc.purdue.edu>

"Sabre Taylor" <toolong.hot_redox@hotmail.com> writes:

}Not to start a holy war but...

}It presents an argument for free documentation
}of freeware.

Go to dejanews.

Read "GNU attacks on the open software community"

Executive summary: A bunch of extremists argue.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Fri, 14 Aug 1998 00:26:23 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: freeware documentation
Message-Id: <Pine.GSO.4.02.9808131726070.10161-100000@user2.teleport.com>

On 13 Aug 1998, Sabre Taylor wrote:

> Not to start a holy war but...
> 
> has anyone else read:
> 	http://www.gnu.org/philosophy/free-doc.html
> ?

You're new here, aren't you?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1998 19:02:38 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: mcafee@qbert.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Have package use another symbol table?
Message-Id: <u33go2g1.fsf@mailhost.panix.com>

mcafee@qbert.rs.itd.umich.edu (Sean McAfee) writes:

> perl -e '$x = 10; %FOO:: = %::; print "$FOO::x\n";'
> 
> After the symbol table assignment, inserting 'print $FOO::{"x"}' shows that
> $FOO::{"x"} is *main::x, as it should be, but 'print $FOO::x' doesn't
> display 10.
> 
> What's going on here?

The scalar referred to by the typeglob $FOO::{x} is spelled
${$FOO::{x}} or, if you're feeling particularly obfuscatory,
${*{$FOO::{x}}{SCALAR}}.  Remember the $FOO::{x} is a value in the
hash %FOO:: (which happend to be a typeglob), and that it is not the
scalar $FOO::x.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Fri, 14 Aug 1998 00:25:17 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: HELP !!!! HTTP ERROR 404
Message-Id: <Pine.GSO.4.02.9808131722330.10161-100000@user2.teleport.com>

On Thu, 13 Aug 1998, Alee Ali wrote:

> Subject: HELP !!!! HTTP ERROR 404

That's not a Perl error. Maybe you should check the docs, FAQs, and
newsgroups about the program that's giving it to you. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 14 Aug 1998 00:20:05 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: HELP !!!! HTTP ERROR 404
Message-Id: <6qvvrl$gll$3@marina.cinenet.net>

Alee Ali (aaa@dms2.com) wrote:
: I have the hello.pl perl program which prints the IP Address.  I have
: that in my cgi-bin directory on NT 4.0.  Does anyone know why I keep
: getting the HTTP Error 404 that it can't find the file or the script.

I mean this in the most helpful possible way:  This really, truly isn't a
Perl question.  If you're getting a 404, it means perl never even got
invoked, as the http server couldn't find the file (you said) you wanted.

A web-server related newsgroup, the docs for your server, or other more
appropriate resource should provide the help you need.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Thu, 13 Aug 1998 17:29:56 -0700
From: Tinbet Gizaw <tgizaw@us.oracle.com>
Subject: How do I validate form input?
Message-Id: <35D38504.9AD9A619@yahoo.com>

Hi,
Can anybody give me an idea on how to do valiating form in put from a
webpage.
I am trying to make sure that people enter the correct date, hours and
stuff like that.
And also I am trying to write a script to put the form data into an
Oracle data base.
Does anybody have any simplar expameles. Any ideas or comments are more
than
welcome.
Tinbet.



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

Date: 13 Aug 1998 18:29:48 -0500
From: "Terrence S. Ma" <terrence@cs.utexas.edu>
Subject: How to append at the top of the logfile ?
Message-Id: <6qvstc$jhs$1@boater.cs.utexas.edu>

I am pretty new to perl so I hope that I am not asking a very 
stupid question.  I have a perl script to log all the web hits 
on my web page but I want to have the latest hit to be at the top 
of the logfile instead of at the bottom. I am doing something like 
this :

open (LOG,">>$logfile") || die "Can't write to log file";
print *something*;

This appends the latest hit at the end but I want to have the 
hit to be written at the top of the logfile.  Is there any easy way 
to do it or do I need to write the new hit in a new file and then 
merge the new and the old to get the result I want ? By the way, 
my URL is http://www.terrence.com. Thank you very much for your help.

-- 
Terrence Ma
terrence@cs.utexas.edu


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

Date: Fri, 14 Aug 1998 00:33:18 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: How to append at the top of the logfile ?
Message-Id: <Pine.GSO.4.02.9808131732490.10161-100000@user2.teleport.com>

On 13 Aug 1998, Terrence S. Ma wrote:

> Subject: How to append at the top of the logfile ?

The FAQ talks about this. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1998 16:56:42 -0700
From: Mark Rafn <dagon@halcyon.com>
Subject: Re: if/elsif menu?
Message-Id: <6qvufq$e3a$1@halcyon.com>

<bkosch@omnicast.net> arranged electrons in a pattern like this:
>what would be the best way to setup a menu system? kind of like this:
>right now I have a whole if/elsif/elsif/elsif/else thing going on, but I
>was wondering if there was a better way.

I don't know about "better", but you might consider using hashes for it.
You could either create a hash for descriptions and one for commands, or
a hash of hashes, each entry describing an option.

%menu=( 'a' => { 'text' => 'option A',
                 'command' => '/bin/ls',
                 'pause' => 1
                },
        'b' => { 'text' => 'option B',
                 'command' => '/usr/bin/du',
                 'pause' => 1
                },
        'shell' => { 'text' => 'shell',
                 'command' => '/bin/bash',
                 'pause' => 0
                },
      );

You print the options based on keys %menu and $menu{$option}{text}, and
you run the command with system($menu{$option}{command}), and then pause
to display the results if $menu{$option}{pause} is true.

>I also wanted to clear the screen
>after each option (choose something, do it there, when that program exits,
>it clears the screen and reprints the menu).

system('clear') is the easiest.  Term::Cap can also give you the
clear-screen code for the current terminal.  I'm pretty sure both are
unix-specific.

>Also, I cannot find anywhere
>how to remove a line of text from a file. Such as remove a user from
>/etc/passwd. Thanks in advance.

You need to rewrite the rest of the file to do this.  
--
Mark Rafn    dagon@halcyon.com    <http://www.halcyon.com/dagon/>   !G


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

Date: Fri, 14 Aug 1998 00:29:35 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: if/elsif menu?
Message-Id: <Pine.GSO.4.02.9808131726400.10161-100000@user2.teleport.com>

On Thu, 13 Aug 1998 bkosch@omnicast.net wrote:

> what would be the best way to setup a menu system? 

Define "best". What's best for me may not be best for you, and there's no
point in any of us wasting our time until you can say just what you want.
 
You may need to choose among fastest, most memory efficient, easiest to
program, fewest lines of code, most robust, most portable, easiest to
debug, easiest to maintain, most like your other favorite programming
languages, or perhaps you mean some other criterion. (Of course, one
solution may fall into more than one of these categories.)
 
> right now I have a whole if/elsif/elsif/elsif/else thing going on, but
> I was wondering if there was a better way.

If you're looking for a case/switch statement, the FAQ has some ideas.

> I also wanted to clear the screen after each option

The FAQ talks about doing that, too.

> Also, I cannot find anywhere
> how to remove a line of text from a file. 

Didn't look in the FAQ, did you? :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 13 Aug 1998 17:19:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: long story - fork & multiprocessing problem
Message-Id: <MPG.103d2283c8938fb6989769@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <35D3461E.8C7BFBD6@rocketmail.com> on Thu, 13 Aug 1998 
16:01:34 -0400, Debbie Whitten <usenet-replies@rocketmail.com> says...
> Thanks John - I managed to shave 20 seconds off using rename and mkpath,
> but for the life of me I can't figure out how to do ls -t - the opendir
> function didn't seem to have that option.

Assuming that means you want the list sorted in order of modification 
date (latest first) then alphabetically, you could do this:

opendir DIR, $dir or die "Couldn't open $dir. $!\n";
print map "$_->[0]\n" =>
    sort { $a->[1] <=> $b->[1] || $a->[0] cmp $b->[0] }
    map { [ $_, -M "$dir/$_" ] } readdir DIR;
closedir DIR;

(You could filter out '.' and '..' by a grep on readdir.)

This uses the 'Schwartzian transformation' which you can read about in 
perlfaq4: "How do I sort an array by (anything)?"

Once you grasp all of this, you will also be able to dance through hoops!

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


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

Date: Thu, 13 Aug 1998 17:27:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: long story - fork & multiprocessing problem
Message-Id: <MPG.103d2456b372602098976a@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <35D34DB5.E2FA8829@tcon.net> on Thu, 13 Aug 1998 22:34:06 GMT, 
Ken McNamara <conmara@tcon.net> says...
 ...
> What about using Perl to generate shell scripts and then running them
> separately.  Then use Perl to monitor the results.
> 
> Would this speed execution?

Sure it would, or you could do the same using 'fork' and 'exec' on 
systems that support it.  That would get several processes running 
simulaneously, so i/o waits get overlapped.  It is much harder to manage 
than single-process execution, of course.  And that's where the original 
submitter got bogged down.

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


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

Date: Fri, 14 Aug 1998 00:05:56 +0100
From: Alastair Taylor <alastair.taylor@cableinet.co.uk>
Subject: Matts counter - suddenly stopped working
Message-Id: <35D37154.2C93D1FE@cableinet.co.uk>

Hi,
I had a counter from MSA all working ok then suddenly it stopped showing
the hits on my web page,  Count.txt is being updated as is the
access_log.

It got to 180 ish then stopped - this is driving me mad

Any clues?

Alastair.


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

Date: Fri, 14 Aug 1998 00:30:15 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Matts counter - suddenly stopped working
Message-Id: <Pine.GSO.4.02.9808131729550.10161-100000@user2.teleport.com>

On Fri, 14 Aug 1998, Alastair Taylor wrote:

> I had a counter from MSA all working ok then suddenly it stopped
> showing the hits on my web page, Count.txt is being updated as is the
> access_log.

Complain to the program's author. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1998 23:30:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie Question About 'for'
Message-Id: <6qvsu4$2fe$1@nswpull.telstra.net>

In article <r8u33kb14r.fsf@asc.sps.mot.com>,
	Martin Gregory <mgregory@asc.sps.mot.com> writes:

> I read this and thought "Bah hah - that's funny, but now I get it!"
> 
> Then I did this:
> 
>   perl -e 'for ($a=1, $a < 7, $a++){print;}'

which is the same as

	perl -e 'for ($a = 1, $a < 7, $a++) { print $_ }'
 
> Then I was confused again.  
> 
> Can you predict what this prints?

I couldn't, but that's my problem :) So I ran it, looked puzzled, and
started a series of tests, to see what happens

> If you didn't predict it correctly, can you now explain why it does
> what it does?

I'll give it a shot.
The for loop assigns the value of the list items to $_ each in turn,
and prints them.
For simplicity, let's get rid of the for loop, and simply do something
like:

@a = ($a = 1, $a++); print "@a\n"
2 1

@a = ($a = 3, $a++, $a++, $a++)
6 3 4 5

@a = ($a = 3, $a++, $a++, $a = -1, $a++ $a++)
1 3 4 1 -1 0

For completeness:

@a = ($a = 3)
3

$a = 2; @a = ($a++)
2

So, a Postincrement operation returns the value of the incremented
variable before the increment (which is logical). An assignment
returns the value of the variable.

All of the above is straight forward, except for the return value of
the assignments. Instead of returning the value that the variable gets
from the assignment, it seems to return the value of the variable
_after_ all the operations are done. In other words, it looks like
it's being evaluated like thus:

@a = ($a = 3, $a++, $a++)

<=>

$a = 3; $a[1] = $a++; $a[2] = $a++; $a[0] = $a;

Now, let's have a look at the comma operator:

# perldoc perlop
     Binary "," is the comma operator.  In a scalar context it
     evaluates its left argument, throws that value away, then
     evaluates its right argument and returns that value.  This
     is just like C's comma operator.

     In a list context, it's just the list argument separator,
     and inserts both its arguments into the list.

Hmmm..

# perl -e '$a = 2, $a++, $a++; print "$a\n"'
4

It looks like that is what is happening. The comma operator seems to
work twice, once in a scalar context, and once as a list separator. It
probably doesn't _really_ work twice, but it's easy to think about it
that way.

Anyway, this is as far as I get. Doubtless one of the people who knows
much more about perl than I do will have something more to say about
this.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Thu, 13 Aug 1998 20:57:36 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Perl and catching alarms
Message-Id: <ExnBK0.1L8@news.boeing.com>

In article <6qu2fo$1cc$1@nnrp1.dejanews.com>,
Mark Wormgoor  <riddles@ipe.nl> wrote:
>Hi,
>
>Could somebody please tell me what's wrong in the following eval{}? I'm using
>this in Perl 5.004 but it won't catch the alarm.  The progam dies with 'Alarm
>clock' and that's it.... The eval I used is almost exactly the one described
>in the perlipc docs...
>----------------------------------------------------------------------------
>eval {
>  local $SIG{ALRM} = sub {die "Connect failed"};
>  alarm 10;
>  $remote = IO::Socket::INET->new(Proto =>"tcp",
>                                  PeerAddr=> "www.domain.com",
>                                  PeerPort=> "80");
>  alarm 0;
>  close($remote);
>};
>if ($@ && ($@ =~ /failed/)) {
>  print "Connect failed!\n";
>} else
>  print "Connected succesfully!\n";
>};
>


Looks like the local SIGALRM definition is getting lost.  
Have you tried the builtin time out, e.g.,

$remote = IO::Socket::INET->new(Proto =>"tcp",
                                Timeout => 10,
                                 ... 


HTH,
--
Charles DeRykus


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

Date: Fri, 14 Aug 1998 00:11:25 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: PLEASE - SOMEONE
Message-Id: <Pine.GSO.4.02.9808131709510.10161-100000@user2.teleport.com>

On 12 Aug 1998, Alfredo Galebe wrote:

> Subject: PLEASE - SOMEONE

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I would like to find where i can get a developer ... fast and reliable ... 

Maybe you meant to ask this in a newsgroup about photography? :-)

Or maybe one about jobs?

Let's see what develops... :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 13 Aug 1998 22:18:26 GMT
From: andreas.hack@duesseldorf.netsurf.de (Andreas Hack)
Subject: Re: Run perl script "in-line"?
Message-Id: <35d365f0.4615566@linux>

On Thu, 13 Aug 1998 08:39:15 GMT, "Lee Davies"
<lee.davies@NOSPAMsaaconsultants.com> wrote:

>Andreas Hack wrote in message <35d1f87b.6269144@linux>...
>>Lee,
>>
>>do you want information about the web-server, or about the client?
>>Andreas Hack
>
>
>I need information about the server - hostname, port, IP address etc.
>
>
Try following perl script:

#!/usr/bin/perl

print "Content-Type:text/html

<html>
        <head>
                <title>Lots of information</title>
        </head>
        <body>
                <table border=1>\n";
foreach $env (sort keys %ENV)
        {
        print "<tr>\n";
        print "<td>$env<td>$ENV{$env}\n";
        print "</tr>\n";
        }
print "         </table>
        </body>
</html>";


Andreas Hack

andreas.hack@duesseldorf.netsurf.de


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

Date: Thu, 13 Aug 1998 23:55:59 GMT
From: careers_zland_com@my-dejanews.com
Subject: SW Eng Mgr - Cutting Edge Pre IPO
Message-Id: <6qvueg$b34$1@nnrp1.dejanews.com>

ZLand is the #1 provider of web-based ERP solutions for small and mid-sized
enterprises. Our product offers applications such as online catalogs,
purchasing / bid systems, sales force automation, human resources and other
online, internet/intranet applications. The company was recently selected as
the "Best of the Best" by Entrepreneur Magazine. We have a $6 million state
of the art network operating center to support state of the art business
solutions for our customers. ZLand currently has alliance partnerships with
FedEX, Arthur Andersen, Dun & Bradstreet and other "best in class"
organizations.

Explosive growth and key market positioning has our company planning to go
public in early 1999.

ZLand is currently recruiting for two exceptional SOFTWARE ENGINEERING
MANAGERS. One will oversee the ongoing development efforts of the standard
ZLand PowerSuite product. The other will manage our customized solutions
group. Both will be faced with an infinite number of challenges as they
participate in shaping the future of global business systems solutions.

Excellent GROWTH opportunity as we double the size of our Engineering
department in the immediate future. Significant STOCK OPTIONS upon hire.

REPLY TO: careers@zland.com or visit http://www.zland.com for more
information.

KEY WORDS: Lotus Notes / Domino / CORBA / Java / C++ / VB / Delphi / IIOS /
OOA / OOD / Oracle

--
career_zland_com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 14 Aug 1998 00:05:53 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: What is the purpose of Perl
Message-Id: <6qvv11$gll$2@marina.cinenet.net>

Jarkko Hietaniemi (jhi@alpha.hut.fi) wrote:
: : Andre Merzky (am@am.westblaak.spirit.nl) wrote:
: : A final question remains: Is the universe open or closed?
: 
: Definitely closed.  Or have you seen the source code?

I have, but it's shrouded. :(

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

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

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