[19395] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1590 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 22 18:10:36 2001

Date: Wed, 22 Aug 2001 15:10:14 -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: <998518214-v10-i1590@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 22 Aug 2001     Volume: 10 Number: 1590

Today's topics:
    Re: i need to count words in perl (Abigail)
    Re: i need to count words in perl <ren@tivoli.com>
        Loading up a program asociated with a file <Pcmann1@btinternet.com>
    Re: Looking for a module (Abigail)
    Re: Need help trapping 'not a number' errors (Malcolm Dew-Jones)
    Re: Need help trapping 'not a number' errors <godzilla@stomp.stomp.tokyo>
    Re: Need help trapping 'not a number' errors <godzilla@stomp.stomp.tokyo>
    Re: Need help trapping 'not a number' errors <cjmackie@princeton.edu>
    Re: Need help trapping 'not a number' errors <godzilla@stomp.stomp.tokyo>
    Re: Need help trapping 'not a number' errors (Malcolm Dew-Jones)
    Re: Need help trapping 'not a number' errors <godzilla@stomp.stomp.tokyo>
        Net::SNMP and unsigned/big integers <andreas@hinet.nu>
        Openning a file <gmandesigns@hotmail.com>
    Re: Openning a file <Tassilo.Parseval@post.rwth-aachen.de>
        Partial matching of a regular expression (JP Belanger)
    Re: Partial matching of a regular expression (Malcolm Dew-Jones)
    Re: Passing code pieces to program (Abigail)
    Re: Perl PGP routines <ben@rhumba.pair.com>
    Re: Perl rookie question!  Setting up perl to work with <somewhere@in.paradise.net>
    Re: perl4 bashing (was Re: syntax & compilation errors) (Anno Siegel)
    Re: perl4 bashing (was Re: syntax & compilation errors) (Abigail)
    Re: race condition? <tsee@gmx.net>
        redirect stderr for sub-routine <just@usenet.please>
    Re: redirect stderr for sub-routine <Tassilo.Parseval@post.rwth-aachen.de>
        Why wont this work!?!?!? (Isaac)
    Re: Why wont this work!?!?!? (John J. Trammell)
    Re: Why wont this work!?!?!? <godzilla@stomp.stomp.tokyo>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 22 Aug 2001 19:29:14 GMT
From: abigail@foad.org (Abigail)
Subject: Re: i need to count words in perl
Message-Id: <slrn9o820l.6m2.abigail@alexandra.xs4all.nl>

Larry S (dime0000@yahoo.com) wrote on MMCMXIII September MCMXCIII in
<URL:news:8fd7acb0.0108220737.57aac387@posting.google.com>:
 .. ok, i have a variable, $text, which contains a certain amount of words.
 .. 
 .. i want to display the first 30 words of $text, nothing more.
 .. 
 .. any simple solutions?


Perhaps. It all depends on your definition of a word. How many words
are there in (and what are those words?):

    I don't like this.

Is punctuation part of a word? That is, is the last word of the above
sentence "this.", or "this"? What about "don't"? One word, or two?
If it's one word, any solution that matches on \w+, will be wrong.
It it's two words, any solution that splits on \s+ will be wrong.
Besides, if it's two words, and there are 29 words proceeding "don't",
what should be printed?


Parsing text into words is a non-trivial task.



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
#    Ten foxes eating near
#    a garden. A pair of nesting
#    woodpeckers. The Prince.


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

Date: 22 Aug 2001 13:46:57 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: i need to count words in perl
Message-Id: <m34rr09bku.fsf@dhcp9-161.support.tivoli.com>

On Wed, 22 Aug 2001, Rainer.Klier@erl.sbs.de wrote:

> Larry S wrote:
>> 
>> ok, i have a variable, $text, which contains a certain amount of
>> words.  i want to display the first 30 words of $text, nothing
>> more.  any simple solutions?
> 
> print join " ",((split " ",$text)[0..29]);

For variety:

  print $text =~ /^((?:\S+\s+){0,30})/g;

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 22 Aug 2001 20:47:20 +0100
From: "Peter Mann" <Pcmann1@btinternet.com>
Subject: Loading up a program asociated with a file
Message-Id: <9m1268$b5n$1@uranium.btinternet.com>

Dear All,
    I am trying to load an HTML file using whatever default browser in
installed on the computer. In Visual Basic, I can use a command to load a
file, and the program associated with the file extension will be loaded.
    I am trying to achieve the same in Perl!
    To my understanding, there is a 'system' command which could be used to
start up a browser with a HTML page. However, I would need the path to the
browser - I suppose this could be stored in a file for use by the program.
    However, I was hoping to load a browser which may reside any different
location!, and different computers may have different default browsers. Is
there a command therefore which will load a file into a program and select
the program with respect to the type of file it is?

Thanks in advance!
Any suggestions would be greatly appreciated

   Regards
      - Pete






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

Date: 22 Aug 2001 19:32:30 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Looking for a module
Message-Id: <slrn9o826q.6m2.abigail@alexandra.xs4all.nl>

Nickolas Emmanuel A Downey (gt5837c@prism.gatech.edu) wrote on MMCMXIII
September MCMXCIII in <URL:news:9m0nu4$o3l$4@news-int.gatech.edu>:
`' I was curious to know if there is a module that allows perl to
`' control system v init scripts. I can of course issue system commands
`' ( system( "/etc/init.d/ppoe-client restart" ) ) but I'm looking for 
`' a cleaner implementation.


What is unclean in using system()?

The purpose of system() is to run external commands. You could of course
fork() and exec() yourself, but system() is doing that behind the screens
too. 



Abigail
-- 
perl -wle'print"Êõóô áîïôèåò Ðåòì Èáãëåò"^"\x80"x24'
#    A pair of mosquitoes
#    flying over the
#    river. A carp swims.


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

Date: 22 Aug 2001 11:08:17 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Need help trapping 'not a number' errors
Message-Id: <3b83f511@news.victoria.tc.ca>

C.J. Mackie (cjmackie@princeton.edu) wrote:
: I'm getting the following error in the middle of a long processing run:

: Can't take sqrt of 1.#QNAN

: I'm guessing 'NAN' is NotANumber.  I can lose this data-point without any
: problem, if I can just trap the error, but so far no luck.  I've tried the
: PerlFAQ suggestions for validating numbers (e.g., /\D/), but no luck.  I
: also tried searching for 'NAN'  but that's clearly not the real content of
: the scalar either.

: The run performs about 208G calculations, so efficiency matters.

: Any suggestions gratefully accepted and tried ASAP.  Thanks,  --Chris


This small script accepts one number on the command line, and catches any
sqrt error.  For example type 'perl try -1' causes an error which it
catches.  (The eval does NOT catch the error if we hard coded the -1 into
the sqrt - for that I think we would need to define a die handler in a
BEGIN block, but that probably doesn't matter to you.)


	$n = shift() ;
	print "About to sqrt($n)\n";
	eval { $res = sqrt($n) };
	if ($@)
	{
	  print "We trapped the error.  It was $@ \n";
	}
	else
	{
	  print "sqrt = $res\n";
	}
	



--
Want to access the command line of your CGI account?  Need to debug your
installed CGI scripts?  Transfer and edit files right from your browser? 

What you need is "ispy.cgi" - visit http://nisoftware.com/ispy.cgi


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

Date: Wed, 22 Aug 2001 11:09:22 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Need help trapping 'not a number' errors
Message-Id: <3B83F552.36EAF5E@stomp.stomp.tokyo>

C.J. Mackie wrote:

(snipped)

> I'm getting the following error in the middle of a long processing run:
 
> Can't take sqrt of 1.#QNAN
 
> I'm guessing 'NAN' is NotANumber.  I can lose this data-point without any
> problem, if I can just trap the error, but so far no luck.


Guessing is a most illogical approach to programming.

Equally illogical, you have not provided any parameters.
Why do you expect others to guess as you do? Many here
certainly enjoying guessing. My preference is to deal
with facts rather than conjecture guessing. However,
I am one of very few here whom think logically.

What is this number and why have you not simply used a print
to eyeball this number?

So your program tells you your data is not a number. Strikes
me you do not need to be rocket scientist material to figure
your data contains a character or characters other than pure
digits, possibly including a customary decimal point.

Care to guess again? Think Scientific Notation.


Godzilla!


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

Date: Wed, 22 Aug 2001 11:50:23 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Need help trapping 'not a number' errors
Message-Id: <3B83FEEF.15DE1C10@stomp.stomp.tokyo>

Malcolm Dew-Jones wrote:
 
> C.J. Mackie wrote:

(snipped)

> : I'm getting the following error in the middle of a long processing run:
 
> : Can't take sqrt of 1.#QNAN
 
> : I'm guessing 'NAN' is NotANumber.
 
 
> This small script accepts one number on the command line, and catches any
> sqrt error.  For example type 'perl try -1' causes an error which it
> catches.  (The eval does NOT catch the error if we hard coded the -1 into
> the sqrt - for that I think we would need to define a die handler in a
> BEGIN block, but that probably doesn't matter to you.)
 
>         $n = shift() ;
>         print "About to sqrt($n)\n";
>         eval { $res = sqrt($n) };
>         if ($@)
>         {
>           print "We trapped the error.  It was $@ \n";
>         }
>         else
>         {
>           print "sqrt = $res\n";
>         }


Under circumstances of attempting to find the square root
of a negative number, perl core crashes and returns an
error message of this typical format:

Can't take sqrt of -4 at test1.pl line 9.


The originating author states, if true, his error message is:

  " Can't take sqrt of 1.#QNAN "

I am curious how you know the originating author is dealing
with finding a square root of a negative number. Perhaps
you are yet another practicing Internet Mind Reader?

I have yet to duplicate the originating author's error message
via Perl methodology. Curious, yes?


Godzilla!


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

Date: Wed, 22 Aug 2001 17:08:19 -0400
From: "C.J. Mackie" <cjmackie@princeton.edu>
Subject: Re: Need help trapping 'not a number' errors
Message-Id: <9m1703$p9c$1@cnn.Princeton.EDU>

Hi, Malcolm.  The problem isn't negatives, unfortunately (I tried sqrt'ing
negatives, and zero, and it's not the same error text).  In fact, it
shouldn't be possible for the number to be negative, since the expression is
sqrt( $val1 * $val2), where $val[12] are both sums of squares.  Nor is it
scientific notation, since the file to be processed is binary floats packed
and unpacked with "f".

There's no doubt you're right--eval is the way to go.  I was just stuck on
trying to figure out the bad value rather than trapping all errors (thought
it might be less expensive).  I've reconfigured the program with an eval
block, and it's past the first trouble spot with no worries--noticeably
slower, but still fast enough.

Many thanks!  --Chris

"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:3b83f511@news.victoria.tc.ca...
>
> This small script accepts one number on the command line, and catches any
> sqrt error.  For example type 'perl try -1' causes an error which it
> catches.  (The eval does NOT catch the error if we hard coded the -1 into
> the sqrt - for that I think we would need to define a die handler in a
> BEGIN block, but that probably doesn't matter to you.)
>
>





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

Date: Wed, 22 Aug 2001 14:44:29 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Need help trapping 'not a number' errors
Message-Id: <3B8427BD.C4307A11@stomp.stomp.tokyo>

C.J. Mackie wrote:
 
> Hi, Malcolm.  The problem isn't negatives, unfortunately (I tried sqrt'ing
> negatives, and zero, and it's not the same error text).  In fact, it
> shouldn't be possible for the number to be negative, since the expression is
> sqrt( $val1 * $val2), where $val[12] are both sums of squares.  Nor is it
> scientific notation, since the file to be processed is binary floats packed
> and unpacked with "f".
 
> There's no doubt you're right--eval is the way to go.  I was just stuck on
> trying to figure out the bad value rather than trapping all errors (thought
> it might be less expensive).  I've reconfigured the program with an eval
> block, and it's past the first trouble spot with no worries--noticeably
> slower, but still fast enough.



My presumption is you are too fearful to address me directly.
 

I will say again what I have said to you before,

  "I hold an opinion both you and your troll articles
   amount to nothing more than canned Mule Manure."


The number one cause of this error message you cite,
"...1.#QNAN" is trying to format a number in a manner
which does not comply with a C compiler's rules for
formatting numbers.

Your claim of perl core creating this error message
are obviously quite false.


Incidently, a troll like you wouldn't be aware there
is a rather ingenious rogue method to work with negative
number square roots when inadvertently called. Advanced
methods like this are reserved for creative rogue Perl
programmers, such as myself.



Square root of a negative number error, my big butt.

* laughs *

Godzilla!


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

Date: 22 Aug 2001 14:46:04 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Need help trapping 'not a number' errors
Message-Id: <3b84281c@news.victoria.tc.ca>

Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
: Malcolm Dew-Jones wrote:
:  
: > C.J. Mackie wrote:

: (snipped)

: > : I'm getting the following error in the middle of a long processing run:
:  
: > : Can't take sqrt of 1.#QNAN
:  
: > : I'm guessing 'NAN' is NotANumber.
:  
:  
: > This small script accepts one number on the command line, and catches any
: > sqrt error.  For example type 'perl try -1' causes an error which it
: > catches.  (The eval does NOT catch the error if we hard coded the -1 into
: > the sqrt - for that I think we would need to define a die handler in a
: > BEGIN block, but that probably doesn't matter to you.)
:  
: >         $n = shift() ;
: >         print "About to sqrt($n)\n";
: >         eval { $res = sqrt($n) };
: >         if ($@)
: >         {
: >           print "We trapped the error.  It was $@ \n";
: >         }
: >         else
: >         {
: >           print "sqrt = $res\n";
: >         }


: Under circumstances of attempting to find the square root
: of a negative number, perl core crashes and returns an
: error message of this typical format:

: Can't take sqrt of -4 at test1.pl line 9.

My perls do not crash while taking the sqrt of a negative number.  Perhaps
you accidently broke your perl.


: The originating author states, if true, his error message is:

:   " Can't take sqrt of 1.#QNAN "

: I am curious how you know the originating author is dealing
: with finding a square root of a negative number. Perhaps
: you are yet another practicing Internet Mind Reader?

Where did I claim his error was caused by sqrt'ing negative numbers? 

I don't have to read his mind to understand the words (and I quote)

	"if I can just trap the error,"

I gave him a prototypical example of trapping an error.  I tested one type
of easily produced error to ensure my syntax and overall error-trapping
logic was correct.  I assume it works for all errors, since this is the
documented behaviour of eval{}, (though I also assume it will not trap
errors that crash perl).

Now go away.


: I have yet to duplicate the originating author's error message
: via Perl methodology. Curious, yes?

I have yet to duplicate your error with sqrting negative numbers.
Curious, (not really).



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

Date: Wed, 22 Aug 2001 14:51:35 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Need help trapping 'not a number' errors
Message-Id: <3B842967.73F5AAED@stomp.stomp.tokyo>

Malcolm Dew-Jones wrote:
 
> Godzilla!  wrote:
> : Malcolm Dew-Jones wrote:
> : > C.J. Mackie wrote:
 
 (snipped)

> My perls do not crash while taking the sqrt of a negative number.  Perhaps
> you accidently broke your perl.

Canned Mule Manure!


Godzilla!


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

Date: Wed, 22 Aug 2001 21:09:23 GMT
From: "Andreas Lidberg" <andreas@hinet.nu>
Subject: Net::SNMP and unsigned/big integers
Message-Id: <7cVg7.26$Ff4.721@news.defero.net>

I have a little problem... when using Net::SNMP to fetch inoctets from
routers the response is a negative (2´s complement) when value is over 2^31.
Is there a way to get Perl to handle this as an unsigned integer? How?
The result from get_request is a hash reference and no matter how I do I
still just get the negative result.

Please help

(I have posted in .modules too but haven´t got any replies yet)

Andreas Lidberg
PERL Newbie =)




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

Date: Wed, 22 Aug 2001 21:55:59 GMT
From: "SpeedCancer" <gmandesigns@hotmail.com>
Subject: Openning a file
Message-Id: <PTVg7.56193$gj1.5154925@bgtnsc05-news.ops.worldnet.att.net>

Is it possible to open and close a file in a sub routine?
Im using this code but it does'nt seem to work

&openfile (ARGUMENTLIST)

sub openfile
    use strict;
    my $filename = ("file.txt");
    open FILEHANDLE, "<$filename" or die "Could not open file: $!\n";
    my @text = <FH>;




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

Date: Thu, 23 Aug 2001 00:03:51 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Openning a file
Message-Id: <3B842C47.2000408@post.rwth-aachen.de>

SpeedCancer wrote:

> Is it possible to open and close a file in a sub routine?
> Im using this code but it does'nt seem to work
> 
> &openfile (ARGUMENTLIST)
> 
> sub openfile
>     use strict;

Using strict is a good idea, but why only inside a subroutine? However, 
you forgot to wrap your sub into curly brackets.

>     my $filename = ("file.txt");

This is dangerous. On the left, you have scalar context and on the right 
a one-element list.
Interestingly enough, Perl does in fact store the string in the 
variable. I would have expected that it assigned 1 to $filename. Perhaps 
one of DWIMings.
However: my $filename = 'file.txt';
Single quotes will do since you do not interpolate anything inside the 
string.

>     open FILEHANDLE, "<$filename" or die "Could not open file: $!\n";
>     my @text = <FH>;

       close FILEHANDLE; # when it is no longer needed.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 22 Aug 2001 14:05:46 -0700
From: jpbelang@hotmail.com (JP Belanger)
Subject: Partial matching of a regular expression
Message-Id: <b399d6ce.0108221305.34490233@posting.google.com>

Is there a way in perl to "partially match" on input ?

For example, with expression /hello/ and input "hel", I'd like to know
that the regular expression is currently matching, but not done yet.


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

Date: 22 Aug 2001 14:49:53 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Partial matching of a regular expression
Message-Id: <3b842901@news.victoria.tc.ca>

JP Belanger (jpbelang@hotmail.com) wrote:
: Is there a way in perl to "partially match" on input ?

: For example, with expression /hello/ and input "hel", I'd like to know
: that the regular expression is currently matching, but not done yet.

This may not be what you need, but sometimes you want to turn the test
around.

	$input = <>;

	print "partial match" if 'hello' =~ m/^${input}$/;




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

Date: 22 Aug 2001 19:14:55 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Passing code pieces to program
Message-Id: <slrn9o815q.6m2.abigail@alexandra.xs4all.nl>

Chas Friedman (friedman@math.utexas.edu) wrote on MMCMXII September
MCMXCIII in <URL:news:3b82ed5c.13792869@news.itouch.net>:
,,  Is there a way to pass pieces of code to a script as arguments? For
,, example, I have a  script that uses File::Find, and contains the
,, expression:  if (-M $_<1)....  
,, I would like to be able to pass the "-M$_<1" to the script when it is
,, run (so I could also pass in other conditions.)   I suppose I could
,, use an eval on some string made up partly of the passed in arg,
,, but I wondered if there is any other way. Thanks for any comments.


To get Perl to interpret a string as code, the string needs to be
compiled.  The compiler is automatically invoked on startup, and if you
need to postpone compilation till runtime, the tool to wield is called
eval, or one of its disguises (s///e, /(?{ })/).



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: Wed, 22 Aug 2001 18:34:41 GMT
From: Benjamin Trott <ben@rhumba.pair.com>
Subject: Re: Perl PGP routines
Message-Id: <B7A94951.10932%ben@rhumba.pair.com>

>>> Wrong. Crypt::OpenPGP is a pure-Perl implementation of the OpenPGP
> standard
>>> (RFC2440). You still need the PGP software to encrypt/decrypt files.
>> 
>> He doesn't want to encrypt files, he wants to send email containing
>> encrypted data.
>> 
>> my $ciphertext = $pgp->encrypt(
>> Data => $plaintext,
>> KeyID => $key_id,
>> Armour => 1,
>> );
> 
> This encrypts data. So...He wants to encrypt data *AND* send email. His
> problem is his ISP wont install PGP and he is looking for a pure perl
> solution. There is none. You still need to install PGP to PGP encode data.

No, you don't. Crypt::OpenPGP *is* a pure Perl solution. If he does this:

    my $ciphertext = $pgp->encrypt(
        Data => $plaintext,
        KeyID => $key_id,
        Armour => 1,
    );

$ciphertext is an encrypted PGP message. It contains an encrypted version of
the original message, plus session key packets that hold the symmetric key
used to encrypt the message. $ciphertext could then be decrypted by anyone
with the private key, either using PGP or Crypt::OpenPGP.

If you are concerned about compatibility with other PGP implementations (eg.
PGP2, which only supports IDEA encryption), the 'Compat' parameter to
encrypt can help. Simply put Crypt::OpenPGP should be compatible with all
PGP implementations (and if it's not, let me know :).

I'm not sure where you see the distinction between "encrypt[ing] data" and
"PGP encod[ing] data". There is no difference, in this case: they are the
same thing, and the above example does both of them.

bye,
Ben



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

Date: Thu, 23 Aug 2001 07:47:47 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Perl rookie question!  Setting up perl to work with IIS or Personal Web Server
Message-Id: <lNVg7.11$w01.56376@news.interact.net.au>


"S Warhurst" <s.warhurst@rl.ac.uk> wrote in message
news:9m0j7m$18am@newton.cc.rl.ac.uk...
> "Melvin Morris" <mmorris@nas-corp.com> wrote in message
> news:2863b571.0108201321.36779ba@posting.google.com...
>
> > #!/usr/bin/perl
> > use strict;
> > use CGI qw(:standard);
> > print header;
> > print"<b>Test</b>";
>
> The line:  #!/usr/bin/perl is for unix.
>
> You need sth like:  #!c:/perl/bin/perl.exe

Rubbish!  Don't answer questions that are off topic and don't give incorrect
answers.




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

Date: 22 Aug 2001 18:14:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl4 bashing (was Re: syntax & compilation errors)
Message-Id: <9m0spr$9vm$1@mamenchi.zrz.TU-Berlin.DE>

According to Jasper McCrea  <jasper@guideguide.com>:
> Anno Siegel wrote:
> > 
> > According to Tad McClellan <tadmc@augustmail.com>:
> > > Nomade <lcamargo@vesper.com.br> wrote:
> > > >tadmc@augustmail.com (Tad McClellan) wrote in message
> > > news:<slrn9o29i6.qk0.tadmc@tadmc26.august.net>...
> > > >> Ilya Martynov <ilya@martynov.org> wrote:
> > >
> > > >> >which bundle Perl 4 with their OS.
> > >
> > > >>You are using a dead, flea-bitten camel carcass perl.
> > >
> > > >That one was good...
> > >
> > >
> > > It was taken directly from the FAQ answer that I referenced.
> > 
> > Call me a pedant, but I can never read that quip without noting that
> > no self-respecting flea would be seen *near* a dead camel, not to
> > mention bite it.
> > 
> > Anno
> 
> I don't think that it's specific whether the flea-bitten-ness occurs
> post-mortem.

 ...the only assumption that reconciles it with biology, yes.  One could
go farther and say it died of too many fleas, but that wouldn't be quite
right. It couldn't keep up with the other camel, that's what killed it.
And fleas.

Anno "moth-eaten" Siegel


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

Date: 22 Aug 2001 19:08:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perl4 bashing (was Re: syntax & compilation errors)
Message-Id: <slrn9o80pi.6m2.abigail@alexandra.xs4all.nl>

Ilya Martynov (ilya@martynov.org) wrote on MMCMXIII September MCMXCIII in
<URL:news:87k7zwktr2.fsf@abra.ru>:
== 
== TM> The *only* Perl is Perl 5.  5.005_03 preferably.
== 
== Just curious. Why not Perl 5.6.1? I know that 5.6.0 was very buggy but
== I've not heard about any major problems with 5.6.1 with exception for
== unicode support.


I guess you missed out the line:

>> I like this one that Randal posted about a year ago,


5.6.1 wasn't out by then.


Abigail
-- 
($;,$_,$|,$\)=("\@\x7Fy~*kde~box*Zoxf*Bkiaox"," "x25,1,"\r"); 
{vec($_=>1+$"=>$^F<<$^F)=ord($/^substr$;=>$"=int rand 24=>1);              
 print&&select$,,$,,$,,$|/($|+tr/ //c);redo if y/ //>$^F**2};


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

Date: Wed, 22 Aug 2001 23:51:44 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: race condition?
Message-Id: <9m19ai$c98$00$1@news.t-online.com>

"cp" <cpryce@pryce.net> schrieb im Newsbeitrag
news:g1Pg7.9392$x84.2847750@ruti.visi.com...

[snip]

>
> open oldfile (readonly)
> open newfile (create|write)
>
> while (<oldfile>) {
>     # change the lines that need changing, leave the lines that don't
>     print each line to the new file
> }
>
> close old
> close new
> rename old -> old.bak

What happens if another instance tries to open 'old' in between here? I
don't know whether a rename is atomic, but I'm positive that two aren't.
What if another instance modifies the records differently at the same time?
One of the changes will be lost if you don't lock, won't it?

> rename new to old

[snip]

Steffen




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

Date: Wed, 22 Aug 2001 14:11:34 -0700
From: "Um... Oh" <just@usenet.please>
Subject: redirect stderr for sub-routine
Message-Id: <3b8403dc$1_2@binarykiller.newsgroups.com>

How can I redirect stderror briefly in order to capture the output of a perl
module (not an external command). For example:

sub blah { print STDERR "hoo\n"; }

do_magic_thing;
blah
mh $fh = do_other_magic_thing;
print STDERR "hi\n";
if (something_happens) {
    print STDERR <$fh>;
}
print STDERR "ho\n";

So, if somthing_happens it prints:

hi
hoo
ho

otherwise, it prints:

hi
ho

Not really knowing what I'm doing, I tried:

open STDERR, ">&SAVERR";
open STDERR, ">err.log";
blah;
close STDERR;
open SAVEERR, ">&STDERR";
print STDERR "hi\n";
open ERR, "err.log";
print STDERR <ERR>;
close ERR;
print STDERR "ho\n";

but it don't woork.




-----=  Posted via Newsfeeds.Com, Uncensored Usenet News  =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
 Check out our new Unlimited Server. No Download or Time Limits!
-----==  Over 80,000 Newsgroups - 19 Different Servers!  ==-----


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

Date: Wed, 22 Aug 2001 23:53:37 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: redirect stderr for sub-routine
Message-Id: <3B8429E1.1040501@post.rwth-aachen.de>

Um... Oh wrote:

> How can I redirect stderror briefly in order to capture the output of a perl
> module (not an external command). For example:
> 
> sub blah { print STDERR "hoo\n"; }
> 
> do_magic_thing;
> blah
> mh $fh = do_other_magic_thing;
> print STDERR "hi\n";
> if (something_happens) {
>     print STDERR <$fh>;
> }

What is <$fh> exactly?

Anyway, I don't really have an idea what you want. My approach however:
Make yourself a subroutine, perhaps calling it trace:

sub trace {
	open STDERR, ">err.log"
		or die "Error: Could not redirect stderr: $!";
	print STDERR @_;
	close STDERR;
}

Alternatively (with the same effect, but looking more tricky):

$SIG{__WARN__} = sub {
		open STDERR, ">err.log" or die "Error: $!";
		print @_;
		close STDERR;
}

Inside your program you just put ' warn "Some warnings" ' and SIGWARN is 
triggered.


Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 22 Aug 2001 12:24:02 -0700
From: aspersion@yahoo.com (Isaac)
Subject: Why wont this work!?!?!?
Message-Id: <e680b373.0108221124.57fcfc99@posting.google.com>

Here is my dillema....I want the contents of file.txt to display to a
web browser.

When I run thise code from the command prompt I get:

C:\Inetpub\scripts\test>perl -w test420.pl
Content-Type: text/html; charset=ISO-8859-1

          Range Delay: 11360 meters

C:\Inetpub\scripts\test>

Which is the content of the file......Which is GOOD

But when I access it from a web browser it page comes up BLANK?!?!?!
No errors whatsoever.

Here is the perl program.

use CGI qw(:standard);
    open FILE, "file.txt"|| die $!;
    @fa = <FILE>; #makes file to an array
    close FILE;
$|=1;
print header;
print $fa[10];

Thanks, Isaac


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

Date: 22 Aug 2001 19:29:40 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Why wont this work!?!?!?
Message-Id: <slrn9o8h71.bre.trammell@haqq.hypersloth.net>

On 22 Aug 2001 12:24:02 -0700, Isaac <aspersion@yahoo.com> wrote:
[snip]
> But when I access it from a web browser it page comes up BLANK?!?!?!
> No errors whatsoever.

What do the server logs say?

-- 
IAAMOAC.


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

Date: Wed, 22 Aug 2001 13:02:47 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Why wont this work!?!?!?
Message-Id: <3B840FE7.57C10D1F@stomp.stomp.tokyo>

Isaac wrote:

(snipped)

> When I run thise code from the command prompt I get:
 
> C:\Inetpub\scripts\test>perl -w test420.pl
> Content-Type: text/html; charset=ISO-8859-1
 
>           Range Delay: 11360 meters
 

This is untrue. Your message is:

  " (offline mode: enter name=value pairs on standard input) "


> Here is the perl program.
 
> print $fa[10];
 
Your array contains less than eleven elements.


Godzilla!


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

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

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


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