[13645] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1055 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 14:01:29 1999

Date: Fri, 15 Oct 1999 11:01:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940010473-v9-i1055@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Oct 1999     Volume: 9 Number: 1055

Today's topics:
    Re: CGI File Upload on WinNT <ehpoole@ingress.com>
    Re: CGI File Upload on WinNT <ehpoole@ingress.com>
        CGI Perl <jjyooi@dcs.qmw.ac.uk>
    Re: CGI testing on a Win95 machine <u2orange@bigfoot.com>
    Re: CGI.pm background graphics <pmm@saf.com>
    Re: CGI.pm background graphics (AcCeSsDeNiEd)
    Re: CGI.pm background graphics <jeff@vpservices.com>
    Re: CGI.pm background graphics (Larry Rosler)
    Re: CGI.pm: Setting `Type' for stylesheets - How? <trevor@opentext.com>
    Re: character count <aqumsieh@matrox.com>
        check if 'exe' program on still running in back ground <billbayNObiSPAM@finessealliance.com.invalid>
    Re: check if 'exe' program on still running in back gro harris_m@my-deja.com
        Check if program(exe) still running <billbayNObiSPAM@finessealliance.com.invalid>
        choose a random key of a hash <siganos@cs.ucr.edu>
    Re: choose a random key of a hash (Craig Berry)
    Re: choose a random key of a hash (Peter J. Kernan)
    Re: choose a random key of a hash <rootbeer@redcat.com>
    Re: choose a random key of a hash (Larry Rosler)
    Re: choose a random key of a hash (Larry Rosler)
        combined conditional effort - if and until in one state <tom.kralidis@ccrs.nrcanDOTgc.ca>
        combined conditional effort - if and until in one state <t.dillerNOt.SPAM@xpres.com.invalid>
    Re: combined conditional effort - if and until in one s (Larry Rosler)
        command line Perl <deantran@cup.hp.com>
    Re: command line Perl (Anno Siegel)
    Re: command line Perl <gellyfish@gellyfish.com>
    Re: command line Perl (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Oct 1999 01:31:18 -0400
From: "Ethan H. Poole" <ehpoole@ingress.com>
Subject: Re: CGI File Upload on WinNT
Message-Id: <38041926.FA8208A7@ingress.com>

[posted and emailed]

CS wrote:
> 
> You can upload a file to a remote Unix/Linux server from a browser if you
> first chmod 777 the target directory.
> 
> But if you want to do a similar thing on a remote NT Server, what should you
> do?  What are your options? (besides switching to a non NT server :-)
> 
> I know this isn't exactly a perl question, but I'm making a perl script that
> would do something like this.  I already have one that works fine for a
> linux/unix server.

Set the directory permissions to 'CHANGE', or have the sysadmin do it for
you.

-- 
Ethan H. Poole           ****   BUSINESS   ****
ehpoole@ingress.com      ==Interact2Day, Inc.==
(personal)               http://www.interact2day.com/


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

Date: Wed, 13 Oct 1999 01:32:29 -0400
From: "Ethan H. Poole" <ehpoole@ingress.com>
Subject: Re: CGI File Upload on WinNT
Message-Id: <3804196D.5F029446@ingress.com>

[posted and emailed...email failed: no mailbox provided...resent w/o CC]

CS wrote:
> 
> You can upload a file to a remote Unix/Linux server from a browser if you
> first chmod 777 the target directory.
> 
> But if you want to do a similar thing on a remote NT Server, what should you
> do?  What are your options? (besides switching to a non NT server :-)
> 
> I know this isn't exactly a perl question, but I'm making a perl script that
> would do something like this.  I already have one that works fine for a
> linux/unix server.

Set the directory permissions to 'CHANGE', or have the sysadmin do it for
you.

-- 
Ethan H. Poole           ****   BUSINESS   ****
ehpoole@ingress.com      ==Interact2Day, Inc.==
(personal)               http://www.interact2day.com/


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

Date: Fri, 15 Oct 1999 08:09:12 +0100
From: Johnny 'Loopy' Ooi <jjyooi@dcs.qmw.ac.uk>
Subject: CGI Perl
Message-Id: <3806D318.68976D74@dcs.qmw.ac.uk>


Is it possible to call a Perl script from within a Perl script? I'd like
to have say a script deal with the background of a page and another deal
with the text.

Any help would be good.

-- 
Johnny Ooi. Aliases: Loopy, Tuxedo Mask, Quote Master.....
E-Mail		: jjyooi@dcs.qmw.ac.uk or jjyooi@yahoo.com
WWW		: http://www.dcs.qmw.ac.uk/~jjyooi/
ICQ No          : 6155774

"Stay sane guys!"

===============================================================


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

Date: Fri, 15 Oct 1999 17:25:30 GMT
From: Mat Tillett <u2orange@bigfoot.com>
Subject: Re: CGI testing on a Win95 machine
Message-Id: <3807652B.66CECA5A@bigfoot.com>

Marc wrote:
> 
> Hi,
>         Just curious, runing ActiveState Perl on a Win95 machine. Wondering if
> there was a way I could test out Perl CGI on it.
> 

Yeah, get some web server prog and use that.  I use Xitami
(www.xitami.com) as the config files are really easy to adjust if you
are work on multiple sites (locally before upload).

Mat

u2orange@bigfoot.com


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

Date: Wed, 13 Oct 1999 00:46:43 GMT
From: Penn McClatchey <pmm@saf.com>
Subject: Re: CGI.pm background graphics
Message-Id: <3803D6A8.188A7679@saf.com>

Sean,

Your suggestion works perfectly.  Thanks for your help!

Best regards,

Penn

Sean Malloy wrote:
> 
> Penn McClatchey <pmm@saf.com> wrote:
> 
> >I am trying to use a background graphic, not a color.
> >The file is called "back.gif"  Anyone know how to get
> >it to serve from a Perl file using CGI.pm?
> 
> Try this:
> 
> print $query->start_html(-title=>'Page Title',
>                            -BACKGROUND=>'background.gif',
>                            -BGCOLOR=>'FFFFFF');
> 
> --
> Sean R. Malloy               | American Non Sequitur
>     Naval Medical Center     |       Society
>     San Diego, CA 92134-5000 |
> srmalloy@home.net            | "We may not make sense,
> srmalloy@nmcsd.med.navy.mil  |  but we do like pizza"
> FORMAL NOTICE: unsolicited commercial email will be read
> at a charge of $500 per item. Receipt of such email shall
> be considered to constitute acceptance of contract, and
> will be billed immediately.

-- 
Penn McClatchey
pmm@saf.com
See SAF's aluminum extrusion and sheet store at http://www.saf.com


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

Date: Wed, 13 Oct 1999 09:57:06 GMT
From: dillon_rm@magix.com.sg (AcCeSsDeNiEd)
Subject: Re: CGI.pm background graphics
Message-Id: <380445b8.8549415@news.magix.com.sg>


Hash: SHA1

Normally, when I work with HTML code in Perl, 
I don't bother using quotes (" "). 
That makes life a lot easier.
I'm not sure about other browsers, but HTML without quotes works for
MSIE & Navigator.

Penn, use this instead (extract from your code, change the rest too):

Change:
print "BACKGROUND=\"bakc.gif\""; 

To: 
print "BACKGROUND=\bakc.gif\"; 

Remember, don't use any quotes within your HTML tags.

Btw, like Dan has pointed out, your HTML code is wrong.
even with quotes, the code: BACKGROUND=\"bakc.gif\"
it should be: BACKGROUND="\bakc.gif\" 


On Tue, 12 Oct 1999 04:00:42 GMT, Sean Malloy <srmalloy@home.com>
wrote:

>Penn McClatchey <pmm@saf.com> wrote:
>
>>I am trying to use a background graphic, not a color.
>>The file is called "back.gif"  Anyone know how to get
>>it to serve from a Perl file using CGI.pm?
>
>Try this:
>
>print $query->start_html(-title=>'Page Title',
>                           -BACKGROUND=>'background.gif',
>                           -BGCOLOR=>'FFFFFF');
>
>-- 
>Sean R. Malloy               | American Non Sequitur
>    Naval Medical Center     |       Society
>    San Diego, CA 92134-5000 |
>srmalloy@home.net            | "We may not make sense,
>srmalloy@nmcsd.med.navy.mil  |  but we do like pizza"
>FORMAL NOTICE: unsolicited commercial email will be read
>at a charge of $500 per item. Receipt of such email shall
>be considered to constitute acceptance of contract, and 
>will be billed immediately.


Version: PGPfreeware 6.0.2i

iQA/AwUBOAPmvobzvNYn0WpvEQI77gCdF6ST8/ID8gCYvr0r+YZgUv0moHcAoLUR
HJrQ/YFD50JvVHTWYhhFrVec
=sLNX
-----END PGP SIGNATURE-----

To e-mail me, remove "_rm"

PGP Key on Keyservers
Key ID: 0x27D16A6F
Fingerprint: 8B3E DEF8 216E 04BD C12E  53AC 86F3 BCD6 27D1 6A6F


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

Date: 13 Oct 1999 13:31:22 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: CGI.pm background graphics
Message-Id: <38048961.9C47FBEA@vpservices.com>

AcCeSsDeNiEd wrote:
 
> I'm not sure about other browsers, but HTML without quotes works for
> MSIE & Navigator.

This is an HTML question, not Perl, but if you mean that you can omit
quotes around values of HTML tag attributes, what do you do with
something like:

	<img src="jdog.gif" alt="Jane's dog">

You could omit quotes from the src, but you could not omit them from the
alt, nor could you change them to single quotes.  

> Change:
> print "BACKGROUND=\"bakc.gif\"";
> 
> To:
> print "BACKGROUND=\bakc.gif\";

Have you tried running that?  It gives a runtime error and eliminates
the "b" in "back".  The line you changed it from is ok although better
written as print qq(BACKGROUND="back.gif"), or if you insist on dropping
the quotes around the value, as print qq(BACKGROUND=back.gif).

> Remember, don't use any quotes within your HTML tags.

I'm afraid that is bad advice.  Sean  Malloy's answer with the proper
CGI.pm syntax was good advice.

-- 
Jeff


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

Date: Wed, 13 Oct 1999 07:12:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: CGI.pm background graphics
Message-Id: <MPG.126e33239173b89198a088@nntp.hpl.hp.com>

In article <380445b8.8549415@news.magix.com.sg> on Wed, 13 Oct 1999 
09:57:06 GMT, AcCeSsDeNiEd <dillon_rm@magix.com.sg> says...
> 
> Hash: SHA1

Why do you trouble us with that noise?  Would someone go to the trouble 
of forging your name to these errors?

 ...

> Change:
> print "BACKGROUND=\"bakc.gif\""; 
> 
> To: 
> print "BACKGROUND=\bakc.gif\"; 
                    ^        ^
A backspace and a syntax error.  Kill the backslashes also.
 
> Remember, don't use any quotes within your HTML tags.

What a wonderful, empty-headed generalization!
 
> Btw, like Dan has pointed out, your HTML code is wrong.
> even with quotes, the code: BACKGROUND=\"bakc.gif\"
> it should be: BACKGROUND="\bakc.gif\" 
                            ^        
You seem to have a 'thing' for backspaces in HTML!

<SNIP> Jeopardy-style quote and PGP noise

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


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

Date: Wed, 13 Oct 1999 01:57:56 GMT
From: <trevor@opentext.com>
Subject: Re: CGI.pm: Setting `Type' for stylesheets - How?
Message-Id: <s07pp48kbhk44@corp.supernews.com>

You might want to check out HTML::Template, perl module by Sam Tregar. 
Works quite well, and greatly simplifies separating the logic of your site 
from the presentation. Also nice since your .cgi files stay small (making 
them easier to debug), and you can let the designers work on the "look and 
feel".

http://www.perl.com/CPAN/modules/by-authors/id/S/SA/SAMTREGAR/


David Amann wrote:
> 
> Hi Jerry,
> 
> Jerry Pank wrote:
> 
> > Using CGI.pm, could someone kindly modify my example below, to output:
> >
> > <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> > <HTML><HEAD><TITLE>Stylish Docs</TITLE>
> > <STYLE TYPE="text/css"><!--
> > a:{color:{#000000}....
> >
> > #!/bin/perl5 -w
> > use CGI qw(:all);
> > print header,
> >       start_html(-TITLE => 'Stylish Docs',
> >                  -STYLE =>  "<!--\na:{color:{#000000}
> >                             a:vlink{color:#2222FF}
> >                             a:hover{color:#FF0000}-->\n"),
> >       h1("It's the way you wear it...\n"),
> >       a({-HREF => 'Foo.htm'}, 'Only Me!'),".\n",
> >       end_html;
> 
> Implement your -style tag as follows:
> 
> print start_html("-style" => {"-type" => "text/css",
>                                           "-code" =>
> $your_style_sheet_code
>                              });
> 
> You'll need to make sure your using version 2.38 of CGI.pm or later.  In
> version 2.38 or later you really won't need the '-type' flag.  It should
> default to "text/css" (at least it does for me).
> 
> Hope this helps,
> -=dav
> 
> 
> 


------------------  Posted via CNET Help.com  ------------------
                      http://www.help.com/


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

Date: Thu, 14 Oct 1999 11:06:40 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: character count
Message-Id: <x3ybta26kxs.fsf@tigre.matrox.com>


Colin R. DeVilbiss <crdevilb@mtu.edu> writes:

> Abigail <abigail@delanet.com> wrote:
> > tmac@transport.com (tmac@transport.com) wrote on MMCCXXXII September
> > MCMXCIII in <URL:news:3801A034.37221669@transport.com>:
> > `` Perhaps something like this:
> > `` 
> > `` $_ = "hello world";
> > `` $l_count = push (@each_l, /(l)/gi);
> > `` 
> > `` I'd get a second opinion though:-)
> 
> 
> > *boggle* Why the push?
> 
> >    $_ = "hello, world";
> >    $l_count = y/l//;
> 
> > Or:
> >    $l_count = () = "hello, world" =~ /l/g;
> 
> *boggle boggle*
> 
> if all the poster wanted was to count instances of a char, why didn't
> anyone give him the FAQ?
> 
> perldoc perlfaq4/How do I count occurences of a substring in a string?
> 
> perldoc perlop (tr//)

But, that's what Abigail suggested above:

	$l_count = y/l//;

--Ala



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

Date: Tue, 12 Oct 1999 20:11:19 +1700
From: elf <billbayNObiSPAM@finessealliance.com.invalid>
Subject: check if 'exe' program on still running in back ground
Message-Id: <000b8d9b.99c1835e@usw-ex0102-010.remarq.com>

I know that we can use 'exec' function in Perl to run/activate a
'.exe'program.
And I know the 'Kill' function to check status of the running program.
Anyone care to share with me in detail about the inplmentation of this
'Kill' function. I understand a $pid is needed but I've trouble
implementing the getppid function. Is this function the way to get the
'$pid' required in the 'kill' function. PLs advise.

Thanks all
elf


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Wed, 13 Oct 1999 08:18:26 GMT
From: harris_m@my-deja.com
Subject: Re: check if 'exe' program on still running in back ground
Message-Id: <7u1f8a$96a$1@nnrp1.deja.com>

You did not specify what operating system you are using. I assume you
are on Unix box. In that case following will do it -

$myexe = "my.exe";
$proc = `ps ax | grep $myexe | grep -v grep` ;
if ( $proc eq "") {
   print "my exe is not running\n";
} else {
   print "my exe is running\n";
}

If you are using Windoz, ps command will not work! I don't know much
about Windoz to find some thing similar to ps command in a program.
Harris M.
In article <000b8d9b.99c1835e@usw-ex0102-010.remarq.com>,
  elf <billbayNObiSPAM@finessealliance.com.invalid> wrote:
> I know that we can use 'exec' function in Perl to run/activate a
> '.exe'program.
> And I know the 'Kill' function to check status of the running program.
> Anyone care to share with me in detail about the inplmentation of this
> 'Kill' function. I understand a $pid is needed but I've trouble
> implementing the getppid function. Is this function the way to get the
> '$pid' required in the 'kill' function. PLs advise.
>
> Thanks all
> elf
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion
Network *
> The fastest and easiest way to search and participate in Usenet -
Free!
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 12 Oct 1999 19:08:30 +1700
From: elf <billbayNObiSPAM@finessealliance.com.invalid>
Subject: Check if program(exe) still running
Message-Id: <0a0133f8.895e72c7@usw-ex0102-010.remarq.com>

I would like to discuss here methods of checking if certain exe. program
is still running in the background of the OS. I've heard about the
'kill'function but it involved the '$pid' element. Can anyone able to
elaborate on that. Or is there other ways of checking status of a
running program?




* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Tue, 12 Oct 1999 14:36:03 +0100
From: "Siganos Giwrgos" <siganos@cs.ucr.edu>
Subject: choose a random key of a hash
Message-Id: <7u058t$149$1@pravda.ucr.edu>

Hi ,
I would like to ask if there is a way to choose a random key of a hash.
George




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

Date: Tue, 12 Oct 1999 21:56:21 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: choose a random key of a hash
Message-Id: <s07bk5s4bhk57@corp.supernews.com>

Siganos Giwrgos (siganos@cs.ucr.edu) wrote:
: I would like to ask if there is a way to choose a random key of a hash.

This code illustrates one technique.  As a simple sanity check, it uses
numeric keys, determines the average key value selected over multiple
iterations, and compares that with the expected value for a flat
distribution of key choices.

#!/usr/bin/perl -w
# randkey -- choose a hash key at random
# Craig Berry (19991012)

use strict;

my %the_hash = ( 1 => 'a', 2 => 'b', 3 => 'c', 4 => 'd' );
my @keys     = keys %the_hash;
my $sum      = 0;
my $iters    = 10_000;

foreach (1 .. $iters) {
  my $randkey  = $keys[rand @keys];
  $sum += $randkey;
}

print "Average = ", $sum/$iters, " (expected value: 2.5)\n";
__END__

/usr2/people/cberry > randkey
Average = 2.4888 (expected value: 2.5)

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "There it is; take it."  - William Mulholland


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

Date: 12 Oct 1999 22:19:45 GMT
From: pete@theory2.phys.cwru.edu (Peter J. Kernan)
Subject: Re: choose a random key of a hash
Message-Id: <slrn807d01.hdi.pete@theory2.phys.cwru.edu>

On Tue, 12 Oct 1999 14:36:03 +0100, 
   Siganos Giwrgos <siganos@cs.ucr.edu> wrote:
 .=Hi ,
 .=I would like to ask if there is a way to choose a random key 
   of a hash.

$ran_key = $a{(keys%a)[int(rand scalar keys%a)]};

--
Pete


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

Date: Tue, 12 Oct 1999 15:20:48 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: choose a random key of a hash
Message-Id: <Pine.GSO.4.10.9910121516260.19155-100000@user2.teleport.com>

On Tue, 12 Oct 1999, Siganos Giwrgos wrote:

> I would like to ask if there is a way to choose a random key of a hash.

Yes, there is. 

    sub rand_key (\%) {
	my $hash = shift;
	(keys %$hash)[rand keys %$hash];
    }

Cheers!

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



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

Date: Tue, 12 Oct 1999 15:20:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: choose a random key of a hash
Message-Id: <MPG.126d53f0a774769498a082@nntp.hpl.hp.com>

In article <7u058t$149$1@pravda.ucr.edu> on Tue, 12 Oct 1999 14:36:03 
+0100, Siganos Giwrgos <siganos@cs.ucr.edu> says...
> I would like to ask if there is a way to choose a random key of a hash.

my $random_key = (keys %hash)[rand keys %hash];

This uses the properties of the keys() function:  to return a list of 
the keys in list context, and the number of keys in scalar context.

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


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

Date: Tue, 12 Oct 1999 16:05:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: choose a random key of a hash
Message-Id: <MPG.126d5ea18c321e7198a085@nntp.hpl.hp.com>

In article <slrn807d01.hdi.pete@theory2.phys.cwru.edu> on 12 Oct 1999 
22:19:45 GMT, Peter J. Kernan <pete@theory2.phys.cwru.edu> says...
> On Tue, 12 Oct 1999 14:36:03 +0100, 
>    Siganos Giwrgos <siganos@cs.ucr.edu> wrote:
> .=I would like to ask if there is a way to choose a random key 
>    of a hash.
> 
> $ran_key = $a{(keys%a)[int(rand scalar keys%a)]};

This returns a randomly chosen *value* from a hash, not the random key 
itself.

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


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

Date: Wed, 13 Oct 1999 13:20:14 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: combined conditional effort - if and until in one statement
Message-Id: <3804BF4E.90C1FD63@ccrs.nrcanDOTgc.ca>

Hi,

I've written a file to extract and manipulate some data, based on error
histograms.  Each process (function), makes alterations on the file in
question (let's say "file.txt"), trying to correct it based on valid
sample id's.  When the file is corrected, an output file is made (let's
say "file.out").  I would like these subroutines to keep looping until
the file is corrected or there are not enough valid samples left to
manipulate in file.txt (let's say 4 id's).

How could one code this to happen?

I've tried 

if ((!-e "file.out) || until ($validPoints < 4))
{
 dostuff0();
 dostuff1();
}

 ..with no luck.  Note that the $validPoints is not set until the
subroutines.  Could I set it before the 'if' to an arbitrary number,
higher than 4 so it passes the first condition, then is assigned the
currect value as per the value returned by the function?

Any ideas??

Thanks

 ..Tom
-- 

-----------------------------------------------------------------------------------------
Tom Kralidis                                  Geo-Spatial Technologist 
Canada Centre for Remote Sensing              Tel: (613) 947-1828
588 Booth Street , Room 241                   Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7                     http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------


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

Date: Wed, 13 Oct 1999 12:20:40 -0700
From: Tim Diller <t.dillerNOt.SPAM@xpres.com.invalid>
Subject: combined conditional effort - if and until in one statement
Message-Id: <2750ac20.b95b9348@usw-ex0102-012.remarq.com>

In article <3804BF4E.90C1FD63@ccrs.nrcanDOTgc.ca>, Tom Kralidis
<tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:
<snip>
> How could one code this to happen?
> I've tried
> if ((!-e "file.out) || until ($validPoints < 4))
> {
>  dostuff0();
>  dostuff1();
> }
> ...with no luck.
How about this:

until($validPoints < 4) {
  if(-e "file.out") {
    last;
  }
  DoStuff();
}

> Note that the $validPoints is not set until the
> subroutines.  Could I set it before the 'if' to an arbitrary
> number,
> higher than 4 so it passes the first condition, then is assigned
> the
> currect value as per the value returned by the function?

That'd work.

> Thanks
> ...Tom



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Wed, 13 Oct 1999 11:50:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: combined conditional effort - if and until in one statement
Message-Id: <MPG.126e7445992405f998a08a@nntp.hpl.hp.com>

In article <3804BF4E.90C1FD63@ccrs.nrcanDOTgc.ca> on Wed, 13 Oct 1999 
13:20:14 -0400, Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> says...
> I've written a file to extract and manipulate some data, based on error
> histograms.  Each process (function), makes alterations on the file in
> question (let's say "file.txt"), trying to correct it based on valid
> sample id's.  When the file is corrected, an output file is made (let's
> say "file.out").  I would like these subroutines to keep looping until
> the file is corrected or there are not enough valid samples left to
> manipulate in file.txt (let's say 4 id's).
> 
> How could one code this to happen?
> 
> I've tried 
> 
> if ((!-e "file.out) || until ($validPoints < 4))
> {
>  dostuff0();
>  dostuff1();
> }
> 
> ..with no luck.  Note that the $validPoints is not set until the
> subroutines.  Could I set it before the 'if' to an arbitrary number,
> higher than 4 so it passes the first condition, then is assigned the
> currect value as per the value returned by the function?

You are probably looking for the constructs:

  do BLOCK while EXPR;

  do BLOCK until EXPR;

Here's what perlsyn says about them:

The while and until modifiers have the usual ``while loop'' semantics 
(conditional evaluated first), except when applied to a do-BLOCK (or to 
the now-deprecated do-SUBROUTINE statement), in which case the block 
executes once before the conditional is evaluated. This is so that you 
can write loops like: 

    do {
        $line = <STDIN>;
        ...
    } until $line eq ".\n";

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


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

Date: Wed, 13 Oct 1999 16:06:49 -0700
From: Dean Tran <deantran@cup.hp.com>
Subject: command line Perl
Message-Id: <38051088.8621A3FB@cup.hp.com>



Is there anyway to make Perl behaves like sh/ksh in command line mode?

I really like Perl, but I also want to use it as a command line, so I
can
execute perl one line at a time, instead of executing a whole Perl
program.

any idea?

Dean





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

Date: 14 Oct 1999 10:50:01 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: command line Perl
Message-Id: <7u4cgp$cb6$1@lublin.zrz.tu-berlin.de>

Dean Tran  <deantran@cup.hp.com> wrote in comp.lang.perl.misc:
>
>
>Is there anyway to make Perl behaves like sh/ksh in command line mode?
>
>I really like Perl, but I also want to use it as a command line, so I
>can
>execute perl one line at a time, instead of executing a whole Perl
>program.
>
>any idea?

Look for the -e switch in perldoc perlrun.

Anno


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

Date: 14 Oct 1999 14:30:40 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: command line Perl
Message-Id: <3805db00_2@newsread3.dircon.co.uk>

Dean Tran <deantran@cup.hp.com> wrote:
> 
> 
> Is there anyway to make Perl behaves like sh/ksh in command line mode?
> 
> I really like Perl, but I also want to use it as a command line, so I
> can
> execute perl one line at a time, instead of executing a whole Perl
> program.
> 

Look at the perlrun manpage.

/J\
-- 
"Nourishes at the root and penetrates right to the tip" - Pantene
Advertisement


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

Date: Thu, 14 Oct 1999 06:42:22 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: command line Perl
Message-Id: <e2c4u7.333.ln@magna.metronet.com>

Dean Tran (deantran@cup.hp.com) wrote:

: Is there anyway to make Perl behaves like sh/ksh in command line mode?

: any idea?


   One idea might be to check the Perl FAQs before posting to
   the Perl newsgroup!



   Perl FAQ, part 3:

      "How can I use Perl interactively?"

      "Is there a Perl shell?"


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


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 1055
**************************************


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