[18309] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 477 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 13 06:05:48 2001

Date: Tue, 13 Mar 2001 03:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984481510-v10-i477@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 13 Mar 2001     Volume: 10 Number: 477

Today's topics:
        commandfile with perl <kamran@norsar.no>
    Re: commandfile with perl <josef.moellers@fujitsu-siemens.com>
    Re: commandfile with perl (Abigail)
    Re: complex pattern matching with backslashes <bart.lateur@skynet.be>
    Re: CPAN Question (Philip Lees)
    Re: functions, operators and () <alun.moon@unn.ac.uk>
    Re: How do I get the name of a variable as a string? (Anno Siegel)
    Re: How to reverse a loop ? <wyzelli@yahoo.com>
        Mime::Lite Question <apmk@MailAndNews.com>
    Re: RE Doubt <cmon_209@hotmail.com>
    Re: reg exp question <joe+usenet@sunstarsys.com>
        running linux shell commands from perl scripts.... <fail00@hotmail.com>
    Re: running linux shell commands from perl scripts.... (Bernard El-Hagin)
        subroutine recursion? <jdavis@dynworks.com>
    Re: subroutine recursion? <peb@bms.umist.ac.uk>
    Re: subroutine recursion? <meisl@amvt.tu-graz.ac.at>
    Re: subroutine recursion? <peb@bms.umist.ac.uk>
    Re: subroutine recursion? (Gwyn Judd)
    Re: subroutine recursion? <meisl@amvt.tu-graz.ac.at>
    Re: subroutine recursion? <peb@bms.umist.ac.uk>
    Re: subroutine recursion? <bart.lateur@skynet.be>
    Re: usage of $SIG{__WARN__} and $SIG{__DIE__} <johnlin@chttl.com.tw>
    Re: usage of $SIG{__WARN__} and $SIG{__DIE__} <bart.lateur@skynet.be>
        Using the 'use' directive, and page reloading in a perl <nbr@newsbrowser.com>
        Using the 'use' directive, and page reloading in a perl <nbr@newsbrowser.com>
        Using the 'use' directive, and page reloading in a perl <nbr@newsbrowser.com>
        Using the 'use' directive, and page reloading in a perl <nbr@newsbrowser.com>
    Re: Why glob doesn't take a list? <bart.lateur@skynet.be>
    Re: XS: Accessing 'enum' constants <matt@sergeant.org>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 13 Mar 2001 09:09:39 +0100
From: kamran <kamran@norsar.no>
Subject: commandfile with perl
Message-Id: <3AADD5C3.6F96@norsar.no>

Hi

Is it possible to feed perl with a commandfile as one
does with 'sed' or 'awk'. I saw that '-e' option
can be used to execute one command(instruction)
but what about a series of instructions right after one
another ?

Thanks in advance

Kamran


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

Date: Tue, 13 Mar 2001 09:26:50 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: commandfile with perl
Message-Id: <3AADD9CA.376718DA@fujitsu-siemens.com>

kamran wrote:
> =

> Hi
> =

> Is it possible to feed perl with a commandfile as one
> does with 'sed' or 'awk'. I saw that '-e' option
> can be used to execute one command(instruction)
> but what about a series of instructions right after one
> another ?

Put them one after another, quotes around the whole kaboodle:

perl -e "print qw(Hello); print \" \"; print qw(world); print \"\\n\";"
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: 13 Mar 2001 10:51:58 GMT
From: abigail@foad.org (Abigail)
Subject: Re: commandfile with perl
Message-Id: <slrn9aruue.435.abigail@tsathoggua.rlyeh.net>

Josef Moellers (josef.moellers@fujitsu-siemens.com) wrote on MMDCCLI
September MCMXCIII in <URL:news:3AADD9CA.376718DA@fujitsu-siemens.com>:
;; kamran wrote:
;; > 
;; > Hi
;; > 
;; > Is it possible to feed perl with a commandfile as one
;; > does with 'sed' or 'awk'. I saw that '-e' option
;; > can be used to execute one command(instruction)
;; > but what about a series of instructions right after one
;; > another ?
;; 
;; Put them one after another, quotes around the whole kaboodle:
;; 
;; perl -e "print qw(Hello); print \" \"; print qw(world); print \"\\n\";"


Single quotes would make your life a lot easier.

As for multiple commands, multiple -e's work too:

    perl -e 'print "Hello";' -e 'print " ";' -e 'print "world";' -e 'print "\n"'


But that's not what the poster asked. He wants to execute a file.
And that's trivial:

    perl file_with_perl_statements



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: Tue, 13 Mar 2001 08:06:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: complex pattern matching with backslashes
Message-Id: <30lratcq258pfpttcuhu6hbh0phvq50hh9@4ax.com>

Martin Vorlaender wrote:

>Randal L. Schwartz (merlyn@stonehenge.com) wrote:
>> However, MacPerl and VMS perl and OS/2 Perl are certainly not going to
>> be accepting slashes. :)
>
>I don't know about MacPerl, but my OS/2 Perl (5.004_01 [1]) and all of
>the VMSPerls I've used support slashes (under VMS, because more recent
>versions of the C RTL allows slashed file specs like '/dev/dir/file').

MacPerl doesn't. And the reason is simple: the directory separator is
":", and the slash itself is a legal file name character. So you can
have a file called "in/out"; in fact names like that are very common.
(Because the Mac supports a file typing mechanism that is not part of
the file name, but stored separately, file name extensions are
uncommon.)

Matthias added a patch so that do "foo/bar.pl" indeed interprets the
slash as a directory separator, as well as for "require" (and maybe even
for "use"), but those are exceptions. Slashes are very uncommon in
library file names... for these, the same rules apply here as for other
platforms.

-- 
	Bart.


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

Date: Tue, 13 Mar 2001 09:41:50 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: CPAN Question
Message-Id: <3aadeafc.71264793@news.grnet.gr>

On Mon, 12 Mar 2001 15:02:19 +0100, Klaus-Dieter
=?iso-8859-1?Q?S=F6der?= <meisterplan@t-online.de> wrote:

>Is there a module which converts Paradox to Excel, or better text?

You could use Win32::ODBC with a Paradox ODBC driver to query the
table(s) you're interested in and output the data to a text file.

But why not just use the Paradox Export function?

Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: 13 Mar 2001 08:26:00 +0000
From: Alun Moon <alun.moon@unn.ac.uk>
Subject: Re: functions, operators and ()
Message-Id: <ubsr6yt0n.fsf@unn.ac.uk>

tadmc@augustmail.com (Tad McClellan) writes:
> We discussed this here a few days ago. 
> 
>    Subject: print using () functions and lists
> 
> Here is the (ridiculously long and word-wrapped) URL to the archived thread:
> 
>    http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=
>       55e736a223a8d96b&seekd=919181340
> 
> 
> Oh sheesh! It was you that started that thread!
> 
> Why are you starting the same one over again?

Sorry folks, for some reason the news feed here didn't pick up 
my earlier posting and the followups... I thought I had posted
to a black hole.

Alun


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

Date: 13 Mar 2001 08:32:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How do I get the name of a variable as a string?
Message-Id: <98klut$jjc$1@mamenchi.zrz.TU-Berlin.DE>

According to Bart Lateur  <bart.lateur@skynet.be>:
> Anno Siegel wrote:
> 
> >The original poster actually asked for a sub get_varname (or so) that
> >worked like this: "$name = get_varname( $var)".  This, of course, is
> >entirely impossible.  If "$var = 3", all the sub ever sees is 3.  It
> >doesn't even make sense to ask for the variable name for that.
> 
> It's not impossible. Perl passes its sub parameters by reference. 
> 
> 	sub getref {
> 	    \(shift);
> 	}
> 	$x = 3;
> 	($\, $,) = ("\n", "\t");
> 	print \$x, getref($x);
> -->
> 	SCALAR(0x8a62150)	SCALAR(0x8a62150)
> 
> That does look like two times the same ref to me.

You're absolutely right.  Sorry for stating a falsehood in apodictic
terms.

Anno


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

Date: Tue, 13 Mar 2001 20:24:59 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How to reverse a loop ?
Message-Id: <P%mr6.9$O43.1876@vic.nntp.telstra.net>

"Gwyn Judd" <tjla@guvfybir.qlaqaf.bet> wrote in message
news:slrn9ap62f.hv8.tjla@thislove.dyndns.org...
> I was shocked! How could Wyzelli <wyzelli@yahoo.com>
> say such a terrible thing:
> ><euterpe21@yahoo.com> wrote in message
> >news:ctvoatcdd23qr6cs4qunl8rue2p98j35sa@4ax.com...
> >> for (my $i=1; $i<scalar(@bids); $i++) {
> >
> >for (my $i=@bids; $i>0; $i--) {
>
> Not quite.
>
> for (my $i = $#bids; $i >= 0; $i--) {

Well spotted, I should have used the index of the last element rather than
the number of items, however, it does point out another 'bug'? in the OP
code...

He is incrementing from @bids[1], not @bids[0].

To reverse that exactly, the test condition still needs to be $i > 0 rather
than $i >= 0, (with the initialisation being $i = $#bids) though I think I
prefer the method which doesn't use $i at all.

Musta had one too many last night :)

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: Tue, 13 Mar 2001 04:44:45 -0500
From: Siva <apmk@MailAndNews.com>
Subject: Mime::Lite Question
Message-Id: <3AB0B823@MailAndNews.com>

Hello,
I realise this might be offtopic in this newsgroup but I want
to know how you'd check whether the stmt executed successfully or not.

 MIME::Lite->send('smtp', "itplmail.xxxx.com",Timeout=>60);
     $msg->send

I wanted to check whether the mail was sent successfully or was the 
mailserver
down and it timedout. Based on the RC i wanted to branch out accordingly.
I tried with 'if' ,'unless',somehow i'm doing it wrong. Can someone show me
how?
MIME::lite.....
should return true,false or undef i suppose,so how do i test it accordingly?
should i do the same for msg->send line too??
regards,
Sivaram

------------------------------------------------------------
 Get your FREE web-based e-mail and newsgroup access at:
                http://MailAndNews.com

 Create a new mailbox, or access your existing IMAP4 or
 POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------



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

Date: Tue, 13 Mar 2001 08:57:24 GMT
From: Chandramohan Neelakantan<cmon_209@hotmail.com>
Subject: Re: RE Doubt
Message-Id: <Uhlr6.2813$54.3004@www.newsranger.com>

In article <m3y9ua9kkq.fsf@mumonkan.sunstarsys.com>, Joe Schaefer says...
>
>Chandramohan Neelakantan <Chandramohan_member@newsranger.com> writes:
>
>> What is the diffrence between using '+' inside  square brackets and 
>> using it outside the same?
>
>+ is just another character within square brackets.
> 
>> Method1
>> =======
>> $str = "Is this trivial!!!??";
>> $str =~ /(\w+)[!\?\. ]+$/;print $1;
>> 
>> 
>> Method2
>> =======
>> 
>> $str = "Is this trivial!!!??";
>> $str =~ /(\w+)[!+\?+\.+ +]$/;print $1;
>                  ^^ ^^ ^
>                unnecessary
>> 
>> 

I am sorry ...I intented to write "Method2 doesnt work!" .


Thanks for the help.



Chandramohan Neelakantan
=====================================================
If it works , it is Obsolete!
                           -Marshall Mcluhan


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

Date: 13 Mar 2001 03:24:22 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: reg exp question
Message-Id: <m3r9029ivd.fsf@mumonkan.sunstarsys.com>

zawy@yahoo.com (zawy) writes:

> I thought I knew REs.
> 
> $a=12
> $b=12
> 
> The following return TRUE
> $a=~/^$b/
> $a=~/^$b$/
> $a=~/$b$/
> 
> The following returns FALSE
> $a=~/$b/
> 
> Why FALSE?


Dunno- where's the code that convinced you of this?  There
is a regexp bug related to empty patterns, but that doesn't 
appear to be relevant to your problem unless somehow 
$b = ''.

#!/usr/bin/perl -wl
$b = '';
$_ = 223344;
$,=":";
print "MATCHES:" . ( ()=/$b/g );

/(.)\1/;
print "CURIOUS", /$b/g ;

()=/(.)\1/g;
print "CURIOUSER", /$b/ ;
__END__

Output:

  MATCHES:7
  CURIOUS:2
  CURIOUSER:2:3:4


Joe Schaefer
-- 
%ENV=(); $A="\rr jpeurls ht\ba \rcankotehe"x666;END{ system
"$^X -wT $0 $^S";print"r\n"}sub foo{$_=pop||exit;/$_/;print
eval 'BEGIN{$^H='. ($^H+=666) .'}$_[-(()=$A=~//g)+$[]';}@_=
reverse$A=~/./g;&foo while$ARGV[0]=~//g;#evil mess for *nix


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

Date: Tue, 13 Mar 2001 22:02:58 +1300
From: "fail006" <fail00@hotmail.com>
Subject: running linux shell commands from perl scripts....
Message-Id: <98kntc$3ln$2@lust.ihug.co.nz>

Hi,
I have just started using perl and i would like to know how can i run any of
the linux shell commands using perl scripts, or how do i execute linux shell
commands within perl scripts?
Is there a website or books that can help me with this...?

Thanks





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

Date: Tue, 13 Mar 2001 09:10:52 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: running linux shell commands from perl scripts....
Message-Id: <slrn9arot1.j9b.bernard.el-hagin@gdndev32.lido-tech>

On Tue, 13 Mar 2001 22:02:58 +1300, fail006 <fail00@hotmail.com> wrote:
>Hi,
>I have just started using perl and i would like to know how can i run any of
>the linux shell commands using perl scripts, or how do i execute linux shell
>commands within perl scripts?

Read about the system command:

perldoc -f system

and about backticks:

perldoc perlop

>Is there a website or books that can help me with this...?

Yes.

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Tue, 13 Mar 2001 01:53:08 -0800
From: Jeff Davis <jdavis@dynworks.com>
Subject: subroutine recursion?
Message-Id: <3AADEE04.60003@dynworks.com>

This seems a simple problem, but how do you make a recursive subroutine? 
I have my code below that didn't work. I was trying to make a simple 
"dircalc" program that would calculate the size of the contents of a 
directory. I realized that I didn't know how to recurse, so I tried 
making the simple case below (factorial calculator function):

#!/usr/bin/perl

sub factorial($);
print &factorial(6); print "\n";


sub factorial($) {
         $x = shift;
         print "x: $x\n";
         if($x == 1) {
                 print "r: 1\n"; # debugging, returned expected
                 return 1;
         }
         else {
                 print "r: $x\n"; # debugging, returned expected
                 return ( $x * &factorial($x-1) ); # returned UNexpected
         }
}

# end

Thanks for any help,
	Jeff Davis



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

Date: Tue, 13 Mar 2001 10:05:43 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: subroutine recursion?
Message-Id: <3AADF0F7.D3D87B35@bms.umist.ac.uk>

Jeff Davis wrote:
> 
> This seems a simple problem, but how do you make a recursive subroutine?

here's a simple factorial example that takes a single number from the
command line.


print "trying $ARGV[0] ",factorial($ARGV[0]), "\n";
 
sub factorial{
        return 1 if $_[0] == 1;
        return $_[0] * factorial($_[0] - 1);
}     

Paul


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

Date: 13 Mar 2001 10:58:29 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Re: subroutine recursion?
Message-Id: <m3vgpeyoqi.fsf@famvtpc59.tu-graz.ac.at>

Jeff Davis <jdavis@dynworks.com> writes:
> #!/usr/bin/perl
> 
> sub factorial($);
> print &factorial(6); print "\n";
> 
> 
> sub factorial($) {
>          $x = shift;
>          print "x: $x\n";
>          if($x == 1) {
>                  print "r: 1\n"; # debugging, returned expected
>                  return 1;
>          }
>          else {
>                  print "r: $x\n"; # debugging, returned expected
>                  return ( $x * &factorial($x-1) ); # returned UNexpected
>          }
> }

I am not a perl guru, but for my eyes the dollar sign in the sub
declaration seems to be wrong. The following should work:

#! /usr/bin/perl -w
use strict;

sub factorial {
    my $x = shift; # Get first argument into $x
    return 1 if $x == 1; # &factorial(1) == 1
    return $x * &factorial(--$x); # Otherwise do recursion
}

print &factorial(6)."\n";

Regards,
Christian

-- 
Christian Meisl <meisl@amvt.tu-graz.ac.at>        www.amft.tu-graz.ac.at
   Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
---- Measure with a micrometer.  Mark with chalk.  Cut with an axe. ----
PGP fingerprint:      DF48 2503 0411 F0EF 149C  851B 1EF0 72B9 78B6 034A


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

Date: Tue, 13 Mar 2001 10:10:50 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: subroutine recursion?
Message-Id: <3AADF22A.E1647F25@bms.umist.ac.uk>

use strict;

> sub factorial($);
> print &factorial(6); print "\n";
> 
> sub factorial($) {

          my $x = shift;
          ^^

here's the reason your version didn't work.  Each time the sub is called
the old value of $x was overwriten as it is a global variable.  Give the
variable local scope and each instance is stored.  So, when the
recursive sub 'un-zipps' itself the old values of $x are remembered for
the 'return $x * factorial($x - 1)' calculation.  Otherwise at the end
of the call $x will just be '1'.

HTH

Paul


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

Date: Tue, 13 Mar 2001 10:14:01 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: subroutine recursion?
Message-Id: <slrn9arsn7.q3u.tjla@thislove.dyndns.org>

I was shocked! How could Christian Meisl <meisl@amvt.tu-graz.ac.at>
say such a terrible thing:
>Jeff Davis <jdavis@dynworks.com> writes:
>> #!/usr/bin/perl
>> 
>> sub factorial($);
>> print &factorial(6); print "\n";
>> 
>> 
>> sub factorial($) {

>> }
>
>I am not a perl guru, but for my eyes the dollar sign in the sub
>declaration seems to be wrong. The following should work:

Did you try your version with the dollar sign? It works exactly the
same.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
For some reason, this fortune reminds everyone of Marvin Zelkowitz.


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

Date: 13 Mar 2001 11:20:24 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Re: subroutine recursion?
Message-Id: <m3snkiynpz.fsf@famvtpc59.tu-graz.ac.at>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
> Did you try your version with the dollar sign? It works exactly the
> same.

OK, you're right. I just looked it up in the 'perlsub' manpage. Never
used prototyping for one of my own routines, so I could not have
known... ;-)

Regards,
Christian

-- 
Christian Meisl <meisl@amvt.tu-graz.ac.at>        www.amft.tu-graz.ac.at
   Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
------- If you can't beat your computer at chess, try kickboxing -------
PGP fingerprint:      DF48 2503 0411 F0EF 149C  851B 1EF0 72B9 78B6 034A


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

Date: Tue, 13 Mar 2001 11:01:38 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: subroutine recursion?
Message-Id: <3AADFE12.AE387DFF@bms.umist.ac.uk>

Christian Meisl wrote:
> 
> tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
> > Did you try your version with the dollar sign? It works exactly the
> > same.
> 
> OK, you're right. I just looked it up in the 'perlsub' manpage. Never
> used prototyping for one of my own routines, so I could not have
> known... ;-)


why does my news reader take sooo loooong to pick up some messages?  The
only messages I have in this thread so far are my own and the one I've
replied to...  It's very frustrating.

Sorry for the rant

Paul


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

Date: Tue, 13 Mar 2001 11:04:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: subroutine recursion?
Message-Id: <olvrat432ifa1ga4ls19ov9acq874o6c9r@4ax.com>

Gwyn Judd wrote:

>>> sub factorial($);
>>> print &factorial(6); print "\n";
>>> 
>>> sub factorial($) {
>
>>> }
>>
>>I am not a perl guru, but for my eyes the dollar sign in the sub
>>declaration seems to be wrong. The following should work:
>
>Did you try your version with the dollar sign? It works exactly the
>same.

As an aside: prototyping a sub and then calling the sub with "&"  is a
useless combination. The "&" overrides the prototype.

-- 
	Bart.


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

Date: Tue, 13 Mar 2001 15:47:52 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: usage of $SIG{__WARN__} and $SIG{__DIE__}
Message-Id: <98kj8h$jiu@netnews.hinet.net>

"Peter Scott" wrote
> Nevertheless, you might use it either where you want its effects
> over more code than you care to wrap in an eval {}, or where you
> are not in a position to do so, i.e., writing a module.  CGI::Carp
> uses it for this purpose.

> >The same question on $SIG{__WARN__}, in what situation
> >would $SIG{__WARN__} be considered useful?
>
> I just had occasion to use it where I am using a CPAN module that calls
> warn() in many situations where I would like to suppress it.
> Rather than clone the module, I just set up a __WARN__ handler
> that looks at the message and drops it on the floor if it matches
> a certain pattern.

Whatever you do by using $SIG{__DIE__} or $SIG{__WARN__} is perishable.

use CGI::Carp;
$SIG{__DIE__} = sub { blah blah };

The author of CGI::Carp wouldn't know his $SIG{__DIE__}
is not called any more at all.

On the other hand, the user of $SIG{__DIE__} has to worry whether
he has destroyed other's code or not.

My normal usage of $SIG{__WARN__} may destroy your suppressing handler.
Hey, maybe your handler just destroyed other's code.

That's the reason why I ask this question.  Maybe we should just
use them "local"ly.  But
> >Since exceptions are catchable by eval {}, in what
> >situation will you use $SIG{__DIE__} ?

Hmm... There must be some misconcept on me...
How are $SIG{__WARN__} and $SIG{__DIE__} used in the real world?

Thank you.

John Lin





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

Date: Tue, 13 Mar 2001 10:33:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: usage of $SIG{__WARN__} and $SIG{__DIE__}
Message-Id: <ontrat0urrea48ddsdfcgfpq5nitdi89di@4ax.com>

John Lin wrote:

>use CGI::Carp;
>$SIG{__DIE__} = sub { blah blah };
>
>The author of CGI::Carp wouldn't know his $SIG{__DIE__}
>is not called any more at all.
>
>On the other hand, the user of $SIG{__DIE__} has to worry whether
>he has destroyed other's code or not.
>
>My normal usage of $SIG{__WARN__} may destroy your suppressing handler.
>Hey, maybe your handler just destroyed other's code.

My idea would be that there ought to be a stack of $SIG{__WARN__}
handlers (and maybe even for $SIG{__DIE__}). If your sub at the top of
the stack doesn't do anything with a particular message, it may decide
to pass it on to handlers underneath it on the stack. As a whole, the
mechanism would be too different from how inheritance works in OOP,
where a method can decide to call the method it replaced, i.e. the
method of the same name in its SUPER.

Heh. Maybe this could even be written using OOP and inheritance?

-- 
	Bart.


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

Date: Tue, 13 Mar 2001 11:00:55 -0000
From: "The NewsBrowser" <nbr@newsbrowser.com>
Subject: Using the 'use' directive, and page reloading in a perl script
Message-Id: <98kul4$2fci3$1@ID-18325.news.dfncis.de>

Hi all,

As a beginner to perl, I was playing around with a script
trying to get it to respond to values I had entered in a form.
The implementation of perl I was using is IndigoPerl on Win32.

In order to retrieve the values submitted to the script
via the post method, I put the following line near the top of
the script:

use CGI;

I am told that this enables me to import a package that
does parsing of the content submitted by the browser.

However, when I use the param function that is part of this
package to extract these entered values, it doesn't work;
nothing at all is displayed.

When I change the directive above to

use CGI qw(:all);

then all is sweetness and light. Does anyone know why this is?


Also, does anyone know if it is possible to get a perl script
to cause a new page to be loaded in a browser? For example, if
on submitting a form, a perl script is invoked, is it possible
to get the perl script to load one page if certain values are
entered in the form and another page if they aren't? (Kind of
like ASP's Response.Redirect(...) or javascript's
location.href = "...")

Thanks in advance,
--
Akin

email: akin at aksoto dot idps dot co dot uk








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

Date: Tue, 13 Mar 2001 10:58:56 -0000
From: "The NewsBrowser" <nbr@newsbrowser.com>
Subject: Using the 'use' directive, and page reloading in a perl script
Message-Id: <98kuio$2cerf$1@ID-18325.news.dfncis.de>

Hi all,

As a beginner to perl, I was playing around with a script
trying to get it to respond to values I had entered in a form.
The implementation of perl I was using is IndigoPerl on Win32.

In order to retrieve the values submitted to the script
via the post method, I put the following line near the top of
the script:

use CGI;

I am told that this enables me to import a package that
does parsing of the content submitted by the browser.

However, when I use the param function that is part of this
package to extract these entered values, it doesn't work;
nothing at all is displayed.

When I change the directive above to

use CGI qw(:all);

then all is sweetness and light. Does anyone know why this is?


Also, does anyone know if it is possible to get a perl script
to cause a new page to be loaded in a browser? For example, if
on submitting a form, a perl script is invoked, is it possible
to get the perl script to load one page if certain values are
entered in the form and another page if they aren't? (Kind of
like ASP's Response.Redirect(...) or javascript's
location.href = "...")

Thanks in advance,
--
Akin

email: akin at aksoto dot idps dot co dot uk




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

Date: Tue, 13 Mar 2001 10:58:56 -0000
From: "The NewsBrowser" <nbr@newsbrowser.com>
Subject: Using the 'use' directive, and page reloading in a perl script
Message-Id: <98kuhg$2b6d2$1@ID-18325.news.dfncis.de>

Hi all,

As a beginner to perl, I was playing around with a script
trying to get it to respond to values I had entered in a form.
The implementation of perl I was using is IndigoPerl on Win32.

In order to retrieve the values submitted to the script
via the post method, I put the following line near the top of
the script:

use CGI;

I am told that this enables me to import a package that
does parsing of the content submitted by the browser.

However, when I use the param function that is part of this
package to extract these entered values, it doesn't work;
nothing at all is displayed.

When I change the directive above to

use CGI qw(:all);

then all is sweetness and light. Does anyone know why this is?


Also, does anyone know if it is possible to get a perl script
to cause a new page to be loaded in a browser? For example, if
on submitting a form, a perl script is invoked, is it possible
to get the perl script to load one page if certain values are
entered in the form and another page if they aren't? (Kind of
like ASP's Response.Redirect(...) or javascript's
location.href = "...")

Thanks in advance,
--
Akin

email: akin at aksoto dot idps dot co dot uk




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

Date: Tue, 13 Mar 2001 11:01:19 -0000
From: "The NewsBrowser" <nbr@newsbrowser.com>
Subject: Using the 'use' directive, and page reloading in a perl script
Message-Id: <98kums$2g5l2$1@ID-18325.news.dfncis.de>

Hi all,

As a beginner to perl, I was playing around with a script
trying to get it to respond to values I had entered in a form.
The implementation of perl I was using is IndigoPerl on Win32.

In order to retrieve the values submitted to the script
via the post method, I put the following line near the top of
the script:

use CGI;

I am told that this enables me to import a package that
does parsing of the content submitted by the browser.

However, when I use the param function that is part of this
package to extract these entered values, it doesn't work;
nothing at all is displayed.

When I change the directive above to

use CGI qw(:all);

then all is sweetness and light. Does anyone know why this is?


Also, does anyone know if it is possible to get a perl script
to cause a new page to be loaded in a browser? For example, if
on submitting a form, a perl script is invoked, is it possible
to get the perl script to load one page if certain values are
entered in the form and another page if they aren't? (Kind of
like ASP's Response.Redirect(...) or javascript's
location.href = "...")

Thanks in advance,
--
Akin

email: akin at aksoto dot idps dot co dot uk










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

Date: Tue, 13 Mar 2001 10:27:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why glob doesn't take a list?
Message-Id: <9esrat0ls8cpt4uerekvcei07jpf63irhc@4ax.com>

Martien Verbruggen wrote:

>One thing I can think of is that it maybe would be a bit ambiguous
>what 
>
>undef @array;
>
>would mean if undef took a list. is it 'undefine all the elements of
>@array', or is it 'undefine @array itself'.

>Apart from taking into account how prototyping works in Perl right
>now, I'd be a bit hard pressed to come up with parsing rules that
>would always do the Right Thing(TM). And if you take prototyping into
>account, then I wouldn't even know whether it would be possible
>without making undef the great exception to the rule (unless it
>already is :)).

The parsing rule can be pretty straightforward: make it the same as with
"local".

Perl never has been a very orthogonal language, so there's no reason to
start now.

"local" can take any type of argument, but it won't flatten any lists.
It either takes scalars or aggregates, but it can also accept hash
elements, for instance.

	local $foo{bar};

%foo needn't even be a global (i.e. it may be a lexical).

-- 
	Bart.


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

Date: Tue, 13 Mar 2001 10:45:02 +0000
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: XS: Accessing 'enum' constants
Message-Id: <3AADFA2E.6F06D180@sergeant.org>

Matthias Papesch wrote:
> 
> Hi,
> 
> I'm trying to create a PERL interface for a c-library and encountering a
> few problems.
> 
> Is there a way to access values of 'enums' from the .h file? I've been
> searching on the web but couldn't really find anything helpful.

The way I've done this in the past is to make functions that return the
value of the enums. There's probably a nicer way, but constants in Perl are
just functions anyway.

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\


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

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 V10 Issue 477
**************************************


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