[16223] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3635 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 12 11:10:33 2000

Date: Wed, 12 Jul 2000 08:10:22 -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: <963414621-v9-i3635@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 12 Jul 2000     Volume: 9 Number: 3635

Today's topics:
    Re: Getting number of running processes in a cron job ? <e.bras@hccnet.nl>
        HELP! Problem with warning on filehandle <ed@nospam.com>
    Re: HELP! Problem with warning on filehandle <thoren@southern-division.com>
    Re: HELP! Problem with warning on filehandle (Tad McClellan)
    Re: how to make my program with csh <care227@attglobal.net>
    Re: interacting perl w/ nt/dos (Young H Lee)
        Intercept MSDOS messages <sebastien.cottalorda1@libertysurf.fr>
    Re: Jeopardy Style (Again!) [Was: multidimensional asso <DNess@Home.Com>
    Re: Method to obfuscate or disguise Perl source code? <mc@backwoods.org>
    Re: Method to obfuscate or disguise Perl source code? <care227@attglobal.net>
    Re: Method to obfuscate or disguise Perl source code? <DNess@Home.Com>
    Re: multidimensional associative arrays <phil.rennert@ioip.com>
    Re: Never satisfied (Bernard El-Hagin)
        Odd problem with qx in ActivePerl bowp@my-deja.com
    Re: Odd problem with qx in ActivePerl <kjetilskotheim@iname.com>
        Perl equivalent of shell command "clear" <karlh@midco.net>
    Re: Perl equivalent of shell command "clear" (Bernard El-Hagin)
        perl on Windows NT web server (Mike Burnett)
        Perl... the split function <mcnultya@nortelnetworks.com>
    Re: Raise Exception when failure occurs ?? <W.Hielscher@mssys.com>
    Re: Raise Exception when failure occurs ?? <perin@panix.com>
    Re: Raise Exception when failure occurs ?? (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 12 Jul 2000 12:21:39 +0200
From: "Ed Bras" <e.bras@hccnet.nl>
Subject: Re: Getting number of running processes in a cron job ??
Message-Id: <8khgqd$1ss$1@enterprise.cistron.net>


Ade Talabi <adetalabi@clara.co.uk> wrote in message
news:396C3F95.1AEDD10B@clara.co.uk...
> Ed Bras wrote:
> >
> > Could you please give me a little bit of advise on the following:
> >
> > In a function a give back the number ofrunning processes of the pocess
that
> > is given as input argument.
> > I do that by:
> > $_ = `ps -A | grep <process>`
> > $lv_Num = s/<process>/<process>/g
> >
> > which works, but when I run the application as a cronjob and call the
> > function I don't receive the output of the `...` command as all the
output
> > is redirected when starting the cron job: <app nam> > /dev/null 2>&1
> >
> > What is a good way to get the number of processes ?
> > I was thinking about:
> > 1: a file locking mechanisme to overcome that a nother application
starts,
> > but this only works for one application, not if I want to allow more
> > applications running at the same time
> > 2: not redirecting the output when starting the cronjob, but doning this
in
> > the application after calling the funtion that gives back the number of
> > processed running (which is at the beginning of the application). But I
> > don't no if I then already receive email from the cronjob which I
certainly
> > don't want.
> >
> > Please, some advice on how to do this,
> >
> > Regards,
> > Ed Bras
>
>
> When you run jobs in cron you hae to give the absolute path. Try that.
>
> ie rather than say myfile.sh, you would have to supply
> /home/edbaras/scripts/myfile.sh
>
>
> --
> /--------------------------------------------------------------\
> | Ade  Talabi     | Internet : adetalabi@clara.co.uk           |
> |  ::M1ETW::      | Web Page : http://www.net-africa.com       |
> \--------------------------------------------------------------/

Thanks Ade,

You mean that I have to give the full path in the ps -A | grep <filename>
command ? to get back th correct process info ?

But do I get something back, as I had the idea that, because I do start the
cron job with <jobname> > /dev/null 2>&2, I don't receive any output from
the `grep ...` command ??

Ed




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

Date: Wed, 12 Jul 2000 11:43:18 GMT
From: "Ed Foy" <ed@nospam.com>
Subject: HELP! Problem with warning on filehandle
Message-Id: <qRYa5.53418$NP5.1695094@newsread2.prod.itd.earthlink.net>

Environment: Perl 5.00404 on UNIX.

My 12-year-old daughter has decided to learn Perl. She is getting a
warning on a filehandle that neither of us can figure out. Here is her
source code:

#!/usr/local/bin/perl5 -w

require 5.004;

package EMAIL;

sub SendMail {

    my ($To,$From,$Subject,$Body) = @_;

    open (SENDMAIL, "|/usr/lib/sendmail -oi -t") or die "Cannot open
mail program: $!\n";

    print SENDMAIL <<"EndOfMail";
To: $To
From: $From
Subject: $Subject

$Body

EndOfMail

    close(SENDMAIL);
    die "Mail program failed: $?" if $?;
}

1;

When the above subroutine is called, Perl gives the following warning:

"Use of uninitialized value at EMAIL.pl line 13."

Perl is complaining about the "print SENDMAIL..." line. I can see no
problem with the here document. The filehandle SENDMAIL is initialized.
There are no variables in the main program that have either the name
SENDMAIL or EndOfMail. I can find no problems with the code and the
subroutine works as expected, that is, sends mail. I'm stumped. Does
anyone have an idea as to what this warning message is about?

BTW, I know there are Perl modules to send mail. That is not an answer
to this problem. This is a learning exercise so understanding why the
error message is occurring is the objective.

Thanks!





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

Date: Wed, 12 Jul 2000 14:23:37 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: HELP! Problem with warning on filehandle
Message-Id: <8kho1h$c0m$18$1@news.t-online.com>

Ed Foy <ed@nospam.com> wrote in message
news:qRYa5.53418$NP5.1695094@newsread2.prod.itd.earthlink.net...

>     my ($To,$From,$Subject,$Body) = @_;

> When the above subroutine is called, Perl gives the following warning:
>
> "Use of uninitialized value at EMAIL.pl line 13."
>
> Perl is complaining about the "print SENDMAIL..." line.

Perl is complaining about one of the values that are used in the print
statement. one/some of them is/are uninitialized.

i think your funktion "SendMail" is not called with 4 initialized arguments.

check that out.

gruß
thoren
8#X

--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com




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

Date: Wed, 12 Jul 2000 09:20:13 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP! Problem with warning on filehandle
Message-Id: <slrn8mos4d.65s.tadmc@magna.metronet.com>

On Wed, 12 Jul 2000 11:43:18 GMT, Ed Foy <ed@nospam.com> wrote:

>Subject: HELP! Problem with warning on filehandle
          ^^^^^
          ^^^^^

You might want to avoid doing that in the future, as it likely
*reduces* the number of people that will read your article.

I have that 5-character substring in my (scoring) killfile.

Most days I don't have time to look down there in the auto-deleted
posts. I had a little extra time today, else I wouldn't have seen
it either.


You have only 40 precious characters to out-compete the other
199 posts in a day (Nobody reads _all_ of them. Most filter
based on what is in the Subject: header).

Spending five of your 40 on pleading is unwise.

_Every_ post here wants "Help!".

Including it does not add any useful information.

(despite the fact that _I_ make use of it :-)



   "Choosing Good Subject Lines":

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



>Environment: Perl 5.00404 on UNIX.
>
>My 12-year-old daughter has decided to learn Perl. 


Way cool!


>She is getting a
>warning on a filehandle that neither of us can figure out. Here is her
>source code:
>
>#!/usr/local/bin/perl5 -w


use strict;     # teach her to put on her seat belt!

(though you may already have this in the main program)


>require 5.004;
>
>package EMAIL;
>
>sub SendMail {
>
>    my ($To,$From,$Subject,$Body) = @_;


See if adding this debugging code helps (untested):

   warn "\$To is undef\n" unless defined $To;
   warn "\$From is undef\n" unless defined $From;
   warn "\$Subject is undef\n" unless defined $Subject;
   warn "\$Body is undef\n" unless defined $Body;


>    open (SENDMAIL, "|/usr/lib/sendmail -oi -t") or die "Cannot open
>mail program: $!\n";


Your diagnostic message is a little misleading there.

If the die() executes, it will NOT be anything related to the
program that you are trying to invoke.

See the Perl FAQ, part 8:

   "Why doesn't open() return an error when a pipe open fails?"



>    print SENDMAIL <<"EndOfMail";
>To: $To
>From: $From
>Subject: $Subject
>
>$Body
>
>EndOfMail
>
>    close(SENDMAIL);
>    die "Mail program failed: $?" if $?;
>}
>
>1;
>
>When the above subroutine is called, 


You should have shown us the _call_, that may show where the problem is...


>Perl gives the following warning:
>
>"Use of uninitialized value at EMAIL.pl line 13."


When perl says "uninitialized value" think "undef".


>Perl is complaining about the "print SENDMAIL..." line. 


Which includes all of the here-doc too (parsers just make
their "best guess" when giving line numbers).

One of the 4 variables in the here-doc has the undef value.


>I can see no
>problem with the here document. 


Me either.

But the variables are set from subroutine args, but we cannot
see the args that it was called with.


>The filehandle SENDMAIL is initialized.


Filehandles do not generate that warning message, variables do.


>There are no variables in the main program that have either the name
>SENDMAIL or EndOfMail. 


First, neither of those are variables (variables start with a
"funny character": $, @, %).

(well, first-class variables do anyway)


SENDMAIL is a filehandle.

EndOfMail is a string terminator.


Second, even if they were variables (let's discuss $To for instance),
having a $To in the main program file would not be a problem, because
$To is a lexical variable in your "library" file. 

( I assume separate files, since you end the one above with  1; )

my()d variables cannot be seen/affected in any file other than the 
file that contains the my() statement.



>I can find no problems with the code and the
>subroutine works as expected, that is, sends mail. I'm stumped. Does
>anyone have an idea as to what this warning message is about?


Have you looked up what the authors of the message have to say
about their message?

    perldoc perldiag



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


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

Date: Wed, 12 Jul 2000 09:50:06 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: how to make my program with csh
Message-Id: <396C778E.5B8025F9@attglobal.net>

doco wrote:
> 
> Drew Simonis (care227@attglobal.net) ´£¨ì:
> : doco wrote:
> : I notice English isn't your native language, so lets make sure
> : I understand your question: You have the example below written
> : in c shell syntax, and you would like to convert it to Perl, right?
> 
> I need to know "Redirect the standard output to  a  file" under PERL
> using "csh" commands,not "sh".
> Tell me in details,please. Thx.

Perl uses sh when it executes external commands via any of the means 
I've specified.  And besides, you shouldn't be trying to use csh 
syntax in Perl, thats backwards.  If you are going to use Perl,
USE it.  You'll find Perl is much more powerfull than csh once you
get a little more comfortable.


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

Date: 12 Jul 2000 13:19:09 GMT
From: yhlee@mail.med.upenn.edu (Young H Lee)
Subject: Re: interacting perl w/ nt/dos
Message-Id: <8khr8d$667$1@netnews.upenn.edu>

Yeah, I did that but the stuff on there was admittedly over my head.  I 
was hoping someone here could provide a clearer (perhaps by example) 
solution. Thanks anyway.

-young

: The answers to 99% of your Perl questions are as close as your
: harddrive.

: Read:

: perldoc -f system

: for the answer to your current question.

: Then, learn to fish:

: perldoc perldoc
: perldoc perl

: - Tom

--
-----
Young H. Lee

"Never try to teach a pig to sing.  It wastes your time and annoys the pig."



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

Date: Wed, 12 Jul 2000 15:53:06 +0100
From: "Sébastien Cottalorda" <sebastien.cottalorda1@libertysurf.fr>
Subject: Intercept MSDOS messages
Message-Id: <8kht7i$g4r$1@news4.isdnet.net>

Hi all,

I'm looking for the way to intercept MSDOS messages when I execute a .BAT
program from a perl script.

On Linux, I use to do that :

$command='ls -l';
$result=qx{$command};

But it doesn't work on Win95 (MsDos), the $result variable is empty, even if
the executed $command produce something on the screen.

ex: :
$command = 'echo Hello_World';
$result=qx{$command};
print '|'.$result.'|';
exit 0;

produce :
C:> perl foo.pl

Hello_World             --> Echo execution
||                               --> the $result variable
C:>



If anybody as a clue.
I preffer not redirect output toward a temporary file and read it with my
script (if it's possible).

Thanks in advance.

Sebastien




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

Date: Wed, 12 Jul 2000 14:51:46 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: Jeopardy Style (Again!) [Was: multidimensional associative arrays]
Message-Id: <396C85F7.45D24FA7@Home.Com>

Philip Rennert wrote:
> 
> I don't know what you mean by "Jeopardy style".
> Am I not stating this clearly?  With a non-associative array, you can specify the
 ....

`Jeopardy style' means commenting above the quoted text. You don't do that
in this newsgroup.

When asking questions in _any_ newsgroup it is a wise idea to read the
group for a while in order to understand its `style'. c.l.p.m is a _very_
active group with a large volume of messages, and `style' is important in
such a group because if everyone does things their own way it imposes a
substantial burden on the people who `do the work' of responding to 
questions.

So when you quote text of previous messages, put your comments after the
quoted text. It is ok, I believe, to interleave comments in the quoted text,
but the comments should follow quotes, not preceed them.


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

Date: Wed, 12 Jul 2000 09:26:40 -0400
From: MC <mc@backwoods.org>
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <396C7210.81558636@backwoods.org>

Jerome O'Neil wrote:
> 
> Drew Simonis <care227@attglobal.net> elucidates:
> > Tad McClellan wrote:
> >>
> >> You don't have to "copyright" it.
> >>
> >> If you write it, it is already copyrighted by you (you don't have
> >> to "do anything" to get it copyrighted. You may have to do something
> >> to _keep_ the copyright though).
> >>
> >> (of course, all of that depends on what country you live in...)
> >>
> >> I think "license" is the term Drew was (or should have been anyway)
> >> looking for.
> >>
> >
> > Neh, I meant copyright.  You are correct, you don't _have_ to
> > do anything but author the program to have copyright rights, but
> > a copyright in the work of authorship is not legally defendable
> > in the US.  In order to secure legal protection of a copyright
> > (the thrust of my post) that copyright _must_ be registered.
> 
> The law states that registration prevents an infringer from
> claiming innocence due to ignorance in his defence.  It has
> to do with your right to recover damages.  The work is always
> protected.
> 

I thought, at least in the US, that 'ignorance' of the law was not a valid
defense for any 'crime'. Hmmmm perhaps I should pracitice my 'innocent' look and
try to get out of a few speeding tickets ("im sorry officer, i havent seen a
speed limit sign in several miles") <G>

MC

> >
> > http://www.loc.gov/copyright/circs/circ1.html#cr

-- 
---------------------------------------------------------------------
My email address(s) are my private property.  They are NOT to be used
or recorded for ANY reason without my explicit permission.  Disregard
of this statement is in violation of federal privacy & copyright law.
---------------------------------------------------------------------
"The world wont end with a bang, or even a whimper, but with an error
message." -- format C:


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

Date: Wed, 12 Jul 2000 10:08:29 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <396C7BDD.C985778@attglobal.net>

MC wrote:
> 
> 
> I thought, at least in the US, that 'ignorance' of the law was not a valid
> defense for any 'crime'. Hmmmm perhaps I should pracitice my 'innocent' look and
> try to get out of a few speeding tickets ("im sorry officer, i havent seen a
> speed limit sign in several miles") <G>
> 

Ignorance is not a defense.  You'll still have to stop using the 
copyrighted material, but how can you be held liable for something
you had no way of knowing existed?


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

Date: Wed, 12 Jul 2000 14:53:47 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: Method to obfuscate or disguise Perl source code?
Message-Id: <396C8670.2517C09@Home.Com>

brian d foy wrote:
> 
> In article <slrn8mmpda.nq.siliconcowboy@erato.bigredrockeater.com>, siliconcowboy@home.com posted:
> 
> > I'm looking for a program that would obfuscate, disguise, or camouflage
> > Perl source code.
> 
> the problem is that thre are Perl beautifiers that are easy to use
> and will undo all of your work to obfuscate the code.
> 

Can you give me a pointer to some of the `Perl beautifiers'? I have searched
both Alta Vista and Google and I keep finding beautifers that are _written_
in perl, but which `beautify' other things (C/C++, Java, ...) not perl
itself.


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

Date: Wed, 12 Jul 2000 09:02:27 -0400
From: Philip Rennert <phil.rennert@ioip.com>
Subject: Re: multidimensional associative arrays
Message-Id: <396C6C63.7D7AE5EA@ioip.com>

I don't know what you mean by "Jeopardy style".
Am I not stating this clearly?  With a non-associative array, you can specify the
values of any indices you want, and vary the others, like $a[4][$j][6][$k], inside
loops on $j and $k.
How do you do the same thing for associative arrays?  What you showed me I think
works only on the first index, because how can Perl know that in $a{Fred} you mean
Fred to be in the third index, say...

Abigail wrote:

> Philip Rennert (phil.rennert@ioip.com) wrote on MMDVI September MCMXCIII
> in <URL:news:396B65ED.C1F2E55E@ioip.com>:
> ~~
> ~~ (Sorry I didn't state it more clearly.)
>
> You're still quoting Jeopardy style. Don't do that if you desire an
> answer.
>



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

Date: Wed, 12 Jul 2000 10:34:28 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Never satisfied
Message-Id: <slrn8moi52.9rf.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 12 Jul 2000 10:40:39 +0100, John <john@nomailplease> wrote:
>At last I feel the arcane mystery of regex starting to reveal itself to me !
>
>However chuffed I am that my code below works I would appreciate it if
>someone would show me how it could be done a bit better.
>I'm sure it could be done in two lines by not destroying the RHS but am
>stumped.
>
>Thanks, JohnShep
>
>  $alpha = $numeric = $string_in;
>  $alpha =~ s/[\W]|[\d]//g; # remove any non letters
>  $numeric =~ s/[\D]//g; # remove any non digits

If you want these in two different variables (as you seem to ) then the
only improvements and/or simplifications I can think of are:

$alpha =~ s/[\W\d]//g;

and

$numeric =~ s/\D//g;

Bernard
--
perl -e '$_="B$[$]e$[$]r$[$]n$[$]a$[$]r$[$]d$[$]\n";print split/05\.006/;'


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

Date: Wed, 12 Jul 2000 13:47:40 GMT
From: bowp@my-deja.com
Subject: Odd problem with qx in ActivePerl
Message-Id: <8khsts$8a0$1@nnrp2.deja.com>

I have an odd problem with a script I've written. I've minimised the program
down to the following. Am I doing something stupid? (I've also tried it with
backticks, with the same results). From what I can see, the data I want to
capture's disappearing off to STDERR.

I've upgraded to ActivePerl 615 (5.6.0) with no joy.

Thanks, Phil.

------Test session follows----

C:\My Documents\Phil's Files\Computing>perl -w perlproblem.pl

 Volume in drive C is LAPTOP_C
 Volume Serial Number is 3A35-10FC
 Directory of C:\Temp2

 .              <DIR>        24/03/00   9:01 .
 ..             <DIR>        24/03/00   9:01 ..
PHILBO~1 OR3     1,785,856  12/07/00  10:35 Phil Bowman.OR3
TAPESP~1 XLS        14,336  05/07/00  11:10 Tape Spreadsheet.xls
TAPEJ-~1 DOC        20,480  05/07/00  11:11 Tape J-cards.doc
PHILIP~1 MBF     5,687,016  12/07/00  12:48 Philip's Money Backup.mbf
BACKUP~1 WBK        20,480  05/07/00  11:00 Backup of Tape J-cards.wbk
         5 file(s)      7,528,168 bytes
         2 dir(s)     133,464,064 bytes free
------------------------

C:\My Documents\Phil's Files\Computing>perl -w perlproblem.pl > wierd.txt

 Volume in drive C is LAPTOP_C
 Volume Serial Number is 3A35-10FC
 Directory of C:\Temp2

 .              <DIR>        24/03/00   9:01 .
 ..             <DIR>        24/03/00   9:01 ..
PHILBO~1 OR3     1,785,856  12/07/00  10:35 Phil Bowman.OR3
TAPESP~1 XLS        14,336  05/07/00  11:10 Tape Spreadsheet.xls
TAPEJ-~1 DOC        20,480  05/07/00  11:11 Tape J-cards.doc
PHILIP~1 MBF     5,687,016  12/07/00  12:48 Philip's Money Backup.mbf
BACKUP~1 WBK        20,480  05/07/00  11:00 Backup of Tape J-cards.wbk
         5 file(s)      7,528,168 bytes
         2 dir(s)     138,969,088 bytes free

C:\My Documents\Phil's Files\Computing>type wierd.txt
------------------------

C:\My Documents\Phil's Files\Computing>type perlproblem.pl
$listing = qx,dir c:\\Temp2,;

print "------------------------\n";

print $listing;

C:\My Documents\Phil's Files\Computing>


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


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

Date: Wed, 12 Jul 2000 15:26:22 +0200
From: Kjetil Skotheim <kjetilskotheim@iname.com>
To: bowp@my-deja.com
Subject: Re: Odd problem with qx in ActivePerl
Message-Id: <396C800E.1EEDF9CD@iname.com>


bowp@my-deja.com wrote:
> 
> I have an odd problem with a script I've written. I've minimised the program
> down to the following. Am I doing something stupid? (I've also tried it with
> backticks, with the same results). From what I can see, the data I want to
> capture's disappearing off to STDERR.

There is no consept of STDERR in DOS!!?! Both the following
tests works fine on my ActivPerl 5.005_02 build 509 on Win95:

perl -e "print length(`dir c:\\`).\"\n\""
perl -e "print length(qx,dir c:\\,).\"\n\""

 
> I've upgraded to ActivePerl 615 (5.6.0) with no joy.

(why?)
 
> Thanks, Phil.
> 
>>>...
> $listing = qx,dir c:\\Temp2,;
> 
> print "------------------------\n";
> 
> print $listing;
> 
> C:\My Documents\Phil's Files\Computing>
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

-- 
Kjetil Skotheim
kjetilskotheim@iname.com


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

Date: Wed, 12 Jul 2000 07:33:37 -0500
From: Karl Harris <karlh@midco.net>
Subject: Perl equivalent of shell command "clear"
Message-Id: <396C65A1.8D720F6C@midco.net>

I have written a little program that offers of menu to the user in a
terminal window. Before the menu is presented I would like to clear the
terminal window so the menu begins at the top of the terminal window.

Does perl do anthing like this?

Thanks.

karl
karlh@midco.net


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

Date: Wed, 12 Jul 2000 12:35:06 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Perl equivalent of shell command "clear"
Message-Id: <slrn8mop79.9rf.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 12 Jul 2000 07:33:37 -0500, Karl Harris <karlh@midco.net> wrote:
>I have written a little program that offers of menu to the user in a
>terminal window. Before the menu is presented I would like to clear the
>terminal window so the menu begins at the top of the terminal window.
>
>Does perl do anthing like this?

If you'd tried:

perldoc -q screen

you'd have found the answer all by yourself in perlfaq8.

Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#


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

Date: 12 Jul 2000 13:51:39 GMT
From: mnb@ornl.gov (Mike Burnett)
Subject: perl on Windows NT web server
Message-Id: <8kht5b$jcv$1@sws1.ctd.ornl.gov>

In the following script, myprog.exe is a program that loops forever.  I
can run this in a DOS window on a Windows NT system, and it works as I
expect (and how I need it to work).  myprog starts execution; and after
5 seconds, the myprog process terminates and the perl script terminates.

#!/usr/local/bin/perl -w

use CGI ":standard";

$pi = open (FOO,"|myprog.exe");
print "$pi pid\n";
sleep 5;
kill 9, $pi;
close FOO;

I put this exact code into a perl script that will generate a web page
on a Windows NT Server running IIS web server. When I open the perl
script from Netscape, I always get an error message when myprog
starts.  (myprog does start as can be seen in the Task Manager.  The
error has nothing to do with the program not being found, for example.)

Can someone provide a fix?  If so, please provide a code fragment
rather than simply a pointer to some perl documentation.  (I learn more
easily by example than by reading documentation.)

Mike Burnett
burnettmn@ornl.gov


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

Date: Wed, 12 Jul 2000 15:18:52 +0100
From: Antony <mcnultya@nortelnetworks.com>
Subject: Perl... the split function
Message-Id: <MPG.13d68eaae5b1fa798968b@eurnews0>

Hi there,

Wonder if someone can help me with this little problem...


Quote

If the PATTERN contains parentheses, additional array elements are 
created from each matching substring in the delimiter. 
    split(/([,-])/, "1-10,20", 3);
produces the list value 
    (1, '-', 10, ',', 20)

Unquote


The above is quoted from the perlfunc documentation.

My problem is... how do you set the delimiters to be a 'space' and a 
'comma' ?

I have tried
	split(/([, ])/, "1 10,20", 3);
But for some reason that doesn't work.

What am I doing wrong ?

Cheers,

Antony (mcnultya@nortelnetworks.com)


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

Date: Wed, 12 Jul 2000 12:31:53 +0200
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: Raise Exception when failure occurs ??
Message-Id: <396C4919.F9674C65@mssys.com>

Ed Bras wrote:
> For example, when I have a database transaction and something goes wrong, I
> want to make a explicit rollback in some kind of an exception handler!

If you're using Sybase/sybperl, you should read the documentation for
the functions  dberrhandle() and dbmsghandle, allowing you to install
you own subroutines being called if accessing a database fails for any
reason. Having installed your own subroutines you no longer get an
"exception" causing your program to terminate.
I don't know if this "mechanism" is available for other databases,
reading their documentation should answer this question.

But generally, as posted before, exception handling is done by using
eval().

Cheers
	Wolfgang


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

Date: 12 Jul 2000 09:53:36 -0400
From: Lewis Perin <perin@panix.com>
Subject: Re: Raise Exception when failure occurs ??
Message-Id: <pc74s5v78v3.fsf@panix3.panix.com>

"Ed Bras" <e.bras@hccnet.nl> writes:
> 
> Iain Chalmers <bigiain@mightymedia.com.au> wrote in message
> news:bigiain-1207001835470001@bigman.mighty.com.au...
> > In article <8kh9gs$8uk$1@enterprise.cistron.net>, "Ed Bras"
> > <e.bras@hccnet.nl> wrote:
> >
> > >What I really "miss" (or at least don't know how to do it) in Perl, is
> that
> > >when an runtime exception occurs the script just dies, without giving you
> > >the oppurtonity to handle the exception, just like delphi, java or visual
> > >basic.
> > >
> > >What can I do to overcome this problem in perl ?
> >
> > perldoc -f eval
>
> Thanks for the answer.
> 
> Buuuut, I know eval, but is that THE proper way to do it ??
> I mean does it work ok, to put eval around about hundred statement for
> example ???

It works for me in production code using DBI.  All the database access
- and there's a lot - goes on inside an eval and there's a rollback
guarded by "if ($@)".

> Isn't there a more elegant way to do it ??

In Ruby exceptions are a part of the language (he said, ducking.)

/Lew
-- 
Lew Perin / perin@mail.med.cornell.edu / perin@acm.org
www.panix.com/~perin/


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

Date: Wed, 12 Jul 2000 09:38:38 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Raise Exception when failure occurs ??
Message-Id: <slrn8mot6u.65s.tadmc@magna.metronet.com>

On Wed, 12 Jul 2000 10:17:10 +0200, Ed Bras <e.bras@hccnet.nl> wrote:

> Subject: Raise Exception when failure occurs ??
                 ^^^^^^^^^

   perldoc -q Exception


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


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