[19773] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1968 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 20 18:05:40 2001

Date: Sat, 20 Oct 2001 15:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1003615513-v10-i1968@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 20 Oct 2001     Volume: 10 Number: 1968

Today's topics:
    Re: alarm and put a timeout on a perl program an its sh (Garry Williams)
        Best way to override $SIG{INT} so that it plays well wi <newspost@coppit.org>
    Re: Config data not as text file but as module code --  <markus.cl@gmx.de>
    Re: Config data not as text file but as module code --  (Garry Williams)
    Re: Edit In-Place Help (Tad McClellan)
    Re: Elegant Code - Indexing Letters (remove the obvious)
        File I/O <Neal.Coombes@telus.net>
    Re: File I/O (Tad McClellan)
    Re: Filename case... <iltzu@sci.invalid>
        finding a string in a list <allistante@zzzhotmailzzz.com>
    Re: finding a string in a list <jeff@vpservices.com>
    Re: finding a string in a list (Tad McClellan)
    Re: finding a string in a list <allistante@zzzhotmailzzz.com>
    Re: finding a string in a list <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Fork messes up parent file handle? (Chris Fedde)
        Good Literature <gclark@wavetel.com>
    Re: Good Literature <glob@cableone.net>
    Re: Good Literature <no_spam@none.com>
    Re: Good Literature (Tad McClellan)
    Re: good or bad code? <uri@sysarch.com>
    Re: good or bad code? (Clinton A. Pierce)
    Re: good or bad code? (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 20 Oct 2001 16:40:31 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: alarm and put a timeout on a perl program an its shell childs ?
Message-Id: <slrn9t3a7t.mts.garry@zfw.zvolve.net>

On Fri, 19 Oct 2001 14:50:50 +0200, Gildas PERROT
<perrot@NOSPAM.fluxus.net> wrote:

> I want to put a timeout on a perl program and its shell child. In order to
> kill both of them, I use "exec" but in that cas, I can set the SIG{ALRM}
> message which by default "Alarm clock". How can I do that ? When using
> system or '' to execute the shell command, this one is not killed at the
> timeout.

Huh?  I don't understand most of that.  

> Here is my perl code :
> 
> $timeout = 1;
> $SIG{'ALRM'} = "TIMEOUT !";

This is nonsense.  

See the perlvar manual page for how to correctly use the %SIG hash.
The perlipc manual page also discusses "Signals".  

> alarm($timeout);
> exec("/shell_cmd");
> alarm(0);

Huh?  The perlfunc manual page tells you that exec() does *not*
return (assuming "/shell_cmd" *can* be exec()ed).  How do you suppose
the last statement will ever be executed.  

Maybe the FAQ will help.  Read the "How do I timeout a slow event?"
section of the perlfaq8 manual page.  It will refer you to the
"Signals" section of the perlipc manual page.  That section discusses
using alarm() for timing out stuff.  

You are enabling warnings and use strict, aren't you?  

Hope this helps.  

-- 
Garry Williams


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

Date: Sat, 20 Oct 2001 13:03:26 -0400
From: David Coppit <newspost@coppit.org>
Subject: Best way to override $SIG{INT} so that it plays well with debugger?
Message-Id: <3BD1AE5E.9060504@coppit.org>

Hi all,

In one of my scripts I try to do a "clean exit" on SIGINT, SIGPIPE, etc:

   # Perform a clean exit with CTRL-C is caught, a pipe is empty, a
   # pipe is killed, etc.
   sub cleanExit
   {
     my $message = shift;
     print STDERR "grepmail: $message.\n";
     exit 1;
   }

   # Catch everything I can... We have to localize these to prevent odd
   # bugs from cropping up (see changelog).
   local $SIG{PIPE} = sub { cleanExit("Broken Pipe") };
   local $SIG{HUP} = sub { cleanExit("Hangup") };
   local $SIG{INT} = sub { cleanExit("Canceled") };
   local $SIG{QUIT} = sub { cleanExit("Killed") };
   local $SIG{TERM} = sub { cleanExit("Killed") };

Unfortunately, this doesn't seem to play well with the debugger. I think 
it's because the debugger installs it's own signal handlers. So I 
changed my code to use any existing signal handler:

   # Catch everything I can... We have to localize these to prevent odd
   # bugs from cropping up (see changelog).
   my $old_sig_pipe = $SIG{PIPE};
   my $old_sig_hup = $SIG{HUP};
   my $old_sig_int = $SIG{INT};
   my $old_sig_quit = $SIG{QUIT};
   my $old_sig_term = $SIG{TERM};
   local $SIG{PIPE} = $old_sig_pipe || sub { cleanExit("Broken Pipe") };
   local $SIG{HUP} = $old_sig_hup || sub { cleanExit("Hangup") };
   local $SIG{INT} = $old_sig_int || sub { cleanExit("Canceled") };
   local $SIG{QUIT} = $old_sig_quit || sub { cleanExit("Quit") };
   local $SIG{TERM} = $old_sig_term || sub { cleanExit("Terminated") };

Is this the best solution? Also, I grabbed the text to display when the 
signal is caught from what GNU grep does. Is there a set of standards 
for what to print? A module that encapsulates them?

Thanks,
David



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

Date: Sat, 20 Oct 2001 17:38:36 +0200
From: "Markus Dehmann" <markus.cl@gmx.de>
Subject: Re: Config data not as text file but as module code -- Oops!
Message-Id: <9qs5uj$pm999$1@ID-101658.news.dfncis.de>


"brian d foy" <comdog@panix.com> wrote in message
news:comdog-0DE686.10495720102001@news.panix.com...

> > script with "use Data;" is killed by the system.
>
> what do you mean "killed by the system".  you'll need to speak in
> something other than metaphors to help us help you. ;)

no, this isn't a metaphor! I start the script that uses the 20MB module and
wait a minute or so. But then, the script ends and I can read "Getötet."
which is German and means "Killed.".

So, the process is killed. And "Exporter" is not the problem, I found out.

With some test data, some KB, it works and the module way is much faster
than the data file way. But a module with >20MB source code seems to be too
much for the interpreter...? That's bad...




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

Date: Sat, 20 Oct 2001 17:38:35 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Config data not as text file but as module code -- Oops!
Message-Id: <slrn9t3dkr.mvj.garry@zfw.zvolve.net>

On Sat, 20 Oct 2001 17:38:36 +0200, Markus Dehmann <markus.cl@gmx.de> wrote:
> 
> "brian d foy" <comdog@panix.com> wrote in message
> news:comdog-0DE686.10495720102001@news.panix.com...
> 
>> > script with "use Data;" is killed by the system.
>>
>> what do you mean "killed by the system".  you'll need to speak in
>> something other than metaphors to help us help you. ;)
> 
> no, this isn't a metaphor! I start the script that uses the 20MB module and
> wait a minute or so. But then, the script ends and I can read "Getötet."
> which is German and means "Killed.".

Depending on the operating system, that may mean that a shared object
(.so) was not found or that a dynamic link was not resolved by ld.so.  

> So, the process is killed. And "Exporter" is not the problem, I found out.

Exporter simply creates aliases in the calling package.  

> With some test data, some KB, it works and the module way is much faster
> than the data file way. But a module with >20MB source code seems to be too
> much for the interpreter...? That's bad...

There's probably more to learn.  I wouldn't jump to such a conclusion.  

Another post suggested using a profiler to understand where the time
is being spent in your original solution.  That sounds like a better
approach than the one that you are taking.  

-- 
Garry Williams


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

Date: Sat, 20 Oct 2001 16:14:23 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Edit In-Place Help
Message-Id: <slrn9t3616.1tb.tadmc@tadmc26.august.net>

Buster Bunker <busterb@hotmail.com> wrote:
>I am trying to write a simple in-place edit of some files (e.g.
>*.txt), but I am having trouble getting the part where it writes the
>file.  I can only get it to write to the screen.  


Are you enabling in-place editing with the -i switch?


>Can someone suggest
>to me a method to do this?


Call it with the -i switch  :-)     (perldoc perlrun)

Or set the $^I variable             (perldoc perlvar)


>use strict;
>use warnings;
>
>my @args = splice(@ARGV,0);
>foreach my $arg (@args) {
>    push(@ARGV,glob($arg));
>}


You can replace those four lines with one:

   @ARGV = map { glob } @ARGV;

Easier to understand what it is doing too.


>$/ = undef;


Why are you enabling "slurp mode"?

I hope you don't think that has anything to do with in-place editing.

You don't have any processing that involves multiple lines, so
line-by-line should work fine. You can leave $/ with its default value.


>my $mcount = 0;
>while (<>) {


All of the contents of the first file go into $_.

You never do anything with $_. So long first file data...


>    my $s = <>;


This reads all of the second file.

Why are you doing 2 reads per loop iteration?

That looks like a mistake to me.


>    print $s;     # Print this to file  ?


It should, if you have in-place editing enabled.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 20 Oct 2001 18:06:50 GMT
From: "--Rick" <no_trick@my-de(remove the obvious)ja.com>
Subject: Re: Elegant Code - Indexing Letters
Message-Id: <_2jA7.134013$3d2.3912845@bgtnsc06-news.ops.worldnet.att.net>


"brian d foy" <comdog@panix.com> wrote in message
news:comdog-3C61D6.10073219102001@news.panix.com...
| In article <9a223a9d.0110181506.6372084b@posting.google.com>,
| iNeverReadAnythingSentToMe@hotmail.com (David Filmer) wrote:
|
| > But, now suppose that $var is a TWO-character alphabetic,
| > and it indexes like this:  AA >> AB, AB >> AC, etc, AZ >> BA (just
as
| > if it were a base-26 numbering system with only alphabetic digits).

Gee.  Why do those look so much like spreadsheet column identifiers?
If you are manipulating a spreadsheet, there might be a simpler way
to reference the cells.

--
--Rick




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

Date: Sat, 20 Oct 2001 19:21:40 GMT
From: "Neal E. Coombes" <Neal.Coombes@telus.net>
Subject: File I/O
Message-Id: <3BD1CFB9.A5E1CABA@telus.net>

In the blow code, $name never makes it into testfile.txt which contains
the text "some pattern" within it.  Any help would be appreciated.

#!/usr/bin/perl -w

$name = "some name";

open(CALLER, "+<testfile.txt") or die("Cannot open testfile.txt: $!");

while ($in = <CALLER>) {
  print $in;
  if ($in =~ /some pattern/) {
    print CALLER "$name\n";
    print "$name\n";
    last;
  }
}

close(CALLER);


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

Date: Sat, 20 Oct 2001 20:02:27 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: File I/O
Message-Id: <slrn9t3j80.2cs.tadmc@tadmc26.august.net>

Neal E. Coombes <Neal.Coombes@telus.net> wrote:

>In the blow code, $name never makes it into testfile.txt which contains
>the text "some pattern" within it.  Any help would be appreciated.


Don't interleave reads and writes.

If you do, then you need to seek() correctly between each:

   perldoc -f seek

If what you are putting in is not *exactly the same number of bytes*
as what you are taking out, then even this approach won't work.

In that case, see the Perl FAQ I mentioned in another followup.


>#!/usr/bin/perl -w

  use strict;

>$name = "some name";

   my $name = "some name";


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 20 Oct 2001 17:47:09 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Filename case...
Message-Id: <1003598841.1423@itz.pp.sci.fi>

In article <slrn9scel9.l88.mgjv@verbruggen.comdyn.com.au>, Martien Verbruggen wrote:
>
>the comparisons. However, there are semantic differences between the
>two versions. The regex may miss out on capitalisation in certain
>locales. I believe Finnish has some letters that could fall outside of
>the A-Z range. A more equivalent, and locale-safe version would be

Yes, just like German, French, Swedish, Danish, Norwegian, etc. -- in
fact, most European languages have letters outside the A-Z range.  And
even if all you're processing is English, sooner or later someone will
include a loanword like "cliché" in the text, with the accent intact.


>PS. According to perlre, [A-Z] is always a character class of 26
>letters. Is this really true? Even if the collation of the characters
>is someting like: A a B b C c D ..? perllocale is silent on this.

It may or may not be explictly documented for the general case, but at
least the EBCDIC ports are documented to treat purely alphabetic ranges
as special cases.  (Hmmm.. is that behavior locale-aware?  I have no
idea.)  So I'd say yes.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



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

Date: Sat, 20 Oct 2001 21:43:05 +0200
From: "Donato" <allistante@zzzhotmailzzz.com>
Subject: finding a string in a list
Message-Id: <9qsjvp$qvo$1@serra.unipi.it>

can anyone tell me if there is a short way to find a string in a list?
@list=~/stringa/ don't seems to work :-(

Donato




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

Date: Sat, 20 Oct 2001 12:48:38 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: finding a string in a list
Message-Id: <3BD1D516.D40A60AF@vpservices.com>

Donato wrote:
> 
> can anyone tell me if there is a short way to find a string in a list?
> @list=~/stringa/ don't seems to work :-(
> 
> Donato

perldoc -q contains


-- 
Jeff



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

Date: Sat, 20 Oct 2001 20:02:28 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: finding a string in a list
Message-Id: <slrn9t3jci.2cs.tadmc@tadmc26.august.net>

Donato <allistante@zzzhotmailzzz.com> wrote:

>can anyone tell me if there is a short way to find a string in a list?
>@list=~/stringa/ don't seems to work :-(


Use the grep() function when you want to "filter a list":

   my @list = grep /stringa/, @big_list_to_filter;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 20 Oct 2001 22:20:48 +0200
From: "Donato" <allistante@zzzhotmailzzz.com>
Subject: Re: finding a string in a list
Message-Id: <9qsm6g$st8$1@serra.unipi.it>

"Tad McClellan" <tadmc@augustmail.com> ha scritto nel messaggio
news:slrn9t3jci.2cs.tadmc@tadmc26.august.net...
> Donato <allistante@zzzhotmailzzz.com> wrote:
>
> >can anyone tell me if there is a short way to find a string in a list?
> >@list=~/stringa/ don't seems to work :-(
>
>
> Use the grep() function when you want to "filter a list":
>
>    my @list = grep /stringa/, @big_list_to_filter;
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas

In perlfaq4 I have found this:

 ...
     Please do not use

         ($is_there) = grep $_ eq $whatever, @array;

     or worse yet

         ($is_there) = grep /$whatever/, @array;

2001-10-20          Last change: perl v5.7.2                    1

User Contributed Perl Documentation                  BAASZAYXF(1)

     These are slow (checks every element even if the first
     matches), inefficient (same reason), and potentially buggy
     (what if there are regex characters in $whatever?).  If
     you're only testing once, then use:

         $is_there = 0;
         foreach $elt (@array) {
             if ($elt eq $elt_to_find) {
                 $is_there = 1;
                 last;
             }
         }
         if ($is_there) { ... }




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

Date: Sat, 20 Oct 2001 23:36:37 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: finding a string in a list
Message-Id: <3BD1EE65.1000106@post.rwth-aachen.de>

Donato wrote:

> "Tad McClellan" <tadmc@augustmail.com> ha scritto nel messaggio


>>Use the grep() function when you want to "filter a list":
>>
>>   my @list = grep /stringa/, @big_list_to_filter;


[...]

> In perlfaq4 I have found this:
> 
> ...
>      Please do not use
> 
>          ($is_there) = grep $_ eq $whatever, @array;
> 
>      or worse yet
> 
>          ($is_there) = grep /$whatever/, @array;


[...]

Sure, but Tad was referring to something quite different. With filtering 
he meant to get _all_ elements applying to a certain a rule and not to 
check whether the array contains one such element. That's what this FAQ 
is referring to.


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: Sat, 20 Oct 2001 20:31:26 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Fork messes up parent file handle?
Message-Id: <yalA7.224$1L8.197620224@news.frii.net>

In article <3BD18499.47A5308D@brighton.ac.uk>,
John English  <je@brighton.ac.uk> wrote:
>Chris Fedde wrote:
>> 
>> You probably want the child to exit(0) after the do_child_stuff rather than
>> last.
>
>When it falls out of the loop there's some common cleanup for both
>parent and child (close IN; a few other details; then exit), so I
>was trying to avoid code duplication. However, I did try putting all
>the cleanup stuff (and exit) inside do_child_stuff, and it makes no
>difference at all.
>

You might create the smallest reasonable bit of code that exhibits
the problem you are seeing and try posting that. The problem is likely to
be in the details. 
-- 
    This space intentionally left blank


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

Date: Sat, 20 Oct 2001 18:22:35 GMT
From: "Geoff Clark" <gclark@wavetel.com>
Subject: Good Literature
Message-Id: <LhjA7.831003$NK1.74319411@bin3.nnrp.aus1.giganews.com>

Can anyone suggest any good literture on wirting CGI Scripts.  This is what
I need to acomplish.  This will be a simple one page, with 3 sections.  1st
Section is to look into a file and search for a given mac address and
display the IP  Address.  Example file looks as follows:

p10020D6ACB204  00      10.1.66.13      10.1.64.2       1021903392
voicedhc
p10020D6BC31B4  00      10.1.66.14      10.1.64.2       1022592484
voicedhc
p10020D68CDA8D  00      10.1.66.15      10.1.64.2       1026616822
voicedhc
p10020D69C3B94  00      10.1.66.16      10.1.64.2       1026565757
voicedhc
p10020D6ACB867  00      10.1.66.17      10.1.64.2       1026601343
voicedhc
p10020D6AC5868  00      10.1.66.18      10.1.64.2       1025879013
voicedhc
p10020D68CD088  00      10.1.66.19      10.1.64.2       1026180392
voicedhc
p10020D6A495D0  00      10.1.66.20      10.1.64.2       1024678502
voicedhc
p10020D6AC943A  00      10.1.66.21      10.1.64.2       1025900903
voicedhc
p10020D6BC4E00  00      10.1.66.22      10.1.64.2       1022700185
voicedhc

But when searching I want to be able to search on any part of the string.
Example: 4E00 finds p10020D6BC4E00 .

2nd thing is to ping the the IP Address the search pulls back.

3rd and final is to run a set command using SNMP on a given parameter.

Thank you, and I hope this makes since.

Geoff




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

Date: Sat, 20 Oct 2001 11:40:00 -0700
From: "David Aslanian" <glob@cableone.net>
Subject: Re: Good Literature
Message-Id: <20011020.113952.638422090.8983@localhost.localdomain>

In article <LhjA7.831003$NK1.74319411@bin3.nnrp.aus1.giganews.com>, "Geoff
Clark" <gclark@wavetel.com> wrote:
For the "good literture" part, try 

www.google.com 
www.devshed.com
www.webmonkey.com

and look around for help there for witing cgi scripts in perl (I assume
you already know perl). I can tell you right now that you're going to
need to use the CGI module, and you might want to install and take a look
at that at CPAN (search.cpan.org).

Hope it helps...
> Can anyone suggest any good literture on wirting CGI Scripts.  This is
> what I need to acomplish.  This will be a simple one page, with 3
> sections.  1st Section is to look into a file and search for a given mac
> address and display the IP  Address.  Example file looks as follows: 
> p10020D6ACB204  00      10.1.66.13      10.1.64.2       1021903392
> voicedhc
> p10020D6BC31B4  00      10.1.66.14      10.1.64.2       1022592484
> voicedhc
> p10020D68CDA8D  00      10.1.66.15      10.1.64.2       1026616822
> voicedhc
> p10020D69C3B94  00      10.1.66.16      10.1.64.2       1026565757
> voicedhc
> p10020D6ACB867  00      10.1.66.17      10.1.64.2       1026601343
> voicedhc
> p10020D6AC5868  00      10.1.66.18      10.1.64.2       1025879013
> voicedhc
> p10020D68CD088  00      10.1.66.19      10.1.64.2       1026180392
> voicedhc
> p10020D6A495D0  00      10.1.66.20      10.1.64.2       1024678502
> voicedhc
> p10020D6AC943A  00      10.1.66.21      10.1.64.2       1025900903
> voicedhc
> p10020D6BC4E00  00      10.1.66.22      10.1.64.2       1022700185
> voicedhc
> But when searching I want to be able to search on any part of the
> string. Example: 4E00 finds p10020D6BC4E00 .
> 2nd thing is to ping the the IP Address the search pulls back.  3rd and
> final is to run a set command using SNMP on a given parameter.  Thank
> you, and I hope this makes since.  Geoff
>


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

Date: Sat, 20 Oct 2001 18:55:55 GMT
From: "mike w" <no_spam@none.com>
Subject: Re: Good Literature
Message-Id: <3bd1d20f$1@news.peakpeak.com>


Geoff Clark <gclark@wavetel.com> wrote in message
news:LhjA7.831003$NK1.74319411@bin3.nnrp.aus1.giganews.com...
> Can anyone suggest any good literture on wirting CGI Scripts.  This is
what

www.cgi101.com   Great place to begin.






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

Date: Sat, 20 Oct 2001 19:49:12 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Good Literature
Message-Id: <slrn9t3g8n.28n.tadmc@tadmc26.august.net>

Geoff Clark <gclark@wavetel.com> wrote:

>Can anyone suggest any good literture on wirting CGI Scripts.  


Why do you ask?

There is no CGI aspect to what you describe below.

CGI is (from the perl program's point of view) nothing more
than a different method of input and output. The guts of the
program will be the same even if run from the command line.


You should check the Perl FAQs before posting to the Perl newsgroup:

   perldoc -q CGI

      "How can I make my CGI script more efficient?"

      "Where can I learn about CGI or Web programming in Perl?"

      "How can I get better error messages from a CGI program?"

      "How do I decode a CGI form?"


>But when searching I want to be able to search on any part of the string.
>Example: 4E00 finds p10020D6BC4E00 .


Use a pattern match. See the "Regexp Quote-Like Operators" section in:

   perldoc perlop

and all of

   perldoc perlre


>2nd thing is to ping the the IP Address the search pulls back.

Go to:

   http://search.cpan.org/

and type "ping" (without the quotes) in the little search box.


>3rd and final is to run a set command using SNMP on a given parameter.

   http://search.cpan.org/

Again.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 20 Oct 2001 15:41:38 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: good or bad code?
Message-Id: <x7lmi648tg.fsf@home.sysarch.com>

>>>>> "JL" == Jens Luedicke <jens@irs-net.com> writes:

  JL> Stephen Patterson wrote:
  >> On Sat, 20 Oct 2001 13:07:46 +0200, Jens Luedicke wrote:
  >>> hi ...
  >>> 
  >>> is this rather good or bad code?
  >>> 
  >>> ($mails_sth,$filters_sth)->finish;
  >> 
  >> Does it work?
  >> 
  >> 

  JL> yes. I hacked it up as a replacement for

  JL>         }
  JL>         $mails_sth->finish;
  JL> }
  JL> $filters_sth->finish;

are you sure? do both calls get made in the new code?

and the older code had the two calls in different scopes so possibly one
was made and the other one wasn't. there are more differences that you
realize.

final comment: what does this do:

	$foo = ( $bar, $baz ) ;

think carefully and apply it to your new line of code.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Sat, 20 Oct 2001 15:47:56 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: good or bad code?
Message-Id: <M0hA7.187018$K6.90034109@news2>

[Posted and mailed]

In article <9qs36p$g8c$06$1@news.t-online.com>,
	Jens Luedicke <jens@irs-net.com> writes:
> Stephen Patterson wrote:
>> On Sat, 20 Oct 2001 13:07:46 +0200, Jens Luedicke wrote:
>>> hi ...
>>> 
>>> is this rather good or bad code?
>>> 
>>>         ($mails_sth,$filters_sth)->finish;
>> Does it work?
>> 
> 
> yes. I hacked it up as a replacement for
> 
>         }
>         $mails_sth->finish;
> }
> $filters_sth->finish;

"I hacked it up" -- you didn't patch the Perl source did you?

These don't do the same thing at ALL.  (Wish they did, but that's another
lamentation.)  Here's a piece of demo code:

	#!/usr/bin/perl -w

	$foo={name => 'foo'};
	$bar={name => 'bar'};
	bless $foo, "main";
	bless $bar, "main";

	sub finish {
		print $_[0]->{name}
	}
	($foo,$bar)->finish();

What happens is that $bar->finish() gets called, but $foo->finish() doesn't.
Why?  Because ($foo,$bar) is in a scalar context here.  In a scalar context
the comma operator evaluates both terms and returns the value of the 
rightmost term.  If you've got warnings turned on, you'll get warned
about $foo being used in a void context (it's being evaluated, but for no
apparent reason).


-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Sat, 20 Oct 2001 16:14:20 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: good or bad code?
Message-Id: <slrn9t3471.1tb.tadmc@tadmc26.august.net>

Jens Luedicke <jens@irs-net.com> wrote:
>
>is this rather good or bad code?


You should *always* enable warnings when developing Perl code!


>        ($mails_sth,$filters_sth)->finish;


It is bad code.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

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


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