[23965] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6166 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 19 18:05:50 2004

Date: Thu, 19 Feb 2004 15:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 19 Feb 2004     Volume: 10 Number: 6166

Today's topics:
    Re: Beginner question on @INC <nottateef@netscape.net>
    Re: commandline version of this script. (NNTP)
    Re: commandline version of this script. <usenet@morrow.me.uk>
    Re: compressing data files/directories <nospam@spamfree.dud>
    Re: finding the last match before a first match (regex) <nobull@mail.com>
    Re: Getopt::Long and <> problem (Daniel Berger)
    Re: Listbox and passing entries <jwkenne@attglobal.net>
    Re: Listbox and passing entries <a@b.com>
    Re: Listbox and passing entries <noreply@gunnar.cc>
    Re: method reference - repost <usenet@morrow.me.uk>
    Re: Newbe Unicode question (Scottie)
    Re: Newbe Unicode question <usenet@morrow.me.uk>
    Re: newbie: inheritance (Bill)
    Re: newbie: inheritance <emschwar@pobox.com>
    Re: newbie: inheritance <usenet@morrow.me.uk>
    Re: newbie: inheritance <emschwar@pobox.com>
    Re: newbie: inheritance (Anno Siegel)
    Re: OPEN( , Get , or slurping problem <dha@panix.com>
    Re: OPEN( , Get , or slurping problem <bik.mido@tiscalinet.it>
    Re: perl controlling samba permissions? <usenet@morrow.me.uk>
    Re: PerlSAX <usenet@morrow.me.uk>
        Problem with hashes (cousin_bubba)
    Re: Problem with hashes <usenet@c0s.org>
    Re: Problem with hashes (Anno Siegel)
    Re: TMTOWTDI <xx087@freenet.carleton.ca>
    Re: understanding perl "get ($url) " function (KK)
    Re: Why is Perl losing ground? (G Klinedinst)
    Re: Why is Perl losing ground? <emschwar@pobox.com>
        Win 2K3 & File Locking <paanwa@hotmail.com>
    Re: Win32::Clipboard() and Excel <brian_helterline@hp.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 19 Feb 2004 15:24:42 -0700
From: Nottateef <nottateef@netscape.net>
Subject: Re: Beginner question on @INC
Message-Id: <mFaZb.7971$o52.5407@fed1read02>

Geedunk wrote:
>>Don't do things as the superuser unless those things *require*
>>that you be the superuser.
>>
>>Posting/reading Usenet does not require that you be the superuser.
>>
>>And when you _are_ being the superuser, be afraid, you can
>>do serious damage. Do what you gotta do, and switch back to
>>a regular user account as soon as possible.
> 
> 
> I don't understand what you are talking about.  I am on as a standard
> user, not as root.  (I'm not quite that newbie:-)   Besides, how would you
> know how I am logged in - is my setup THAT transparent to everybody???!!!
> 
> Geedunk  

Depends, the perl that is in your path (echo $PATH in a terminal window 
to see) is in a location that you would need to be the superuser to 
install it, /usr/bin/perl in RH9.  Last one that I compiled and 
installed myself went into /usr/local somewhere.  Backup old 
/usr/bin/perl and copy new one there to avoid changing your $PATH 
(.bashrc is one place to change it)

Nottateef

aka phil681@yahoo.com etc



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

Date: 19 Feb 2004 13:37:26 -0800
From: news8080@yahoo.com (NNTP)
Subject: Re: commandline version of this script.
Message-Id: <110fc16.0402191337.3067a5d0@posting.google.com>

This script does work but what I am trying to do is call it from
another script and I don't want to have 2 scripts if I can just
replace this script with a command like Ben suggested,

perl -MValidate::Net -le'print \!Validate::Net->ip(shift) && "in",
"valid"'
doesn't work

sh-2.05a# ./validateip.pl 1.1.1.1
valid
sh-2.05a# ./validateip.pl 1.1.1.1asdfdasf
invalid
sh-2.05a# cat validateip.pl
#!/usr/bin/perl
use Validate::Net;
if ( Validate::Net->ip($ARGV[0]))
{
print "valid
";
exit 0;
}
print "invalid
";
sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.1.1)
&& "in", "valid"'
invalid
sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.11.)
&& "in", "valid"'
syntax error at -e line 1, near ".) "
Execution of -e aborted due to compilation errors.
sh-2.05a# perl -MValidate::Net -le'print
\!Validate::Net->ip(1.1.1.1asdfdasf) && "in", "valid"'
Bareword found where operator expected at -e line 1, near
"1.1.1.1asdfdasf"
        (Missing operator before asdfdasf?)
syntax error at -e line 1, near "1.1.1.1asdfdasf"
Execution of -e aborted due to compilation errors.




Ben Morrow <usenet@morrow.me.uk> wrote in message news:<c10dev$a0u$9@wisteria.csv.warwick.ac.uk>...
> news8080@yahoo.com (NNTP) wrote:
> > #!/usr/bin/perl
> > use Validate::Net;
> > if ( Validate::Net->ip($ARGV[0]))
> > {
> > print "valid";
> > exit 0;
> > }
> > print "invalid";
> > #--done
> > 
> > is it even doable?
> 
> err... (untested)
> 
> perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
> 
> Ben


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

Date: Thu, 19 Feb 2004 21:52:59 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: commandline version of this script.
Message-Id: <c13b7r$aiv$1@wisteria.csv.warwick.ac.uk>

[don't top-post]
[wrap your posts at 72 chars or so]

news8080@yahoo.com (NNTP) wrote:
> Ben Morrow <usenet@morrow.me.uk> wrote in message
> news:<c10dev$a0u$9@wisteria.csv.warwick.ac.uk>...
> > news8080@yahoo.com (NNTP) wrote:
> > >
> > > #!/usr/bin/perl
> > > use Validate::Net;
> > > if ( Validate::Net->ip($ARGV[0]))
> > > {
> > > print "valid";
> > > exit 0;
> > > }
> > > print "invalid";
> > > #--done
> > > 
> > > is it even doable?
> > 
> > err... (untested)
> > 
> > perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
>  
> perl -MValidate::Net -le'print \!Validate::Net->ip(shift) && "in",
> "valid"'
> doesn't work
> 
> sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.1.1)
> && "in", "valid"'
> invalid
> sh-2.05a# perl -MValidate::Net -le'print \!Validate::Net->ip(1.1.11.)
> && "in", "valid"'
> syntax error at -e line 1, near ".) "
> Execution of -e aborted due to compilation errors.
> sh-2.05a# perl -MValidate::Net -le'print
> \!Validate::Net->ip(1.1.1.1asdfdasf) && "in", "valid"'
> Bareword found where operator expected at -e line 1, near
> "1.1.1.1asdfdasf"
>         (Missing operator before asdfdasf?)
> syntax error at -e line 1, near "1.1.1.1asdfdasf"
> Execution of -e aborted due to compilation errors.

Try using it right:

~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.1.1") 
    && "in", "valid"'
valid
~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.1.1adad") 
    && "in", "valid"'
invalid
~% perl -MValidate::Net -le'print !Validate::Net->ip("1.1.11.") 
    && "in", "valid"'
invalid

or, better,

#!/bin/sh

VALID_IP=$(<<CMD
perl -MValidate::Net -le'print !Validate::Net->ip(shift) && "in", "valid"'
CMD
)

eval $VALID_IP 1.1.1.1
eval $VALID_IP 1.1.11.
eval $VALID_IP 1.1.1.1adsf

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else *  ben@morrow.me.uk


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

Date: Thu, 19 Feb 2004 21:11:52 GMT
From: Sean O'Dwyer <nospam@spamfree.dud>
Subject: Re: compressing data files/directories
Message-Id: <nospam-2F3904.16183219022004@nyctyp02-ge0.rdc-nyc.rr.com>

In article <c11dcr$sna$2@wisteria.csv.warwick.ac.uk>,
 Ben Morrow <usenet@morrow.me.uk> wrote:

> Compress::Zlib, Archive::Tar, maybe Archive::Zip.

Thank you!

Sean


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

Date: 19 Feb 2004 19:06:08 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: finding the last match before a first match (regex)
Message-Id: <u9znbedh3z.fsf@wcl-l.bham.ac.uk>

That well know clown Brian McCauley <nobull@mail.com> writes:

> Don't put qualifiers on m// that you don't understand.

Advice he'd do well to follow himself :-)

> $_ = 'abcdefgabcde-FIRST-fooabcdefg-SECOND-foo';
> /foo/gc or die "no foo";
> /.*(a.*)\G/ or die "no a before first foo";
> print "$1\n";

The /c above does nothing.

$_ = 'abcdefgabcde-FIRST-fooabcdefg-SECOND-foo';
/foo/g or die "no foo";
/.*(a.*)\G/ or die "no a before first foo";
print "$1\n";

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 19 Feb 2004 11:54:50 -0800
From: djberg96@hotmail.com (Daniel Berger)
Subject: Re: Getopt::Long and <> problem
Message-Id: <6e613a32.0402191154.562608d9@posting.google.com>

ko <kuujinbo@hotmail.com> wrote in message news:<c11um4$m0o$1@pin3.tky.plala.or.jp>...
> Daniel Berger wrote:
> 
> > Hi all,
> > 
> > Perl 5.8.3
> > Solaris 9
> > 
> > I'm trying to use the <> operator in Getopt::Long to call a sub when
> > an unknown option occurs.  However, it doesn't seem to work.  I read
> > the docs, found a few online examples, but nothing that would indicate
> > why this would fail.  It's probably something obvious but I don't see
> > it.
> > 
> > Help appreciated.
> > 
> > Regards,
> > 
> > Dan
> > 
> > # getopttest.pl
> > use strict;
> > use Getopt::Long;
> > 
> > $Getopt::Long::debug = 9;
> > #Getopt::Long::config qw(permute); # tried both
> ---------------------------------------^^^^^^^^^^
> Probably won't make a difference. 'permute' is usually enabled by 
> default. You want the 'pass_through' configuration option:
> 
> #!/usr/bin/perl
> # test.pl
> use strict;
> use warnings;
> use Getopt::Long;
> Getopt::Long::config qw[pass_through];
> my($qt_dir, $CC);
> 
> sub foo {
>    print $_[0] =~ /^--/
>      ? "unknown option: $_[0]\n"
>      : "unknown value: $_[0]\n";
> }
> 
> GetOptions(
>     "--with-qt=s"  => \$qt_dir,
>     "--with-gcc=s" => \$CC,
>     '<>' => \&foo
> );
> __END__

<snip>

> 
> HTH - keith

That does the trick.  Thanks much!

Regards,

Dan


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

Date: Thu, 19 Feb 2004 21:02:44 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Listbox and passing entries
Message-Id: <Uv9Zb.4071$ya.1636783@news4.srv.hcvlny.cv.net>

Alan J. Flavell wrote:
> On Thu, 19 Feb 2004, David H. Adler wrote:
> 
> 
>>A lack of CGI.pm also makes me question just how old a perl distribution
>>his host has installed...
> 
> 
> Possibly so; but I've heard of a number of cases where web service
> providers have deliberately removed components from an otherwise
> fairly recent Perl installation - for whatever inscrutable reason they
> might have had.
> 
> Without wanting to re-open old arguments, one _does_ have to wonder at
> the thought processes of a provider who allows their customers access
> to CGI facilities from Perl, but denies them the use of CGI.pm.

Tripod (Lycos) gives you:
   Perl 5.8.0
   $Id: CGI.pm,v 2.30 1997/1/01 12:12 lstein Exp $
   a few CGI-related modules of their own creation,
and _nothing_ else.  Not even pragmas.

(And there are too many pieces of paper out in the wild with our old 
http://....tripod.com URL to consider changing suppliers for at least a 
year.)

-- 
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
   -- Charles Williams.  "Judgement at Chelmsford"


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

Date: Thu, 19 Feb 2004 21:42:03 GMT
From: "Old School" <a@b.com>
Subject: Re: Listbox and passing entries
Message-Id: <L4aZb.4482$J84.4128@fe1.texas.rr.com>

> It's not possible to tell what mistake you made out from the code
> fragments you posted. You'd better post a *minimal* but *complete*
> script and ditto form that people can copy, paste and run. If you do
> so, the script should be written with strictures and warnings enabled,
> so that you don't unnecessarily bother the group with trivial errors
> that Perl could have let you know about.
>
> But your biggest mistake seems to be that you are staying with that
> hosting company.
>
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

The new hosting statements are givens.  I understand that the functionality
is limited, but I can't switch right now.
I'm not that happy that my hosting company doesn't have this module, but I
am working with what I have.  The SplitParam sub does the same thing as
param(), however, you may need to run the input through ReadParse, before
proccessing with SplitParam.  The script is much too large to post here, but
the idea behind what I want to do is:

1.  collect data from a multiple item listbox (created within an html form
via print EOF)
2.  strip out the \0s and assign to list array elements
3.  be able to print out the elements

In PHP, you can denote the listbox variable as variable[ ] and it will put
the data in an array.  Does Perl have anything like this?

Thanks for any help provided.






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

Date: Thu, 19 Feb 2004 23:02:35 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Listbox and passing entries
Message-Id: <c13boc$1dt59q$1@ID-184292.news.uni-berlin.de>

Old School wrote:
> Gunnar Hjalmarsson wrote:
>> It's not possible to tell what mistake you made out from the code
>> fragments you posted. You'd better post a *minimal* but
>> *complete* script and ditto form that people can copy, paste and
>> run. If you do so, the script should be written with strictures
>> and warnings enabled, so that you don't unnecessarily bother the
>> group with trivial errors that Perl could have let you know
>> about.
> 
> The SplitParam sub does the same thing as param(),

The *same* thing? Not even close.

     @lchar = SplitParam($form{LCHAR});

does nothing but

     @lchar = split /\0/, $form{LCHAR};

so it's basically redundant (IMO).

> however, you may need to run the input through ReadParse, before 
> proccessing with SplitParam.

Yes, ReadParse() is the main function in cgi-lib.pl.

> The script is much too large to post here, but the idea behind what
> I want to do is:
> 
> 1.  collect data from a multiple item listbox (created within an
> html form via print EOF)
> 2.  strip out the \0s and assign to list array elements
> 3.  be able to print out the elements

What you are trying to do is perfectly clear to me, but obviously you
are making a mistake, since it should work AFAICT. When asking you to
post a *minimal* script I meant that you should write a script for the
sole purpose of illustrating the problem. If you don't, I'm afraid
that nobody can help you.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 19 Feb 2004 19:13:07 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: method reference - repost
Message-Id: <c131s3$3po$2@wisteria.csv.warwick.ac.uk>


Uri Guttman <uri@stemsystems.com> wrote:
> >>>>> "BM" == Ben Morrow <usenet@morrow.me.uk> writes:
> 
>   BM> Uri Guttman <uri@stemsystems.com> wrote:
> 
>   NS> how could it be called without creating the intermediate $m ?
>   >> 
>   >> can't be done. it has nothing to do with how you get the dynamic
>   >> method. the method slot of a call must be a single scalar variable or
>   >> bareword. it can't be an expression.
> 
>   BM> Howsabout (not exactly clear, but...:)
>   BM>     $obj->can($obj->{lst}[0])->($obj, 20);
>   BM> ?
> 
> that isn't selecting the method but getting back a code ref. not the
> same thing. and i am not even sure that will be a method call there
> since there is no method being used in the final call.

What difference does it make? I thought that $obj->meth(@args) was
equivalent to Class::meth($obj, @args) once the method lookup has been
done (which is what can() does). Am I wrong?

(If I am wrong then yes, clearly that is a sub rather than a method
call...)

Ben

-- 
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else *  ben@morrow.me.uk


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

Date: 19 Feb 2004 11:22:21 -0800
From: Scott_Starker@sil.org (Scottie)
Subject: Re: Newbe Unicode question
Message-Id: <899d28b2.0402191122.6746acc5@posting.google.com>

Ben,

> > In the zapotec.pl I have:
> >     binmode(STDOUT, ":utf8");
> >     binmode(STDIN, ":utf8");
> >     use encoding "latin2";
> 
> Why? Is your source in latin2?

I'm sorry. The 3rd line is:
      use encoding "latin1";
 
> Err... what does yor script do, and in what ways is in not working?

I started with GAWK and used a2p to change it to Perl. I think I know
that the @Fld line isn't allowing it to be Unicode. I have hunted
through the Perl docs concerning my problem and I haven't come up with
an answer. What do you think?

# Perl - a2p - Combines many changes to the Zapotec-Spanish
dictionary.
# Scott Starker

binmode(STDOUT, ":utf8");
binmode(STDIN, ":utf8");
use encoding "latin1";

# ${^WIDE_SYSTEM_CALLS} = 1;
$[ = 1;			        # set array base to 1
$, = " ";			# set output field separator
$\ = "\n";			# set output record separator

$AlreadyGN = 0;
$notes = 0;
$gnsgnFirstLine = 0;
$anyline = 0;
$position = 0;
$lxline = '';
$mldef = '';
$seline = '';
$line = '';
$beg = '';
$end = '';

# This program takes out the "lx"'s that are alone on the line ("\k").
while (<>) {
    chomp;									# strip record separator
    @Fld = split("\x{0020}", $_, 9999);				# " "
print "\x{002a}";
#     if ($Fld[1] eq " \\ l x") {
#     if ($Fld[1] eq "\x{005c}\x{006c}\x{0078}") {		# "\\lx"
     if ($Fld[1] eq "\x{005c}\x{005c}\x{006c}\x{0078}") {	# "\\lx"
print "\x{002a}\x{002a}";
	$s = "\x{002d}", s/$s/\^\x{007e}/g;				# "-"
# Make "tone" un-bolded
	$Fld[2] = "\x{007c}\x{0062}" . $Fld[2];			# "\x{007c}\x{0062}"
	s/\x{005b}/\x{007c}\x{0072}\x{005b}/g;			# If "[" or "," exist
	s/\x{005d}/\x{005d}\x{007c}\x{0062}/g;
	s/\x{005d}\x{007c}\x{0062}\x{00b8}\x{0020}/\x{005d}\x{00b8}\x{0020}\x{007c}\x{0062}/g;
	$Fld[$#Fld] = $Fld[$#Fld] . "\x{007c}\x{0072}";
	$position = index($Fld[$#Fld], "\x{005d}");
	$lxline = $_;
 .
 .
 .

Scott


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

Date: Thu, 19 Feb 2004 20:52:45 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Newbe Unicode question
Message-Id: <c137mt$8df$1@wisteria.csv.warwick.ac.uk>


Scott_Starker@sil.org (Scottie) wrote:
> Ben,
> 
> > > In the zapotec.pl I have:
> > >     binmode(STDOUT, ":utf8");
> > >     binmode(STDIN, ":utf8");
> > >     use encoding "latin2";
> > 
> > Why? Is your source in latin2?
> 
> I'm sorry. The 3rd line is:
>       use encoding "latin1";
>  
> > Err... what does yor script do, and in what ways is in not working?
> 
> I started with GAWK and used a2p to change it to Perl. I think I know
> that the @Fld line isn't allowing it to be Unicode. I have hunted
> through the Perl docs concerning my problem and I haven't come up with
> an answer. What do you think?
> 
> # Perl - a2p - Combines many changes to the Zapotec-Spanish
> dictionary.
> # Scott Starker
> 
> binmode(STDOUT, ":utf8");
> binmode(STDIN, ":utf8");
> use encoding "latin1";

This is unnecessary because al latin1 is the default anyway and b. your
source is all ascii.

> # ${^WIDE_SYSTEM_CALLS} = 1;
> $[ = 1;			        # set array base to 1

Aaarg... run away... $[ is highly deprecated and double-plus-ungood.
Yes, I know it's not your code :).

> $, = " ";			# set output field separator
> $\ = "\n";			# set output record separator
> 
> $AlreadyGN = 0;
> $notes = 0;
> $gnsgnFirstLine = 0;
> $anyline = 0;
> $position = 0;
> $lxline = '';
> $mldef = '';
> $seline = '';
> $line = '';
> $beg = '';
> $end = '';
> 
> # This program takes out the "lx"'s that are alone on the line ("\k").
> while (<>) {
>     chomp;									# strip record separator
>     @Fld = split("\x{0020}", $_, 9999);				# " "
> print "\x{002a}";
> #     if ($Fld[1] eq " \\ l x") {
> #     if ($Fld[1] eq "\x{005c}\x{006c}\x{0078}") {		# "\\lx"
>      if ($Fld[1] eq "\x{005c}\x{005c}\x{006c}\x{0078}") {	# "\\lx"
> print "\x{002a}\x{002a}";
> 	$s = "\x{002d}", s/$s/\^\x{007e}/g;				# "-"
> # Make "tone" un-bolded
> 	$Fld[2] = "\x{007c}\x{0062}" . $Fld[2];			# "\x{007c}\x{0062}"
> 	s/\x{005b}/\x{007c}\x{0072}\x{005b}/g;			# If "[" or "," exist
> 	s/\x{005d}/\x{005d}\x{007c}\x{0062}/g;
> 	s/\x{005d}\x{007c}\x{0062}\x{00b8}\x{0020}/\x{005d}\x{00b8}\x{0020}\x{007c}\x{0062}/g;
> 	$Fld[$#Fld] = $Fld[$#Fld] . "\x{007c}\x{0072}";
> 	$position = index($Fld[$#Fld], "\x{005d}");
> 	$lxline = $_;

Right, let's attempt to translate that into Perl... (untested)

#!/usr/bin/perl

use strict;
use warnings;

$, = " ";
$\ = "\n";

binmode STDIN,  ':encoding(utf8)';
binmode STDOUT, ':encoding(utf8)';
# this is better as you get fallback if the input is invalid

my $ced = "\xb8";

while (<>) {
    chomp;
    my ($a, $b, $c) = split " ";
    if ($a eq '\\\lx') {          # this comes out as two \
        print '**';
        s/-/^~/g;
        $b = "|b$b";
        s/\[/|r[/g;
        s/]/]|b/g;
        s/]\|b$ced ]/]$ced |b/g;

 ...etc. (Bog, that code's making my eyes hurt!) You can carry on, and
finish it (what you posted wasn't complete, right?).

Now, I can't really see what this is supposed to do, so what do you want
it to do, and what is it in fact doing?

Ben

-- 
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t    # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.


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

Date: 19 Feb 2004 13:05:50 -0800
From: wherrera@lynxview.com (Bill)
Subject: Re: newbie: inheritance
Message-Id: <239ce42f.0402191305.4dbab89a@posting.google.com>

merlyn@stonehenge.com (Randal L. Schwartz) wrote in message news:<0030f2dfcb1fd1b51792e9c506a624a3@news.teranews.com>...
> >>>>> "Andrew" == Andrew V Tkachenko <pobugfix@peterlink.ru> writes:
> 
> Andrew>      my $proto = shift;
> Andrew>      my $class = ref($proto) || $proto;
> 
> Please don't do this.

Why do they still put it in the docs (perltoot) anyway?


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

Date: Thu, 19 Feb 2004 14:32:56 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: newbie: inheritance
Message-Id: <etoptcadabb.fsf@fc.hp.com>

wherrera@lynxview.com (Bill) writes:
> merlyn@stonehenge.com (Randal L. Schwartz) wrote in message news:<0030f2dfcb1fd1b51792e9c506a624a3@news.teranews.com>...
>> >>>>> "Andrew" == Andrew V Tkachenko <pobugfix@peterlink.ru> writes:
>> 
>> Andrew>      my $proto = shift;
>> Andrew>      my $class = ref($proto) || $proto;
>> 
>> Please don't do this.
>
> Why do they still put it in the docs (perltoot) anyway?

Okay, I'll bite.  I hardly write any OO perl these days (I find ruby
does the trick for me, when I need OO-ness), but the article Randal
referred to says little more than his comment, basically "don't do
this".  Why not?

I agree that it's easy enough to work around, thanks to Randal's
article explaining how, but I don't see what's wrong with the above
code.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 19 Feb 2004 21:38:33 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: newbie: inheritance
Message-Id: <c13acp$9q4$1@wisteria.csv.warwick.ac.uk>


Eric Schwartz <emschwar@pobox.com> wrote:
> wherrera@lynxview.com (Bill) writes:
> > merlyn@stonehenge.com (Randal L. Schwartz) wrote in message
> > news:<0030f2dfcb1fd1b51792e9c506a624a3@news.teranews.com>...
> >> >>>>> "Andrew" == Andrew V Tkachenko <pobugfix@peterlink.ru> writes:
> >> 
> >> Andrew>      my $proto = shift;
> >> Andrew>      my $class = ref($proto) || $proto;
> >> 
> >> Please don't do this.
> >
> > Why do they still put it in the docs (perltoot) anyway?
> 
> Okay, I'll bite.  I hardly write any OO perl these days (I find ruby
> does the trick for me, when I need OO-ness), but the article Randal
> referred to says little more than his comment, basically "don't do
> this".  Why not?
> 
> I agree that it's easy enough to work around, thanks to Randal's
> article explaining how, but I don't see what's wrong with the above
> code.

Randal's argument is that the semantics of $obj->new are unclear: does
this copy the object, or create a new clean one? Given that, the former
should be handled with a ->clone instance method, and the latter with
(ref $obj)->new, neither of which is ambiguous.

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'


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

Date: Thu, 19 Feb 2004 14:47:20 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: newbie: inheritance
Message-Id: <etoisi2d9nb.fsf@fc.hp.com>

Ben Morrow <usenet@morrow.me.uk> writes:
> Randal's argument is that the semantics of $obj->new are unclear: does
> this copy the object, or create a new clean one? Given that, the former
> should be handled with a ->clone instance method, and the latter with
> (ref $obj)->new, neither of which is ambiguous.

That makes perfect sense, thanks.  I agree completely now that you've
explained it that way.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 19 Feb 2004 22:36:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: newbie: inheritance
Message-Id: <c13dot$85m$1@mamenchi.zrz.TU-Berlin.DE>

Eric Schwartz  <emschwar@pobox.com> wrote in comp.lang.perl.misc:
> Ben Morrow <usenet@morrow.me.uk> writes:
> > Randal's argument is that the semantics of $obj->new are unclear: does
> > this copy the object, or create a new clean one? Given that, the former
> > should be handled with a ->clone instance method, and the latter with
> > (ref $obj)->new, neither of which is ambiguous.
> 
> That makes perfect sense, thanks.  I agree completely now that you've
> explained it that way.

If god had intended "new" to work this way, "bless" would accept an object
as its second parameter and bless into its class.

Anno


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

Date: Thu, 19 Feb 2004 19:42:52 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <slrnc3a4ds.leo.dha@panix2.panix.com>

In article <c10ud1$1dgan2$1@ID-184292.news.uni-berlin.de>, Gunnar
Hjalmarsson wrote:
> David H. Adler wrote:
>> In article <c0vtj9$1cqoqv$1@ID-184292.news.uni-berlin.de>, Gunnar
>> Hjalmarsson wrote:
>> 
>>>Yeah, I do know that Perl == CGI returns false (or doesn't
>>>compile...). ;-)
>> 
>> Ahem.
>> 
>> ~ 18:13:43% perl -e 'print "yikes!\n" if Perl == CGI';
>> yikes!
>> 
>> eq, however, is a different matter entirely... :-)
> 
> Ouch! What can I say.. Maybe: You should have enabled strictures! ;-)
 
But that wouldn't be any fun. :-)

(for those of you wondering why this happens, it's because perl treats
all strings containing no digits the same way in numeric context
(iirc)).

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"I'll keep him as an insurance policy, since, unfortunately, I can't
kill him twice." - Scaroth


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

Date: Thu, 19 Feb 2004 21:35:03 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <d66a30592gfu1c0954r9qjm9clhic2tftk@4ax.com>

On Wed, 18 Feb 2004 15:28:53 +0100, Gunnar Hjalmarsson
<noreply@gunnar.cc> wrote:

>>> does not make a difference, and I don't get any meaningful error
>>> message. (Only "Premature end of script headers".)
>> 
>> Well, it's evident even from your .sig that you "have to do" with
>> CGI et similia.
>
>Guilty as charged.
[snip]
>Well, I'm on a W98 box, and not very fond of the MS-DOS window. Maybe
>the truth is that I have never bothered to learn how to configure
>and/or use it properly.

AFAIK, sad as it can be, there's not much to configure and/or "use
properly". But as far as I'm concerned I'm keen on cmd line UI's,
whatever they are! I've been grown up on good 'ol MS-DOS, oh! those
days when it was natural for me to think that nothing could prevent a
priori anything with a M$ in it to be any good ;-)... I've used both
the standard shell and enhanced ones like 4dos... of course
discovering real shells under Linux was so breathtaking!! Still using
DOS prompt under W98 et similia here, though...

>Not sure if those reasons are good enough. :)

Well you didn't need to justify yourself, I was just being curious!


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Thu, 19 Feb 2004 19:20:22 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl controlling samba permissions?
Message-Id: <c1329m$3po$4@wisteria.csv.warwick.ac.uk>


usenet@outshine.com (Anthony Boyd) wrote:
> I have a Linux box that is going to share a directory via Samba. 
> People will be authorized to use the share via LDAP.  They may change
> the file permissions (on the Samba/Windows side, but the Linux
> permissions should remain unchanged).
> 
> I wanted to have a PHP script read the Samba permissions set on each
> file, and display that via a Web page.  PHP doesn't appear up to the
> task (but it can get/set Linux permissions OK).
> 
> Can Perl handle this?  I thought Filesys::SmbClient might work, but
> the docs imply Linux permissions can be changed, not the Windows side.

I don't think the two sets of permissions are distinct...

Ben

-- 
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t    # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.


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

Date: Thu, 19 Feb 2004 19:19:25 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: PerlSAX
Message-Id: <c1327t$3po$3@wisteria.csv.warwick.ac.uk>


ihatespam@hotmail.com wrote:
> I'm relatively new at the XML parsing stuff, but I've been reading 
> O'Reilly's XML & Perl and I noticed that the SAX parsers use handles for 
> special events like start tag and character data.  What would you do if you 
> wanted to capture the character data into a variable depending on what the 
> start tag is?

In your start-tag function, you set an attribute of your statte object
saying where the cdata should go. Then in the cdata function, you put it
there.

Ben

-- 
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die.  |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|  ben@morrow.me.uk


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

Date: 19 Feb 2004 14:34:00 -0800
From: cousin_bubba@hotmail.com (cousin_bubba)
Subject: Problem with hashes
Message-Id: <cf64e035.0402191434.55111f8e@posting.google.com>

I have a script that contains several hashes.  I need to retrieve
information from only one of the hashes depending on what argument the
user passes to the script.    To access the values in the hashes I
would like to do the following:

@{$line_xx_section{$variable}

in this case the hash name is $line_xx_section and the "xx" part is
the argument passed by the user.  I tried
@{$line_$ARGV[0]_section{$variable}} but it won't run.  Any idea how I
can make this work.

Thanks for your help and putting up with my newbie problems.


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

Date: Thu, 19 Feb 2004 14:39:29 -0800
From: gabe anzelini <usenet@c0s.org>
Subject: Re: Problem with hashes
Message-Id: <86ad3ewv6m.fsf@tyler.c0s.org>

cousin_bubba@hotmail.com (cousin_bubba) writes:

> I have a script that contains several hashes.  I need to retrieve
> information from only one of the hashes depending on what argument the
> user passes to the script.    To access the values in the hashes I
> would like to do the following:
>
> @{$line_xx_section{$variable}
>
> in this case the hash name is $line_xx_section and the "xx" part is
> the argument passed by the user.  I tried
> @{$line_$ARGV[0]_section{$variable}} but it won't run.  Any idea how I
> can make this work.
>
> Thanks for your help and putting up with my newbie problems.


as with everything in perl there are many ways to do this, i believe
the most accepted way is to make $line_secion a hash of hashes that you ref
like:

${$line_section{$ARGV[0]}}{$variable}

with some defined error checking a crap in there oc

----
gabe


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

Date: 19 Feb 2004 22:52:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem with hashes
Message-Id: <c13enr$85m$2@mamenchi.zrz.TU-Berlin.DE>

cousin_bubba <cousin_bubba@hotmail.com> wrote in comp.lang.perl.misc:
> I have a script that contains several hashes.  I need to retrieve
> information from only one of the hashes depending on what argument the
> user passes to the script.

Then use a hash of hashes (HOH).  As keys of the outer hash use the possible
user inputs, the structure of the inner hashes stays what it is now.

>                                  To access the values in the hashes I
> would like to do the following:
> 
> @{$line_xx_section{$variable}

Huh?

> in this case the hash name is $line_xx_section and the "xx" part is
> the argument passed by the user.  I tried
> @{$line_$ARGV[0]_section{$variable}} but it won't run.  Any idea how I
> can make this work.

That's a futile attempt at symbolic references.  Don't go that way.
With a HOH, you access the selected hash through

    my $current_subhash = $hoh{ $ARGV[ 0]};

Anno


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

Date: 19 Feb 2004 20:15:21 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: TMTOWTDI
Message-Id: <slrnc3a6aq.dm5.xx087@smeagol.ncf.ca>

fifo <fifo@despammed.com> wrote:
>  At 2004-02-19 17:02 +0000, Graham Gough wrote:
> > I have been trying to solve a problem in which I wish to substitute
> > for *almost* all occurrences of a regular expression. For example all
> > occurrences of \d\d\d\d except some specific ones. I ended up with
[...]
>  
>  How about
>  
>    $text =~ s/(?!1234)(\d{4})/XX$1XX/g;

Depending on the OP's data, may have undesired matches, for example, if
$text="12345"

Perhaps, if the OP only cares about 4 digit numbers, and suppose he
doesnt want to match 1234 or 6789 or 4242:
    $text =~ s/(^|\D)(?!1234|6789|4242)(\d{4})(\D|$)/$1<<$2>>$3/g;

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: 19 Feb 2004 12:39:29 -0800
From: kewlkarun@yahoo.com (KK)
Subject: Re: understanding perl "get ($url) " function
Message-Id: <c8fd5039.0402191239.19fa7409@posting.google.com>

Uri Guttman <uri@stemsystems.com> wrote in message news:<x7r7wrr7x8.fsf@mail.sysarch.com>...
> >>>>> "K" == KK  <kewlkarun@yahoo.com> writes:
> 
> <don't top post. read the group guidelines which are posted regularly>
> 
>   K> I did not have to try mechanize. Useragent did the job for me. 
> 
> it will still save you much coding. but what do i care about saving you
> work?
> 
> uri

Hi Uri, I did not mean to turn down your suggestion. Just that it was
a bit late I came accross your suggestion, when, by that time I could
get my job done with Useragent. I am/was pressed for time. regards,
-KK


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

Date: 19 Feb 2004 11:38:12 -0800
From: g_klinedinst@hotmail.com (G Klinedinst)
Subject: Re: Why is Perl losing ground?
Message-Id: <168f035a.0402191138.88bb0a2@posting.google.com>

Sherm Pendley <spamtrap@dot-app.org> wrote in message news:

> $_ : $ARG
> $? : $CHILD_ERROR
> $! : $OS_ERROR
> $@ : $EVAL_ERROR
> $$ : $PROCESS_ID or $PID
> $| : $OUTPUT_AUTOFLUSH
> 
> sherm--

Thanks Sherm. That looks interesting, I will read up on it. 

-Greg


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

Date: Thu, 19 Feb 2004 13:29:19 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Why is Perl losing ground?
Message-Id: <etowu6idd9c.fsf@fc.hp.com>

g_klinedinst@hotmail.com (G Klinedinst) writes:
> Sherm Pendley <spamtrap@dot-app.org> wrote in message news:

<stuff about 'use English'>

> Thanks Sherm. That looks interesting, I will read up on it. 

Just be aware that hardly anyone uses those in practise, and it will
make your programs more difficult to maintain in the future (as an
otherwise experienced Perl programmer will hunt around forever to see
where the #($*&! $PID is defined, etc.).  If you read the Camel book,
it has some mnemonics for the special variables, such as '$<' is where
you're coming FROM, '$>' is where you're going TO, and so on.

Learning the API will do you more good than learning 'use English;' in
the long run, I believe.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 19 Feb 2004 14:18:44 -0500
From: "Paanwa" <paanwa@hotmail.com>
Subject: Win 2K3 & File Locking
Message-Id: <40350c15$0$49485$a04e5680@nnrp.fuse.net>

Anyone aware of file locking issues specific to Perl on Windows 2003 server?




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

Date: Thu, 19 Feb 2004 12:36:23 -0800
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: Win32::Clipboard() and Excel
Message-Id: <40351e4c$1@usenet01.boi.hp.com>


"Mike Flannigan" <mikeflan@earthlink.net> wrote in message
news:4034173A.F22C98FF@earthlink.net...
>
> I'm trying to use Win32::Clipboard() to get data from the
> clipboard.  The text I am copying to the clipboard is in
> an Excel file.  Here is the code I use:
>
> $clip = Win32::Clipboard();
> $text = $clip->Get();
>
> It works fine if I swipe the formula bar in Excel, hit
> ctrl C, and then run the program.  But if I just highlight
> the cell I want and hit ctrl C, and then run the Perl
> script I get a bunch of garbage like this:
>
>       6   (   ²                              ø  à  
> ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ
>

If you want text, specify it:
$text = $clip->GetText();

according to the docs,

Get()

Returns the clipboard content; note that the result depends on the nature of
clipboard data; to ensure that you get only the desired format, you should
use GetText(), GetBitmap() or GetFiles() instead. Get() is in fact
implemented as:
        if(    IsBitmap() ) { return GetBitmap(); }
        elsif( IsFiles()  ) { return GetFiles();  }
        else                { return GetText();   }


and if you had tried $clip->IsBitmap(), you would have seen that it returned
true
so it treated the Excel cell information as a bitmap.

-brian




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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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