[8309] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1926 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 18 21:17:49 1998

Date: Wed, 18 Feb 98 18:01:43 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 18 Feb 1998     Volume: 8 Number: 1926

Today's topics:
    Re: Regex & locales. <rjk@coos.dartmouth.edu>
    Re: Regexp question/problem... (Martin Vorlaender)
    Re: Regexp question/problem... <sgermain@nortel.ca>
    Re: Regexp question/problem... <sami@ehdo.ton.tut.fi>
    Re: Regexp question/problem... (Douglas Wilson)
        REMOTE_HOST (Steve)
    Re: RFC about "Matt's Script Archive" <Russell_Schulz@locutus.ofB.ORG>
        s/$x/$y/e question <nospam@no.spam>
    Re: Securing Form Input?!?!? <ebohlman@netcom.com>
    Re: sourcing csh scripts from within perl scott@softbase.com
    Re: split on ':', but not '\:' (Jeff Yoak)
    Re: split on ':', but not '\:' <gbarr@ti.com>
    Re: split on ':', but not '\:' (Ilya Zakharevich)
    Re: split on ':', but not '\:' (Michael J Gebis)
    Re: split on ':', but not '\:' (Taylor Gautier)
    Re: split on ':', but not '\:' <sami@ehdo.ton.tut.fi>
    Re: split on ':', but not '\:' (Ilya Zakharevich)
        String Extraction and checkup <evert.smit@eds.ch>
    Re: sucess stories? (Abigail)
    Re: sucess stories? (Earl Hood)
        suid script newbie question (JackE)
        timing out a socket... plambert$1@plambert.org
    Re: timing out a socket... <gbarr@ti.com>
    Re: ts: Remove files in a PERL sript <tchrist@mox.perl.com>
    Re: Undefined Subroutine in &Module::Package::SubPackag <ragoff@sandia.gov>
    Re: Undefined Subroutine in &Module::Package::SubPackag (Jonathan Feinberg)
    Re: Undefined Subroutine in &Module::Package::SubPackag <mhh@nortel.ca>
        Unlink and rmdir <Kari.Marttila.@tietogroup.com>
        useful citation lines (was Re: Killfile Triage) <Russell_Schulz@locutus.ofB.ORG>
    Re: Why do I get this error on SunOS5? twod@not.valid
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 18 Feb 1998 00:25:24 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: Regex & locales.
Message-Id: <34EA70C5.5230D3B4@coos.dartmouth.edu>

[posted and mailed]

Ilya Zakharevich wrote:
> 
> Chipmunk wrote in article <34EA2384.437D1098@coos.dartmouth.edu>:
> >
> > $uc = '[^' . lc join('', map {chr} 0x00 .. 0x7F) . ']';
> >
> > $string =~ /$uc/;
> 
> Did you try this?  I think '-', '\\' and ']' will bite you hard.  But
> otherwise it is pretty cool...

Due a bit of confusion on my part, I got an error when I tried using
quotemeta.  (Without the parens, so the precedence got me.  Oops.  And it
seemed to work anyway.)

$uc = '[^' . quotemeta(lc join('', map {chr} 0x00 .. 0xFF)) . ']';

Thanks!

-- 
 _ / '  _      /             rjk@coos.dartmouth.edu
( /)//)//)(//)/(                     chipmunk@m-net.arbornet.org
    /                                        http://www.ziplink.net/~rjk/


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

Date: Wed, 18 Feb 1998 21:50:55 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Regexp question/problem...
Message-Id: <34eb49af.524144494f47414741@radiogaga.harz.de>

Sylvain St.Germain (sgermain@nortel.ca) wrote:
: How would you match a string in the following format:

: AWord.AWord.AWord.add.ini

: Why this does nod work?
: if (/(.*\.){2,}\.add\.ini/) {
           ^      ^
One dot too many. This regexp would match AWord.AWord.AWord..add.ini
Leave out the one in front of 'add', and it'll work.

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: Wed, 18 Feb 1998 15:30:47 -0500
From: "Sylvain St.Germain" <sgermain@nortel.ca>
Subject: Re: Regexp question/problem...
Message-Id: <34EB44F6.BD2424A0@nortel.ca>

I got it thanks for your time...
Sylvain.

Sami Sandqvist wrote:

> "Sylvain St.Germain" <sgermain@nortel.ca> writes:
>
> > Hi,
> >
> > How would you match a string in the following format:
> >
> > AWord.AWord.AWord.add.ini
> >
> > Why this does nod work?
> > $_ = $Line;
> > if (/(.*\.){2,}\.add\.ini/) {
> >     push ...
> > elsif ...
>
> You did not say specifically what it doesn't do. I assume you would
> want as many matches as possible for the (.*\.). Unfortunately (in
> this case) '.' matches '\.'. Say what you mean. Try
> /([^\.]*\.){2,}\.add\.ini/. You might also want to do the match in
> list context so that the matches will be easier to process.
>
> Sami
> --
> #!/bin/perl -w
> $_="wee buvkz\nucy!xrtashnpm lrkeprr qloejhithognfaajdtcs";
> s$([jp])$\u\$1$g;s;(.)(\n|.);${lc$1}=$2;eg;print map{$$_}("a".."z");
> #Sami Sandqvist - samiss@cc.tut.fi - Finger for PGP key.





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

Date: 18 Feb 1998 21:41:43 +0200
From: Sami Sandqvist <sami@ehdo.ton.tut.fi>
Subject: Re: Regexp question/problem...
Message-Id: <m3zpjok8eg.fsf@ehdo.ton.tut.fi>

"Sylvain St.Germain" <sgermain@nortel.ca> writes:

> Hi,
> 
> How would you match a string in the following format:
> 
> AWord.AWord.AWord.add.ini
> 
> Why this does nod work?
> $_ = $Line;
> if (/(.*\.){2,}\.add\.ini/) {
>     push ...
> elsif ...

You did not say specifically what it doesn't do. I assume you would
want as many matches as possible for the (.*\.). Unfortunately (in
this case) '.' matches '\.'. Say what you mean. Try
/([^\.]*\.){2,}\.add\.ini/. You might also want to do the match in
list context so that the matches will be easier to process.

Sami
-- 
#!/bin/perl -w
$_="wee buvkz\nucy!xrtashnpm lrkeprr qloejhithognfaajdtcs";
s$([jp])$\u\$1$g;s;(.)(\n|.);${lc$1}=$2;eg;print map{$$_}("a".."z");
#Sami Sandqvist - samiss@cc.tut.fi - Finger for PGP key.


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

Date: Wed, 18 Feb 1998 19:50:10 GMT
From: dgwilson@gte.net (Douglas Wilson)
Subject: Re: Regexp question/problem...
Message-Id: <6cfdv9$8uc$1@gte1.gte.net>

On Wed, 18 Feb 1998 11:43:27 -0500, "Sylvain St.Germain"
<sgermain@nortel.ca> wrote:

>Hi,
>
>How would you match a string in the following format:
>
>AWord.AWord.AWord.add.ini
>
>Why this does nod work?
because I believe you want:
$Line="abcd.abcd.add.ini";
$_ = $Line;
if (/(.*\.){2,}add\.ini/) {
            ^^^^ no "\." before the 'add'
 print "$1\n";
}
if (/(.*)\.ini/) {
 print "$1\n";
}



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

Date: Wed, 18 Feb 1998 21:50:16 GMT
From: trollboy@usa.net (Steve)
Subject: REMOTE_HOST
Message-Id: <34eb575f.22342054@news.tiac.net>

How do i have a script log your ip address so it looks like for
example this:   p9.ts3.lowel.MA.tiac.com   instead of    207.60.164.74


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

Date: Wed, 18 Feb 1998 13:53:25 +0000
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <19980218.135325.4J5.rnr.w164w@locutus.ofB.ORG>

c28f62@world.std.com (Mark Kramer) writes:

> Admit it; if it was someone besides Tom who was complaining that
> a free piece of software wasn't written the way he liked code to
> be written, would you you be supporting him or telling him to
> write his own if he didn't like the free stuff?

aren't they the same attitude?

if a complainer has already given you a lot of free code, that you
use yourself, don't complain so hard at the complainer.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Wed, 18 Feb 1998 10:48:38 -0800
From: Dave Winters <nospam@no.spam>
Subject: s/$x/$y/e question
Message-Id: <34EB2D06.58D3FE6E@no.spam>

Hi,

    I'm having a little trouble with regular expression substitution.
I'd like to use a variable as the replacement string.  I'd also like
this variable to contain references ($1, $2, etc.) to the match.

  I've attached a simple example.  I thought the /e modifier would cause

the $replace to get "eval-ed" and the $1, $2 to get substituted
properly.
Any idea what I'm doing wrong?

  If it matters, I'm running:

This is perl, version 5.003 with EMBED
        built under solaris at Sep  9 1996 16:22:35

Thanks for any help,

Dave Winters

$adr = 'dwinters';
$adr .= '@';
$adr .= 'juniper.net';

Please post replies to this newgroup or e-mail to $adr
(Reply To: is incorrect)

________________example.pl ____________________________

#!/usr/local/bin/perl

$in = '__A__123___456__B_';

$find = '_([0-9]*)___([0-9]*)_';
$replace = ' $1 XX $2 ';

($out_ok1  = $in) =~ s/_([0-9]*)___([0-9]*)_/ $1 XX $2 /;
($out_ok2  = $in) =~ s/$find/ $1 XX $2 /;
($out_bad1 = $in) =~ s/$find/$replace/;
($out_bad2 = $in) =~ s/$find/$replace/e;
($out_bad3 = $in) =~ s/$find/\$replace/ee;

print "INPUT: $in\n";
print "FIND: $find\n";
print "REPLACE: $replace\n";
print "$out_ok1\n";
print "$out_ok2\n";
print "$out_bad1\n";
print "$out_bad2\n";
print "$out_bad3\n";

__________________end example.pl ________________________

output of example.pl:

INPUT: __A__123___456__B_
FIND: _([0-9]*)___([0-9]*)_
REPLACE:  $1 XX $2
__A_ 123 XX 456 _B_
__A_ 123 XX 456 _B_
__A_ $1 XX $2 _B_
__A_ $1 XX $2 _B_
__A__B_






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

Date: Wed, 18 Feb 1998 08:49:11 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Securing Form Input?!?!?
Message-Id: <ebohlmanEoKGHz.H6s@netcom.com>

Chad Casselman <c2@3-g.com> wrote:
: How do I parse, truncate, or whatever to form input to make sure that it
: is secure and not going to erase everything.  

: Basicallly, how do I check for valid information and not system
: commands?

"perldoc perlsec" will give you plenty of food for thought.



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

Date: 18 Feb 1998 18:48:31 GMT
From: scott@softbase.com
Subject: Re: sourcing csh scripts from within perl
Message-Id: <6cfadv$cdj$2@mainsrv.main.nc.us>

J Robert Ray (robert@visionart.com) wrote:
> Is it possible to "source" a csh script from within a perl program?  I have
> a script that sets environment variables, and would like to execute the
> script then access the environment variables.

If you *only* want the environment variables, write a Perl subroutine
(or module) that reads the file, pulls out any setenv lines, and
manually adds the variable and value pairs to %ENV. The setenv
syntax is just space separated words you could split.

Pseudocode:

	open(...)
	for grep setenv <>
		setenv, key, val = split ...
		$ENV{key} = val
	close...

You'll probably want to handle comments, too.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Wed, 18 Feb 1998 21:01:42 GMT
From: jeff@yoak.com (Jeff Yoak)
Subject: Re: split on ':', but not '\:'
Message-Id: <6cfijt$352@dfw-ixnews9.ix.netcom.com>

[posted and emailed]

Justin Banks <justinb@cray.com> wrote:

>Hello -
>	I'm trying to split a line on colons, except where the colon is 
>backslashified, and I can't seem to make it happen. I've tried replacing
>the sequence '\:' before the split, like so :

>$line = "one:two:three\:here:four";

I couldn't figure out why my code wasn't working because I copied this
line directly into my test script.  Single quotes are a little more
appropriate here.  :)  That may have been part of your problem.

Text::ParseWords will do what you need here.

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

use Text::ParseWords;

$line = 'one:two:three\:here:four';
@parts = &quotewords(":", 0, $line);

-------------------------------
Jeff Yoak         jeff@yoak.com



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

Date: Wed, 18 Feb 1998 14:33:50 -0600
From: Graham Barr <gbarr@ti.com>
Subject: Re: split on ':', but not '\:'
Message-Id: <34EB45AE.A12BF354@ti.com>

Ilya Zakharevich wrote:
> 
> <justinb@cray.com>],
> > Hello -
> >       I'm trying to split a line on colons, except where the colon is
> > backslashified, and I can't seem to make it happen. I've tried replacing
> > the sequence '\:' before the split, like so :
> 
> use 5.00455;
> split /(?<!\\):/;

Ilya, you have to take all the fun out of it don't you :-)

Graham.

-- 
Originality is the ability to conceal your source.


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

Date: 18 Feb 1998 21:55:22 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: split on ':', but not '\:'
Message-Id: <6cflca$gc5$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Graham Barr 
<gbarr@ti.com>],
who wrote in article <34EB45AE.A12BF354@ti.com>:
> Ilya Zakharevich wrote:

> > use 5.00455;
> > split /(?<!\\):/;

> Ilya, you have to take all the fun out of it don't you :-)

Did not we all wish it 3 times *each*?  ;-)

In fact implementing it took 3 or 4 lines of C, *after* I understood
*what* it is we all wanted 3 times.  The sniffer had the info about
the length already, so the only thing to do was to allow a shift back
in the opcodes for (?=...) and (?!...).

(And add error messages for all the cases which are not imlemented yet
:-()

Ilya


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

Date: 18 Feb 1998 19:20:33 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: split on ':', but not '\:'
Message-Id: <6cfca1$l5v@mozo.cc.purdue.edu>

Justin Banks <justinb@cray.com> writes:

}Hello -
}	I'm trying to split a line on colons, except where the colon is 
}backslashified, and I can't seem to make it happen. I've tried replacing
}the sequence '\:' before the split, like so :

}$line = "one:two:three\:here:four";
print STDOUT "$line\n";

You don't HAVE the sequence '\:' in your example strings.

In any case, pick up a copy of the drunken Owls (by Freidl).  To me,
this looks like a job for regexps, not split.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 18 Feb 1998 19:27:35 GMT
From: tgautier@monazite.geoworks.com (Taylor Gautier)
Subject: Re: split on ':', but not '\:'
Message-Id: <6cfcn7$i6$1@news>

Justin Banks (justinb@cray.com) wrote:
: Hello -
: 	I'm trying to split a line on colons, except where the colon is 
: backslashified, and I can't seem to make it happen. I've tried replacing
: the sequence '\:' before the split, like so :

: $line = "one:two:three\:here:four";
: $line =~ s/\\(?=:)/BACKSLASH/g;
: print "$line\n";

This is the best I can come up with, I can't come up with a
"non-programmatic" way to do it.  

[====
# I assume you meant to have an "actual" \ in the string $line
$line = "one:two:three\\:here:four";

@vals = split(/\\:/, $line);

map {
  @newvals = split(/:/, $_);
  if (defined @split) {
    $split[-1] .= "\\:" . shift @newvals;
  }
  push (@split, @newvals);
} @vals;

print join(" ", @split);
=====]

gives the output I assume you desired:

one two three\:here four

tg
_________________________________________________________________________
Taylor Scott Gautier                                tgautier@geoworks.com


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

Date: 18 Feb 1998 21:27:34 +0200
From: Sami Sandqvist <sami@ehdo.ton.tut.fi>
Subject: Re: split on ':', but not '\:'
Message-Id: <m31zx0lnmh.fsf@ehdo.ton.tut.fi>

Justin Banks <justinb@cray.com> writes:

> Hello -
> 	I'm trying to split a line on colons, except where the colon is 
> backslashified, and I can't seem to make it happen. I've tried replacing
> the sequence '\:' before the split, like so :
> 
> $line = "one:two:three\:here:four";
> $line =~ s/\\(?=:)/BACKSLASH/g;
> print "$line\n";

In doublequoted strings, the backslashes are evaluated. See:

ehdo:[~] % perl -e 'print "one:two:three\:here:four\n"'
one:two:three:here:four
ehdo:[~] % 

Try this:
---------
#!/bin/perl -w
$_='one:two:three\:here:four';
print split /(^|[^\\]):/;
---------

HTH.

Sami
-- 
#!/bin/perl -w
$_="wee buvkz\nucy!xrtashnpm lrkeprr qloejhithognfaajdtcs";
s$([jp])$\u\$1$g;s;(.)(\n|.);${lc$1}=$2;eg;print map{$$_}("a".."z");
#Sami Sandqvist - samiss@cc.tut.fi - Finger for PGP key.


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

Date: 18 Feb 1998 20:07:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: split on ':', but not '\:'
Message-Id: <6cff1f$2pa$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Justin Banks 
<justinb@cray.com>],
who wrote in article <o8nn2foj1ur.fsf@ebony.cray.com>:
> Hello -
> 	I'm trying to split a line on colons, except where the colon is 
> backslashified, and I can't seem to make it happen. I've tried replacing
> the sequence '\:' before the split, like so :

use 5.00455;
split /(?<!\\):/;

Ilya


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

Date: Wed, 18 Feb 1998 09:57:59 +0100
From: Evert Smit <evert.smit@eds.ch>
Subject: String Extraction and checkup
Message-Id: <34EAA297.47B433C3@eds.ch>

This is a multi-part message in MIME format.
--------------51E13E4DC7BC050588950DCF
Content-Type: text/plain; charset=us-ascii
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Transfer-Encoding: 7bit

hello everyone...

i am looking for a piece of perl script, that will look at a string, rip
it appart, check if it is 8 digits long and make sure that there are 2
numbers in it. I am sure someone has this one already and would be
eternally thankful, if i could use it.

Evert

--
___________________________________

HTTP://WWW.KSHAR.COM                   HTTP://www.eds.com
Page me at: HTTP://www.pagoo.com/cgi-bin/me.cgi?6081226
or try this one: HTTP://wwp.mirabilis.com/1386975
___________________________________


--------------51E13E4DC7BC050588950DCF
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Evert Smit
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Evert Smit
n:              Smit;Evert
org:            EDS
adr:            Flughofstrasse 35;;;Glattbrugg;ZH;8152;Switzerland
email;internet: evert.smit@eds.ch
title:          Newmedia
tel;work:       +41-1-8095111
tel;fax:        +41-1-8095222
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
end:            vcard


--------------51E13E4DC7BC050588950DCF--



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

Date: 18 Feb 1998 18:23:41 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: sucess stories?
Message-Id: <6cf8vd$5sl$1@client2.news.psi.net>

Ronald L. Parker (ron@farmworks.com) wrote on 1632 September 1993 in
<URL: news:34ede53e.2892609@10.0.2.33>:
++ On 18 Feb 1998 00:43:07 GMT, abigail@fnx.com (Abigail) wrote:
++ 
++ >Goodie. Now I got to write $self -> {__MYCLASS} -> {attr1} to access
++ >an object instance variable. I'm not claiming you can't do it. But
++ >I find "$self -> {__MYCLASS} -> {attr1}" incredible long compared
++ >to "$attr1", which I would use for a normal variable. package Foo::Bar;
++ >makes that I don't have to prefix it all the time to make my name unique
++ >(not to mention the pleasure of my) and with use strict; I can catch
++ >possible typos at compile time. That's all lost when Perl goes OO.
++ 
++ Go reread perltoot.  I did, and I was surprised to see this paragraph
++ that I (and apparently everyone else but Tom) missed before:
++ 
++ |This same model is often used for classes, although it is not considered
++ |the pinnacle of programming propriety for folks from outside the
++ |class to come waltzing into an object, brazenly accessing its data
++ |members directly.  Generally speaking, an object should be considered
++ |an opaque cookie that you use I<object methods> to access.  Visually,
++ |methods look like you're dereffing a reference using a function name
++ |instead of brackets or braces.
++ 
++ If you used accessor methods, you'd only have to write 
++ $self -> {__MYCLASS} -> {attr1} once or twice.  

Really?

colour {
    my $self = shift;
    $self -> {__MYCLASS} -> {colour} = shift if @_;
    $self -> {__MYCLASS} -> {colour};
}

That's twice for one attribute. Multiply that with the number of
attributes you have.

This looks neat, doesn't? Now we can simple use $self -> colour;

But this is even worse than before! Remember we came up with the
{__MYCLASS} part to avoid name collision with an inherited class that uses
'colour' as well to keep state. (Remember this is internal state, and
has nothing to do with a public interface, it's "work behind the scenes").
Now if the inherited module also uses a method colour () to get to
its own state, we have a name clash again. 

Of course, you can say that if you want to access your own state,
you call $self -> My::Package::method, but then you are back to
long complicated names that don't get checked at compile time.


++ Also, I'm reminded of a couple of chapters from /Effective C++/:
++ 20: Avoid data members in the public interface.

I never ever talked about putting data members in the public interface.
I am complaining about storing data *TO KEEP TRACK OF ITS OWN STATE*
You suggest promoting access to your own internal members by methods -
which by definition are public.

++ 29: Avoid returning "handles" to internal data from const member
++ functions.

I very very seldom write code where I do $obj -> {foo} where 
$obj -> {foo} isn't used by my current class.

++ Personally, I'd avoid returning "handles" to internal data from /any/
++ member function, but maybe that's just me.
++ 
++ You've been talking exclusively about variables; what do we do about
++ the fact that every method is what C++ would call "virtual"?  Do we
++ have to start messing with lexical scoping and closures and the like
++ if we want to have a non-virtual method?  (I see no reason for public
++ methods to not be virtual.)

I don't know what you mean by virtual, I've no experience with C++.

++ >And you're still hosed if the inherited object didn't use a hashref.
++ >You make yourself dependent on the internal implementation of the
++ >inherited object. You break the abstraction model. 
++ 
++ This much is true.  Good thing most people use hashes. 



Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


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

Date: 18 Feb 1998 20:00:13 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: sucess stories?
Message-Id: <6cfekd$k5a@news.service.uci.edu>

In article <6cf8vd$5sl$1@client2.news.psi.net>,
Abigail <abigail@fnx.com> wrote:

>colour {
>    my $self = shift;
>    $self -> {__MYCLASS} -> {colour} = shift if @_;
>    $self -> {__MYCLASS} -> {colour};
>}
>
>That's twice for one attribute. Multiply that with the number of
>attributes you have.

First, you can remove the second set of "->" since it is implied.
Second, you can use an intermediate variable to make code more
readable.  For example:

colour {
    my $self = shift;
    my $attr = $self->{__MYCLASS};
    $attr->{colour} = shift if @_;
    $attr->{colour};
}

For this example, $attr may not be needed.  But if you a method
that needs to access many attributes of the class, it helps.

BTW, to avoid a gotcha, make sure to initialize $self->{__MYCLASS}
during object instantiation as follows:

    $self->{__MYCLASS} = { };


	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Wed, 18 Feb 1998 13:10:38 -0800
From: jacke@hghed.com (JackE)
Subject: suid script newbie question
Message-Id: <jacke-1802981310380001@dnai-207-181-206-1.dialup.dnai.com>

Hi, all - I have a sort-of-newbie question, which I can't seem to find a
really straight answer for in any docs I have seen...

What exactly is a suid script, why is it such a horrendous security hole,
and how can I fix it?  i.e. do I need to rebuild my perl, or what????

Thanks for any responses!


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

Date: 18 Feb 1998 21:05:05 GMT
From: plambert$1@plambert.org
Subject: timing out a socket...
Message-Id: <6cfie1$crt$1@nntp1.ba.best.com>

We have a number of machines whose inetd's stop listening to a particular
port after a while.  I'm writing a script to fix this problem, and running
in to a particular issue.  Specifically, some of our hosts respond to pings
but no connections.  This is a known problem, and is being worked on, but
my script has to handle this somewhat cleanly.

What I need to do is change the timeout for making a connection... it takes
far too long to timeout as it is...

Here's the code:

      $sock = new IO::Socket::INET (
         PeerAddr => $host,
         PeerPort => $port,
         Proto => 'tcp',
         Timeout => 5,
                                   );

This is not working.  No matter what I set the Timeout to, it's a really,
really, really long time before it times out on a machine that isn't
answering on that port, but is otherwise reachable.

What am I doing wrong?  I can't find anything in Advanced Perl or the
FAQs, so I'm turning to y'all.

Thanks!

--Paul L.



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

Date: Wed, 18 Feb 1998 15:57:55 -0600
From: Graham Barr <gbarr@ti.com>
Subject: Re: timing out a socket...
Message-Id: <34EB5963.71FC4AA1@ti.com>

plambert$1@plambert.org wrote:
> Here's the code:
> 
>       $sock = new IO::Socket::INET (
>          PeerAddr => $host,
>          PeerPort => $port,
>          Proto => 'tcp',
>          Timeout => 5,
>                                    );
> 
> This is not working.  No matter what I set the Timeout to, it's a really,
> really, really long time before it times out on a machine that isn't
> answering on that port, but is otherwise reachable.

The problem is probably that you have an old version of IO::Socket,
there was a bug in an old release which used alarm() to timeout
the connection.

The latest version avaliable on CPAN at

http://www.perl.com/CPAN/authors/id/GBARR/

does not use alarm() and should fix your problem.

Graham.

-- 
Originality is the ability to conceal your source.


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

Date: 18 Feb 1998 19:47:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: ts: Remove files in a PERL sript
Message-Id: <6cfdsq$bhf$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, tsatan@hotmail.com writes:
:Wrong. Use the xyzzy unction like this:

Don't tell people answers that are in the manpages or faqs.
Tell there where to find those answers for themselves.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


150 years ago everybody was a Christian Scientist.   --dmr


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

Date: Wed, 18 Feb 1998 11:51:29 -0700
From: Robert Goff <ragoff@sandia.gov>
Subject: Re: Undefined Subroutine in &Module::Package::SubPackage
Message-Id: <34EB2DB1.95DBED6E@sandia.gov>

I got rid of the error message by changing the contstructor call from 

   my $rowref = new NDS::Table::Row(@p);

to 

   my $rowref = NDS::Table::Row->new(@p);

but I still don't understand why.
-- 
=================================================
Robert Goff             email: ragoff@sandia.gov
Sandia National Labs    Phone: (505)284-3639


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

Date: Wed, 18 Feb 1998 14:41:48 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Undefined Subroutine in &Module::Package::SubPackage
Message-Id: <MPG.f55038618646496989700@news.concentric.net>

  [courtesy cc of this posting sent to cited author via email]

ragoff@sandia.gov said...
: Package NDS::Table;
  ^
What's "Package"?  I think you mean "package".

: The error is "Undefined Subroutine &NDS::Table::Row at ..." 

Try putting the NDS::Table:Row package before the NDS::Table package in your 
source file.

-- 
#!/usr/bin/perl -w -- Just another Perl hacker,
 (open 0),$_=<0>,s,.*-+ ,,,chop;for(split?@*?){($$_++or$}=$_,y,
 y \,y,<STDIN>,,eval"sub $_ {print'$}'}"),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg    jdf@pobox.com    Sunny Brooklyn, NY


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

Date: 18 Feb 1998 18:26:31 GMT
From: Mark Hollomon <mhh@nortel.ca>
Subject: Re: Undefined Subroutine in &Module::Package::SubPackage
Message-Id: <6cf94n$312@crchh327.us.nortel.com>

Robert Goff <ragoff@sandia.gov> wrote:
> I'm trying to call methods from one package from a different package in
> the same module, and getting the 'Undefined Subroutine' error.  I can't
> figure out why.  Here's the setup:

> Package NDS::Table;

> sub new {
>    (stuff)
>    return $self;
> }

> sub row {
>    my($self, @p) = @_;
>    my $rowref = new NDS::Table::Row(@p); <- this line generates the

Try

NDS::Table::Row->new(@p)

instead

At the time the line is compiled, a 'new' (NDS::Table::new) is visible.

So this gets parsed as if you had written

NDS::Table::new(NDS::Table::Row(@p))

And of course the 'subroutine' NDS::Table::Row doesn't exist.

The bad part is 'NDS::Table::Row->new(@p)' is not guaranteed to
work, for instance:
Package NDS::Table;

sub new {
   (stuff)
   return $self;
}

sub Row {
	# blah
}

sub row {
   my($self, @p) = @_;

   $rowref = NDS::Table::Row->new(@p);  # line 1
   push(@{$self->{rows}}, $rowref);
}

line 1 will be parsed as

	$rowref = NDS::Table::Row()->new(@p);

The following line is guaranteed to do what you
want, but it is ugly.

$rowref = "NDS::Table::Row"->new(@p);

Have fun.

-----------------
Mark Hollomon
mhh@nortel.com


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

Date: Wed, 18 Feb 1998 22:00:51 +0200
From: Kari Marttila <Kari.Marttila.@tietogroup.com>
Subject: Unlink and rmdir
Message-Id: <34EB3DF3.F7E@tietogroup.com>

Hi

I use perl for system administration. I have a script that deletes
certain directories. I have used unlink to delete every file in that
directory and then rmdir to delete the directory itself. There is one
problem. Every now and then the script "leaves" certain directories
(irregular behaviour: not the same directories every time) without
deleting them. Perl script says that there were no errors, though. If I
try to see whats in those directories, NT 4.0 says: "Access is denied.".
I have to boot the machine and after that I can see that perl script has
deleted all files but the directory is there. After booting the
directory can be deleted manually. I am quite sure, that the reason is
somewhere in perl script, because I know that the directories are not
locked by some other process. I use Perl 5.004_02 in NT 4.0.

Thanks.

*******************************************************
Kari
Marttila                                                                           
TT Tieto / TT Government Services / Networking services 
Internet: Kari.Marttila@tietogroup.com
*******************************************************


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

Date: Wed, 18 Feb 1998 13:40:10 +0000
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: useful citation lines (was Re: Killfile Triage)
Message-Id: <19980218.134010.7Q1.rnr.w164w_-_@locutus.ofB.ORG>

  [ no longer perl-relevant, hasn't been for a while ]

Eli the Bearded <*@qz.to> writes:

> There is the further obstacle of a case like this: person A posts
> a question; person B follows up with the wrong answer; person C
> sees it is wrong and tries to email person A with a correction.
> If person B has edited out the "fix" for the email address,
> person C is helpless.

this occurs even now, with (I think) Netscape Navigator (and others),
which only give the `name' in the citation, not the address.

a citation of ``Chris Jones writes:'' is fairly useless on Usenet.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: 18 Feb 1998 04:25:29 GMT
From: twod@not.valid
Subject: Re: Why do I get this error on SunOS5?
Message-Id: <6cdnrp$nib$1@vnetnews.value.net>

: % perl -e "@in=(1,2); print $in[0];"
: in: Undefined variable

One thought is that double quotes allow the shell to expand variables and
thus the shell and not PERL is trying to evaluate $in. Try single quotes.

: problem. What's wrong with SunOS5?  Thank you.

Users :)

IAP
--
I am using anti-spam measures, please replace 'not.valid' with 'value.net'


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1926
**************************************

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