[11174] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4774 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 28 22:07:20 1999

Date: Thu, 28 Jan 99 19:00:19 -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           Thu, 28 Jan 1999     Volume: 8 Number: 4774

Today's topics:
    Re: A more efficient & cleaner method of doing this? <cdkaiser@delete.these.four.words.concentric.net>
    Re: A more efficient & cleaner method of doing this? (Martien Verbruggen)
    Re: ActivePerl on Win95 <andrewf@beausys.demon.co.uk>
        adding to LoL with a ref confusion. (Rob Hill)
    Re: cgi in perl (Abigail)
    Re: cgi in perl <design@raincloud-studios.com>
    Re: Checking for flock <jeff@vpservices.com>
    Re: Detecting string containing no printing chars ? (Alastair)
    Re: Floating point math errors (Martien Verbruggen)
    Re: Forms in CGI (Martien Verbruggen)
    Re: HELP with string parsing and scoring <jeromeo@atrieva.com>
    Re: Limiting length of datasent from a text box (Alastair)
    Re: LWP Questions (Alastair)
        More cannot evaluate $query->param('thing') <design@raincloud-studios.com>
    Re: More cannot evaluate $query->param('thing') <Tony.Curtis+usenet@vcpc.univie.ac.at>
        Perl 4.0 Question <Matthew.Foley@rich.frb.org>
    Re: Perl 4.0 Question (Mike Stok)
    Re: perl DBI CGI and mySQL (Alastair)
        Split vs Substr:  The Awful Truth <jeromeo@atrieva.com>
    Re: Stopping a foreach loop <jglascoe@giss.nasa.gov>
    Re: Stopping a foreach loop <ludlow@us.ibm.com>
    Re: Stopping a foreach loop <uri@ibnets.com>
    Re: system function, Pros and Cons?? (Abigail)
    Re: system function, Pros and Cons?? <jeff@toad.net>
    Re: system function, Pros and Cons?? (Martien Verbruggen)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 28 Jan 1999 16:47:39 PST
From: Cameron Kaiser <cdkaiser@delete.these.four.words.concentric.net>
Subject: Re: A more efficient & cleaner method of doing this?
Message-Id: <78r0fb$emp@chronicle.concentric.net>

"Gavin Cato" <gavin@optus.net.au.dontspam.myass> writes:

>I have quickly (and nastily with my knowledge of perl) restricted access to
>a CGI script with this ;

>$passlist = "/foo/bar.list";
>$security = $ENV{'REMOTE_HOST'};
>        chomp $security;
>        $checkip = `grep $security $passlist`;
>        chomp $checkip;

>It is working fine, but just wondering if there is a cleaner way of doing it
>without shelling out using grep etc...

Of course.

chomp($security = $ENV{'REMOTE_HOST'});
open(S, "$passlist") || die("aieeeeeeeee: $!\n");
$checkip = 0;
while(<S>) { chomp; ($security eq $_) && ($checkip = 1, last); }
close(S);
die("intruder!\n") if (!$checkip);

--
Cameron Kaiser * cdkaiser.cris@com * powered by eight bits * operating on faith
  -- supporting the Commodore 64/128:  http://www.armory.com/~spectre/cwi/ --
   head moderator comp.binaries.cbm * cbm special forces unit $ea31 (tincsf)
personal page http://calvin.ptloma.edu/~spectre/ * "when in doubt, take a pawn"


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

Date: Fri, 29 Jan 1999 02:04:58 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: A more efficient & cleaner method of doing this?
Message-Id: <eH8s2.66$LH2.5406@nsw.nnrp.telstra.net>

In article <XK6s2.5$0r.318950@news0.optus.net.au>,
	"Gavin Cato" <gavin@optus.net.au.dontspam.myass> writes:

> It is working fine, but just wondering if there is a cleaner way of
> doing it without shelling out using grep etc...

Yes. You could read in the file, and use perl's builtin grep, or just
read it line by line.

An even better way would be to let the server take care of this for
you, but that's not a perl issue. Check the configuration manual for
your server.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: Thu, 28 Jan 1999 23:55:36 +0000
From: Andrew Fry <andrewf@beausys.demon.co.uk>
Subject: Re: ActivePerl on Win95
Message-Id: <Pp9s$HA4jPs2EwSo@beausys.demon.co.uk>

In article <78kvgc$no$1@newnews.global.net.uk>, Wallace
<niall_wallace@yahoo.com> writes
>Try opening a DOS Box and then running using perl file
>
>Wallace

Yep. That's how I do it. I think it mentions it somewhere in the
ActivePerl documentation.

>
>Jason Boyd wrote in message <3697BAC3.7DA17D9F@hotmail.com>...
>>If anyone knows how I can get ActivePerl (509) to fuction properly on my
>>Win95 system, could you please help me?
>>
>>I can open the perl.exe in Windows, but any scripts I run shut down as
>>soon as they have displayed, meaning I can't see the results. When I try
>>to open perl from DOS, it tells me "this program doesn't run in DOS
>>mode." Yet the docs that come with the build claim it is for Win NT, 95
>>and 98 systems.
>>
>>Any help is appreciated (even the name of another version of perl that
>>IS built for Win95).
>>
>>Jason Boyd
>
>

---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).


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

Date: Fri, 29 Jan 1999 02:43:52 GMT
From: rhill@thisbox.com (Rob Hill)
Subject: adding to LoL with a ref confusion.
Message-Id: <36b11f37.11191152@news.lconn.com>

I am writing a perl program using Lists of Lists using a reference. 

After I define the List, I am trying add another list to the list of
lists (sounds technical enough!) but I am not getting the desired
results.

Here is the code:

#!/usr/bin/perl

$ref1 = [
	["word0", "word1", ],
	["word2", "word3", ],
	];

print "$ref1->[1][1]\n";
# This returns 'word3'.

$ref1 += [["david", "graff", ],];

print $ref1->[2][1];
# This returns nothing.

Obviously I am doing this all wrong, but I cannot seem to locate the
correct method in any of my documentation. Any help would be greatly
appreciated.

Thanks In Advance,

Rob Hill
rhill@thisbox.com

PS. I have the Programming Perl book by O'reilly. If the answer is in
there, I am having some trouble finding it. Maybe a page number is all
I need!




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

Date: 28 Jan 1999 23:44:21 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: cgi in perl
Message-Id: <78qsol$9om$1@client2.news.psi.net>

Chris Yeates (C.N.Yeates@cs.cf.ac.uk) wrote on MCMLXXVI September
MCMXCIII in <URL:news:78pfhd$g6$1@fafnir.cf.ac.uk>:
&& I am completely new to CGI programming in Perl. I wish to password protect
&& some web pages. Does anybody know how to do this?


Follow this hallway, take a left at the fountain, go up the stairs,
give the secretary a bouquet of flowers and take the second blue
door on your right. You can get the key at from the bunny.

That's the group about server configuration. Ask there.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: 29 Jan 1999 00:37:32 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: cgi in perl
Message-Id: <78qvsc$oja@bgtnsc01.worldnet.att.net>

If you are just starting out, you should have a decent book to
eliminate the usual newbie traps before you jump head first into
what you suggest. I found an *excellent* primer for people
wanting to use CGI for Perl if they are totally new to it all.
The book is called...

Perl and CGI for the world wide web
Elizabeth Castro

ISBN 0-201-35358-X
www.peachpit.com

While you will eventually learn other ways of doing things, this
makes starting a breeze.. and it's only about $20.00...will save
you tons of headaches.

Chris Yeates wrote in message <78pfhd$g6$1@fafnir.cf.ac.uk>...
>I am completely new to CGI programming in Perl. I wish to
password protect
>some web pages. Does anybody know how to do this?
>
>Cheers!
>
>Chris
>
>




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

Date: Thu, 28 Jan 1999 16:38:04 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Checking for flock
Message-Id: <36B102EC.5CC87537@vpservices.com>

Thanks for the reply Mike, but your snippets don't work on the platforms
they need to work on. See below.

M.J.T. Guy wrote:
> Jeff Zucker  <jeff@vpservices.com> wrote:
>>Is there a better way to check if flock is implemented on a machine
>>than this subroutine?
>>sub has_flock {
>>    my $flock_status = 1;
>>    open(FH,$0) || die $!;
>>    undef $@;
>>    eval( "flock(FH,8)" );
>>    if ( $@ =~ /unimplemented/ ) { $flock_status = 0; }
>>    close(FH) || die $!;
>>    return $flock_status;
>>}
>
> [snip]
>
> All you need is to do a call of flock().   flock() should die only if
> it isn't implemented.    All other errors just give a false return 
> value.

But I don't want it to die if it is unimplemented, I want it to ignore
the call to flock if (and only if) it is unimplemented.  On a
single-user machine this isn't too risky since it's unlikely anyone else
will be trying to access the file at the same time :-).

> So this should be sufficient (untested - I don't have a platform
> without  flock):

Aye, there's the rub.  Both your snippets return true on win95 but mine
correctly returns false.

> 
> sub has_flock {
>     eval { flock 0, 0 };
>     return ! $@;
> };
> 
> (Note that it's almost always better to use eval{} rather than
> eval(""). )

Ok, thx, I'll remember that.
 
> Or you may wish to do the work at compile time:
> use constant HAS_FLOCK => ! eval { flock 0, 0; 1 };

Good idea about doing it at compile time, but bzzzzt this returns false
on solaris like that.  If I remove the !, it returns true on win95. 
Either way is wrong on at least one platform.

> 
> Mike Guy

-- 
       Jeff Zucker          \/     mailto:jeff@vpservices.com
      Co-coordinator       -<>-    http://www.unicef.org/voy/
   UNICEF Voices of Youth   /\   http://www.vpservices.com/jeff/


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

Date: Fri, 29 Jan 1999 00:11:59 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Detecting string containing no printing chars ?
Message-Id: <slrn7b1v86.5b.alastair@calliope.demon.co.uk>

ajmas@bigfoot.com <ajmas@bigfoot.com> wrote:
>Hi,
>
> I have a perl script that returns the records from a file that contains
> a certain string. Now any fields that do not contain any printing characters
> or are of zero length should be replaced with '&nbsp;'.

If I was you I'd get some test data and write a short perl program as a test bed
for it. Try something out and see what happens. This is quite a basic question -
try harder. Post some code!

Good luck.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Fri, 29 Jan 1999 02:00:11 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Floating point math errors
Message-Id: <LC8s2.64$LH2.5406@nsw.nnrp.telstra.net>

In article <39zp73t2xr.fsf@ibnets.com>,
	Uri Guttman <uri@ibnets.com> writes:
>>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
> 
>   LR> better) do all your arithmetic in integers (pennies, as you say),
>   LR> then divide by 100 to display totals in dollars.
> 
> i always do money calculations as integral pennies and convert on
> i/o. it is clean, accurate and works anyone who does floating point math
> on his money is a fool and will soon be parted from it.

That approach is fine if you don't need a higher resolution than
pennies or cents. If you do, then you simply cannot use this approach.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd.       | why kamikaze pilots wore helmets - Dave
NSW, Australia                      | Edison 


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

Date: Fri, 29 Jan 1999 02:03:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Forms in CGI
Message-Id: <qF8s2.65$LH2.5406@nsw.nnrp.telstra.net>

In article <78qln3$vs0$1@nnrp1.dejanews.com>,
	prakashpatel@hotmail.com writes:

>   print "<input TYPE=text NAME=state size=2 VALUE='@state[$x]'>";
>   print "<input TYPE=hidden NAME=state size=9 VALUE='@zip[$x]'> <BR>";

> The lines with the hidden type doesn't show any thing. IT doesn't
> give me any errors either.

Have you tried looking up what 'hidden' means?

And your perl question is?

You either don't understand CGI, or HTML. Both of those things are
discussed in the comp.infosystems.www.* hierarchy. Please ask there.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: Thu, 28 Jan 1999 14:47:51 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: HELP with string parsing and scoring
Message-Id: <36B0E917.B9796D07@atrieva.com>

Daniel Grisinger wrote:

> See, it only executes the code inside of WH once.  After that your
> global variable has already been incremented high enough that the
> conditional always tests false.  Split is very certainly faster than
> while for this as other benchmarks have demonstrated.

Ack.  I retract it all, and stand corrected.

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Fri, 29 Jan 1999 00:08:55 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Limiting length of datasent from a text box
Message-Id: <slrn7b1v2e.5b.alastair@calliope.demon.co.uk>

Quentin Compson <bcompson@yahoo.com> wrote:
>Hello
>
>How can I go about making sure someone doesn't send my script 
>too much data in a text box?
>
>Should I test for length?

You should really try out a few tests. Doing a 'length' test appears reasonable
to me (given what I have been told).

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Fri, 29 Jan 1999 00:29:13 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: LWP Questions
Message-Id: <slrn7b208h.5b.alastair@calliope.demon.co.uk>

John <John@melon17.freeserve.co.uk> wrote:
>Is there any clear explanation as to how
>you install this module on your server?

Yes. It's called the README.

>How do you call this module from your script?

See the docs.

perldoc LWP
perldoc lwpcook

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 29 Jan 1999 00:32:23 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: More cannot evaluate $query->param('thing')
Message-Id: <78qvin$mr3@bgtnsc01.worldnet.att.net>

I'm finding it somewhat of a pain that I cannot embed
$query->param('client_id') inside of quotes or qq~ ~; in print
statements. Things like...

print qq~<input type="hidden" name="client_id"
value="$query->param('client_id')">~;

create this...

<input type="hidden" name="client_id"
value="CGI=HASH(0x80b5670)->param('client_id')">

I've tried moving it into a scalar first then using the scalar
in the print statement, but it does the same darn thing. Scalars
have always worked with double quotes in the past.. why does it
handle $query a bit differently? Doing this is an easy fix for
single lines...

print $query->param('client_id') . "stuff";

but alot of the time I may have to use a qq~ ~; for about 10
lines of text, and the $query->param('client_id') is placed
around line 4 or 5. I 'd rather not break it up if I can get
around it.

CT





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

Date: 29 Jan 1999 02:11:35 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: More cannot evaluate $query->param('thing')
Message-Id: <83ogninarc.fsf@vcpc.univie.ac.at>

Re: More cannot evaluate $query->param('thing'),
Charles <design@raincloud-studios.com> said:

Charles> I'm finding it somewhat of a pain that I
Charles> cannot embed $query->param('client_id')
Charles> inside of quotes or qq~ ~; in print
Charles> statements. Things like...

Well, why not use all those handy form creating HTML
shortcuts that CGI.pm gives you?  Saves fighting
HTML syntax with perl's syntax.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Wed, 27 Jan 1999 16:00:03 -0500
From: Matthew Foley <Matthew.Foley@rich.frb.org>
Subject: Perl 4.0 Question
Message-Id: <36AF7E53.283D06B8@rich.frb.org>

I have a date script on a NT server running perl 5:
$time = localtime(time());
print $time;

The return format is:
Wed Jan 27 15:45:41 1999

On my NT 4.0 server running perl 4.0 ( a requirement due to other
constrains) this script doesn't not work, and I receive no error code.
Does anyone have any insight as to how to extract the same sort of data
in perl 4.0.1.8 ?

Thanks,
Matt Foley


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

Date: Thu, 28 Jan 1999 20:09:22 -0600
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl 4.0 Question
Message-Id: <uS2DkxyS#GA.159@news1.texas.rr.com>

In article <36AF7E53.283D06B8@rich.frb.org>,
Matthew Foley  <Matthew.Foley@rich.frb.org> wrote:
>
>I have a date script on a NT server running perl 5:
>$time = localtime(time());
>print $time;
>
>The return format is:
>Wed Jan 27 15:45:41 1999
>
>On my NT 4.0 server running perl 4.0 ( a requirement due to other
>constrains) this script doesn't not work, and I receive no error code.
>Does anyone have any insight as to how to extract the same sort of data
>in perl 4.0.1.8 ?

If you have the libraries installed then you can get something close by
saying

  require "ctime.pl";
  $time = &ctime(time);

Hope this helps,

Mike (perl 4 lives on :-)

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
                                   |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Fri, 29 Jan 1999 00:20:00 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: perl DBI CGI and mySQL
Message-Id: <slrn7b1vn7.5b.alastair@calliope.demon.co.uk>

Mike D. <sprintfer@yahoo.com> wrote:
>I am experimenting with mySQL and the DBI and CGI modules.  I have a
>small customer table with idnumber, fname, lname, email, password,
>etc.  
>
>I now can do a simple query via the web to lookup a row.

Use DBI to do the query, get the results and print them out (as HTML maybe). The
docs are quite good.

Get a query running from the command line first.

>I am wonder if I append a row to the table via the web, do I need to
>lock the table (let's assume there are many people using the datbase
>at the same time) - or is the table locked/secure automatically?

The database takes care of this - part of the attraction.

>Also, I was wondering if anyone has any example scripts I can take a
>look at that uses mySQL DBI and the CGI module?  (like the source of
>register.cgi at www.pm.org/source/registration)
>
>I appreciate your help.

Here's my advice - it has served me well. Don't try to run before you can walk.
Take things in stages.

To use perl with the database, use ;

DBI module
Msql-Mysql-modules

Install these and try a test program. Learn how to use the module, however
trivially (connect/disconnect).

For CGI, the docs are very good. Write a test script and get it working - even a
simple HTML page.

Then try and link the two together.

If something doesn't work, there are plenty of people who will try and help. For
pre-written/canned programs, you'll probably have to look elsewhere. 

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Thu, 28 Jan 1999 16:56:11 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Split vs Substr:  The Awful Truth
Message-Id: <36B1072B.4D39769@atrieva.com>

Larry Rosler wrote:

> 
> Maybe you should own up, to set the record straight.  Split is indeed
> faster than a loop on substr, as well as being a lot easier to get right
> (as your serial corrections have dempnstrated).

Yep. You were right, I was wrong.  I fess up.  Mea culpa.  My bad.  I
droped the ball, etc, etc...

However, only *one* of you showed me the error of my ways (or code, as
it were).  Dang warnings.  I never liked them, anyway...

Take it easy on me, please!

TO SPLIT IS HUMAN, SUBSTR - SLOW!   

Oh, Larry, e-mail to you keeps bouncing, so I wasn't able to forward
this to you directly.

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Thu, 28 Jan 1999 18:58:02 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
Subject: Re: Stopping a foreach loop
Message-Id: <36B0F98A.320F6E5F@giss.nasa.gov>

Ryan.Haman@mci.com wrote:

> Is there anyway to break (stop) a foreach loop?

I've always found good ol' <ctrl-C> quite effective
at stopping loops.  <wink>

--
	Fiery Phoenix
	Oh seven-record splendor
	We will correct you


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

Date: Thu, 28 Jan 1999 17:55:55 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Stopping a foreach loop
Message-Id: <36B0F90B.A7DFFA7E@us.ibm.com>

Larry Rosler wrote:
> 
> [Posted and a courtesy copy mailed.]
> 
> In article <78qkep$uqm$1@nnrp1.dejanews.com> on Thu, 28 Jan 1999
> 21:22:44 GMT, Ryan.Haman@mci.com <Ryan.Haman@mci.com> says...
> > Is there anyway to break (stop) a foreach loop?
> 
> perldoc -f last
> perldoc -f return
> perldoc -f exit
> perldoc -f die
> perldoc -f exec
> 
> even (ugh!)
> 
> perldoc -f goto
> 
> That's off the top of my head.  Did I miss any?

system("/sbin/shutdown -r now");

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: 28 Jan 1999 19:02:54 -0500
From: Uri Guttman <uri@ibnets.com>
To: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Stopping a foreach loop
Message-Id: <39ww27t07l.fsf@ibnets.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> [Posted and a courtesy copy mailed.]
  LR> In article <78qkep$uqm$1@nnrp1.dejanews.com> on Thu, 28 Jan 1999 
  LR> 21:22:44 GMT, Ryan.Haman@mci.com <Ryan.Haman@mci.com> says...
  >> Is there anyway to break (stop) a foreach loop?

  LR> perldoc -f last
  LR> perldoc -f return
  LR> perldoc -f exit
  LR> perldoc -f die
  LR> perldoc -f exec

  LR> even (ugh!)

  LR> perldoc -f goto

  LR> That's off the top of my head.  Did I miss any?

next 		slow but if you keep calling it the loop will end :-)

this is very ugly and may not be legal but it works on 5.004_03

@a = ( 1,2,3,4 ) ;
foreach (@a) {
	print ;
	@a = ();
}

eval { any of the above }
eval " any of the above " 

hitting your computer with a baseball bat (very quickly, in the middle
of the loop).

hth,

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: 28 Jan 1999 23:32:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: system function, Pros and Cons??
Message-Id: <78qs28$9k0$1@client2.news.psi.net>

Martien Verbruggen (mgjv@comdyn.com.au) wrote on MCMLXXVI September
MCMXCIII in <URL:news:ei5s2.19$LH2.1585@nsw.nnrp.telstra.net>:
%% 
%% Also, I never call system without specifying the full path to a
%% binary. As Abigail mentioned in another post, people have /usr/bin and
%% /usr/ucb (and on some platforms /usr/xpg4/bin or some other XOpen dir)
%% in their path, but the order of those depends on personal preference.
%% Some people have tools in /usr/local/bin and have that before
%% /usr/bin. I don't ever want to deal with search paths. If I want
%% /usr/ucb/ps, I will call it that.


Well, yes. But if you buy Sybase ASE and want to use its "showserver"
command, it just calls ps. And then which ps it calls depends on your
PATH. /usr/ucb/ps works, /usr/bin/ps doesn't.  Using full paths sounds
nice, but that's not very portible :(. There's no /usr/ucb on HP for
instance.

As I said before, UNIX is a twisty little maze of tools, all different.



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: Thu, 28 Jan 1999 21:11:52 -0500
From: Jeff Hester <jeff@toad.net>
Subject: Re: system function, Pros and Cons??
Message-Id: <36B118E8.709CB6F5@toad.net>

The System() function just happened to be the first solution I found
while riding on the "Camel".

The thing that struck me odd was that the substitution suggested was to
use back tic's vice system.

Don't they do the same thing??  And if they due, would it not be a
better idea to use the perl function primarily coded for this?

SIDE NOTE:The programs being called were "tnfxtract" and "tnfdump". 
These are strictly Solaris 2.6 (and above I assume) functions.  So
portability wasn't a concern (for me anyway ;)


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

Date: Fri, 29 Jan 1999 02:26:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: system function, Pros and Cons??
Message-Id: <i%8s2.67$LH2.5406@nsw.nnrp.telstra.net>

In article <36B118E8.709CB6F5@toad.net>,
	Jeff Hester <jeff@toad.net> writes:
> The thing that struck me odd was that the substitution suggested was to
> use back tic's vice system.
> 
> Don't they do the same thing?? 

No.

system does not return whatever the external program dumps on stdout.
It returns the exit value of the program. Whatever the called program
puts on stdout goes to STDOUT of the calling perl program.

The contents of backticks (or qx()) always get interpolated, and then
passed of to /bin/sh (or whatever the equivalent is on your platform).
stdout of the called stuff is collected and returned.

So: backticks always invoke a shell, system will only invoke a shell
if there is only one argument, and that argument contains shell
metacharacters.

I am probably leaving some things out, but all this is discussed in
the documentation:

# perldoc -f system
# perldoc perlop
/`STRING`

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.       | password?
NSW, Australia                      | 


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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