[17432] in Perl-Users-Digest
Perl-Users Digest, Issue: 4852 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 9 06:05:38 2000
Date: Thu, 9 Nov 2000 03:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973767911-v9-i4852@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 9 Nov 2000 Volume: 9 Number: 4852
Today's topics:
Re: Detecting socket closure (Charles DeRykus)
Re: Emailing formatted <abaltd@ntlworld.com>
Hash assignments in loops? gelshocker@my-deja.com
Re: Hash assignments in loops? <mahnke@fliegen-ist-schoener.de>
Re: Hash assignments in loops? <tward10@jaguar.com>
Re: Hash assignments in loops? (Bernard El-Hagin)
Re: Help -- msgget with key >= 0x80000000 fails <geoff-at-farmline-dot-com@127.0.0.1>
Re: Help -- msgget with key >= 0x80000000 fails <geoff-at-farmline-dot-com@127.0.0.1>
Re: Help -- msgget with key >= 0x80000000 fails (Martien Verbruggen)
Re: Help with HTML::Parser module <bart.lateur@skynet.be>
Re: NT4 - How do I display the current userid? <philipg@atl.mediaone.net>
Re: NT4 - How do I display the current userid? (CDM)
Re: OOP and information hiding (Damian Conway)
Re: OOP and information hiding (Abigail)
Re: OOP and information hiding <bart.lateur@skynet.be>
Re: Passing args as references vivek@cse.iitd.ernet.in
Re: percent-underscore: %_ <eli@there-is-no-more-qzto.com>
Re: percent-underscore: %_ (Ilya Zakharevich)
Re: Perl on Win32 - System Call error numbers (CDM)
Re: Problem with Inline C <eli@there-is-no-more-qzto.com>
Re: Pushing a hash on to a stack... (Christopher Burke)
Re: Pushing a hash on to a stack... (Martien Verbruggen)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 9 Nov 2000 03:08:23 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Detecting socket closure
Message-Id: <G3qM1z.9DB@news.boeing.com>
In article <3A0992BC.2781@wecan.com>, Fulko Hew <fulko@wecan.com> wrote:
>Charles DeRykus wrote:
>>
>> In article <G3oo13.1u0@news.boeing.com>,
>> Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>> Actually, after checking DejaNews, I suspect you were
>> correct in installing a SIGPIPE handler but something
>> more like this would be a better IMO:
>>
>> { local $SIG{PIPE} = 'IGNORE';
>> defined( send(...) ) || die "send $host: $!";
>> }
>>
>> Unless I missed the boat, that'll prevent the SIGPIPE from
>> terminating your program and instead C<send> will return -1
>> with $! set to EPIPE ("broken pipe"). You shouldn't have to
>> do any other error checking contortions.
>
>Keep in mind that the program wasn't terminating, it was blocking
>in send().
>
>I suspect if you set it to ignore (I haven't tried it) then
>the signal won't be delivered, and the send() won't get interrupted.
>and I'm back to being blocked.
>
No, I don't believe that's true. Even if the signal's ignored,
errno gets set. For instance, here's a simple client/server
pair which causes the client to terminate with:
"send: Broken pipe at ./client.pl line 18"
The server simply closes the socket before the client
can finish sending a large amount of data to force the
SIGPIPE.
--
Charles DeRykus
#/usr/bin/perl -w
# simple server that exits at once to force a SIGPIPE
use IO::Socket;
use strict;
my $sock = IO::Socket::INET->new( LocalAddr=> "localhost",
LocalPort=>31025,
Listen => 5,
Proto => "tcp" );
die "can't connect: $!" unless $sock;
my $connection = $sock->accept;
$connection->close;
__END__
#!/usr/bin/perl -lw
# client that tries to write lots of data
use Socket;
use strict;
my($server) = qw(localhost);
my($port,$name) = qw(31025 foo);
my($iaddr,$paddr,$proto);
$iaddr = inet_aton($server) or die "Unable to locate server";
$paddr = sockaddr_in($port,$iaddr) or die "sockaddr_in: $!";
$proto = getprotobyname('tcp') or die "getprotobyname: $!";
$SIG{ PIPE } = 'IGNORE';
socket(SOCK,PF_INET,SOCK_STREAM,$proto) or die "socket: $!";
connect(SOCK,$paddr) or die "connect: $!";
$ARGV[0] = "foo" x 10_000;
defined(send(SOCK,"foo @ARGV\n",0)) or die "send: $!";
print while <SOCK>;
__END__
------------------------------
Date: Thu, 9 Nov 2000 10:24:34 -0000
From: "abaltd" <abaltd@ntlworld.com>
Subject: Re: Emailing formatted
Message-Id: <rYuO5.87639$hk2.279238@news6-win.server.ntlworld.com>
--
Alan Dougall
alan@tradesponsors.com
www.tradesponsors.com
James Taylor <james@NOSPAM.demon.co.uk> wrote:
in message news:ant081208b49fNdQ@oakseed.demon.co.uk...
> > Content-Type: multipart/alternative;
> > boundary="----=_NextPart_000_C0_KBO0LAAA"
> > (and so on)
>
> You appear to have the boundary="" line as a separate line from
> Content-Type: so perhaps that's the problem. When RFC822 header lines
> are folded the subsequent lines must start with whitespace (usually a
> tab character).
>
> I would definitely recommend using an established module to build MIME
> messages because the author will have made all the mistakes and
> widespread peer review will have corrected most of them already.
> There's no point in going through it all yourself. I've heard that
> MIME::Lite is simple to use so why don't you check it out.
Will do! Thx
> > No, normally just sendmail -t !!
> > (checking man sendmail: -oi ignores '.'s at beginning of lines??)
>
> Yes, you need -oi otherwise a chance '.' in the email body could
> terminate the message early thus corrupting it.
[snip]
Now I remember that behaviour from an X400 server set-up.
> Yes, so it looks like you have folded the boundary="" line incorrectly
> as I mentioned above. Save yourself a lot of trouble, use MIME::Lite.
That was indeed my problem.
So, thinks...
I imagine that I'll be using Outlook (Express) or an HTML editor to produce
the formatted email.
I'll then paste it into the form message box
So, presumably calling some MIME(::Lite) routine will convert it to:
- multipart with it's "stripped down" text form, which saves me doing it in
my Perl script - sounds as if that is a better approach
- OR just simple text (for those not wishing to receive HTML).
Thx for the tips, Alan
--
Alan Dougall
alan.dougall@virgin.net
http://start.at/the.cross
------------------------------
Date: Thu, 09 Nov 2000 09:27:12 GMT
From: gelshocker@my-deja.com
Subject: Hash assignments in loops?
Message-Id: <8udqlc$cpg$1@nnrp1.deja.com>
Hi,
For some reason I can't seem to populate hashes in a loop block. For
example, I have a forloop that splits @lines into 2 elements, assigning
the elements as key/value into a %hash.
Doesn't work: I only get one $hash, being the last elements from
@lines. Tried the Cookbook but no examples of hash assignments in a
loop block. And I missing something?
Many, many thanks!
Jason Lam
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 9 Nov 2000 11:05:05 -0000
From: "Christian Mahnke" <mahnke@fliegen-ist-schoener.de>
Subject: Re: Hash assignments in loops?
Message-Id: <8udssl$dcp$06$1@news.t-online.com>
Show the code!
What I could imagine, that you assign the entire hash in every loop. That
would explain, why you only have the latest element in the hash after the
loop is done.
mit freundlichen Grüßen / With kind regards
Christian Mahnke
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
Fliegen-ist-Schoener.de
http://www.fliegen-ist-schoener.de
mahnke@fliegen-ist-schoener.de
Tel: 0179-5304585
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
in-House Partner:
http://www.billiger-telefonieren.de/ ~ http://www.stromseite.de/
http://www.billiger-surfen.de/ ~ http://www.tvinfo.de/
http://www.billiger-versichern.de/ ~ http://www.booklooker.de/
http://www.sms.de/ ~ http://www.movil24.com/
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
<gelshocker@my-deja.com> schrieb im Newsbeitrag
news:8udqlc$cpg$1@nnrp1.deja.com...
> Hi,
>
> For some reason I can't seem to populate hashes in a loop block. For
> example, I have a forloop that splits @lines into 2 elements, assigning
> the elements as key/value into a %hash.
>
> Doesn't work: I only get one $hash, being the last elements from
> @lines. Tried the Cookbook but no examples of hash assignments in a
> loop block. And I missing something?
>
> Many, many thanks!
> Jason Lam
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Thu, 9 Nov 2000 10:09:21 -0000
From: "Trevor Ward" <tward10@jaguar.com>
Subject: Re: Hash assignments in loops?
Message-Id: <8udt4i$i085@eccws12.dearborn.ford.com>
I tend to do this
foeach $item (@array)
{
my ($pt1, $pt2) = split (/what/, $item);
$hash{$pt1} = $pt2;
}
have fun
<gelshocker@my-deja.com> wrote in message
news:8udqlc$cpg$1@nnrp1.deja.com...
> Hi,
>
> For some reason I can't seem to populate hashes in a loop block. For
> example, I have a forloop that splits @lines into 2 elements, assigning
> the elements as key/value into a %hash.
>
> Doesn't work: I only get one $hash, being the last elements from
> @lines. Tried the Cookbook but no examples of hash assignments in a
> loop block. And I missing something?
>
> Many, many thanks!
> Jason Lam
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Thu, 9 Nov 2000 10:43:06 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Hash assignments in loops?
Message-Id: <slrn90kvs1.2jm.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 9 Nov 2000 10:09:21 -0000, Trevor Ward <tward10@jaguar.com>
wrote:
>I tend to do this
>
>foeach $item (@array)
>{
> my ($pt1, $pt2) = split (/what/, $item);
>
> $hash{$pt1} = $pt2;
>}
That doesn't compile.
Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'
------------------------------
Date: Thu, 9 Nov 2000 09:35:13 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: Help -- msgget with key >= 0x80000000 fails
Message-Id: <8udr16$7pi$1@soap.pipex.net>
"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn90jvv3.7ck.mgjv@verbruggen.comdyn.com.au...
> On Wed, 8 Nov 2000 14:07:31 -0000,
> Geoff Winkless <geoff-at-farmline-dot-com@127.0.0.1> wrote:
> > As such my understanding is that my specifying a key of ffe0ffe0
_should_
> > fail?
>
> It should, but didn't you say that you had C code that did the same,
> but that worked? That's what threw me a bit.
Mmm. I've been having a think about this. There's nothing in the manpages (I
don't know where I could read the sysV specs for this) about positive values
for key -- so there's no reason why passing key as negative is invalid.
I guess the problem would be that if I pass a very high (ie >= 1<<32) number
to perl when it's expecting an int it will assume that the number is out of
bounds, whereas passing a 32-bit value as an int to C will just mean it will
treat it as a negative number - which then gets passed through to the system
and just happens to work. I'll try passing the actual negative number to
perl and see what happens :)
Geoff
------------------------------
Date: Thu, 9 Nov 2000 09:51:36 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: Help -- msgget with key >= 0x80000000 fails
Message-Id: <8udrvt$87u$1@soap.pipex.net>
"Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1> wrote in message
news:8udr16$7pi$1@soap.pipex.net...
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn90jvv3.7ck.mgjv@verbruggen.comdyn.com.au...
> > On Wed, 8 Nov 2000 14:07:31 -0000,
> > Geoff Winkless <geoff-at-farmline-dot-com@127.0.0.1> wrote:
> > > As such my understanding is that my specifying a key of ffe0ffe0
> _should_
> > > fail?
> >
> > It should, but didn't you say that you had C code that did the same,
> > but that worked? That's what threw me a bit.
>
> Mmm. I've been having a think about this. There's nothing in the manpages
(I
> don't know where I could read the sysV specs for this) about positive
values
> for key -- so there's no reason why passing key as negative is invalid.
>
> I guess the problem would be that if I pass a very high (ie >= 1<<32)
number
> to perl when it's expecting an int it will assume that the number is out
of
> bounds, whereas passing a high-bit-set 32-bit value as an int to C will
just mean it will
> treat it as a negative number - which then gets passed through to the
system
> and just happens to work. I'll try passing the actual negative number to
> perl and see what happens :)
Yeuck. I was right.
The following code:
$IPC_CREAT=oct (1000);
$rq_queue=msgget (-520101633, $IPC_CREAT | oct(777));
# 0xe0ffe0ff
$rt_queue=msgget (-2031648, $IPC_CREAT | oct(777));
# 0xffe0ffe0
works correctly.
Now the question is, what do the specs say? Should there be a restriction
on -ve numbers? Is there a specific size (32 bits?) for the key?
Geoff
------------------------------
Date: Thu, 9 Nov 2000 21:12:24 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Help -- msgget with key >= 0x80000000 fails
Message-Id: <slrn90ku48.22p.mgjv@martien.heliotrope.home>
On Thu, 9 Nov 2000 09:35:13 -0000,
Geoff Winkless <geoff-at-farmline-dot-com@127.0.0.1> wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn90jvv3.7ck.mgjv@verbruggen.comdyn.com.au...
>> On Wed, 8 Nov 2000 14:07:31 -0000,
>> Geoff Winkless <geoff-at-farmline-dot-com@127.0.0.1> wrote:
>> > As such my understanding is that my specifying a key of ffe0ffe0
> _should_
>> > fail?
>>
>> It should, but didn't you say that you had C code that did the same,
>> but that worked? That's what threw me a bit.
>
> Mmm. I've been having a think about this. There's nothing in the manpages (I
> don't know where I could read the sysV specs for this) about positive values
> for key -- so there's no reason why passing key as negative is invalid.
>
> I guess the problem would be that if I pass a very high (ie >= 1<<32) number
> to perl when it's expecting an int it will assume that the number is out of
> bounds, whereas passing a 32-bit value as an int to C will just mean it will
> treat it as a negative number - which then gets passed through to the system
> and just happens to work. I'll try passing the actual negative number to
> perl and see what happens :)
Perl actually treats it as a double, and that double gets cast to a
key_t. If you cast a dbl to an int, I don't think you're guaranteed to
get a negative number. However, on my Linux box, it does become
negative, and equal to INT_MIN. Any large value behaves like that. So,
it looks like your key_t ends up as INT_MIN. It is very well possible
that that is disallowed. In fact, W. Richard Stevens[1] says
Each IPC structure [..] in the kernel is defined by a nonnegative
integer identifier.
[...]
The data type of this key is the primitive system data type key_t,
which is often defined as a long integer in the header
<sys/types.h>.
So, it looks like key_t being a signed type, but only allowing positive
values is normal behaviour. This means that your key_t should be between
0 and INT_MAX (on linux). Anything else is disallowed. Anything between
0x0 and 0x7fffffff is allowed. Your key_t is simply too large :)
We've now established, I hope, that Perl isn't to blame here, and in
fact it does the right thing. Maybe the discussion is far enough
offtopic now that it should be taken to comp.unix.programmer
Martien
[1] W. Richard Stevens, /Advanced programming in the Unix environment/,
p. 449
--
Martien Verbruggen | Since light travels faster than
Interactive Media Division | sound, isn't that why some people
Commercial Dynamics Pty. Ltd. | appear bright until you hear them
NSW, Australia | speak?
------------------------------
Date: Thu, 09 Nov 2000 09:36:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help with HTML::Parser module
Message-Id: <21sk0t4jdn3vdi5mrkadoe5923nctq605h@4ax.com>
Daniel Chetlin wrote:
>Note that this solution doesn't deal perfectly well with nested `font'
>tags -- to do that correctly would require a minor addition of a counter
>to maintain state.
I think this was precisely the problem.
>You might also take a look at HTML::TokeParser, which comes bundled with
>HTML::Parser. It's a slightly easier interface to get used to, and would
>handle this task quite well.
Same problem.
--
Bart.
------------------------------
Date: Thu, 09 Nov 2000 05:30:34 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: NT4 - How do I display the current userid?
Message-Id: <_DqO5.9699$I8.1590792@typhoon.southeast.rr.com>
Bill Border <bill_border@agilent.com> wrote in message
news:8uchnf$f7k$1@nonews.col.hp.com...
> Hi All,
>
> I am running a Perl pgm that is invoked from a unix server (with
> the resource kit rsh nt daemon) and in order to get an ODBC
> Oracle application to work, I need to know what USERID it my
> task is running under.
>
> The $> variable returns 0. ??????
From perldoc win32:
Win32::LoginName()
[CORE] Returns the username of the owner of the current perl
process.
For some reason, the Win32 module documentation isn't in the toc frame of my
ActiveState documentation, but I knew I had seen it before somewhere else.
Anyway, just "use Win32;", and then Win32::LoginName() will be what you're
looking for.
good luck,
p
------------------------------
Date: Thu, 9 Nov 2000 09:08:43 +0100
From: cdemaeyer1@mmm.com (CDM)
Subject: Re: NT4 - How do I display the current userid?
Message-Id: <8udm3n$au4$1@magnum.mmm.com>
Script is running from Unix, I doubt it supports windows calls....
"Philip Garrett" <philipg@atl.mediaone.net> wrote in message
news:_DqO5.9699$I8.1590792@typhoon.southeast.rr.com...
> Bill Border <bill_border@agilent.com> wrote in message
> news:8uchnf$f7k$1@nonews.col.hp.com...
> > Hi All,
> >
> > I am running a Perl pgm that is invoked from a unix server (with
> > the resource kit rsh nt daemon) and in order to get an ODBC
> > Oracle application to work, I need to know what USERID it my
> > task is running under.
> >
> > The $> variable returns 0. ??????
>
> From perldoc win32:
>
> Win32::LoginName()
> [CORE] Returns the username of the owner of the current perl
> process.
>
> For some reason, the Win32 module documentation isn't in the toc frame of
my
> ActiveState documentation, but I knew I had seen it before somewhere else.
> Anyway, just "use Win32;", and then Win32::LoginName() will be what you're
> looking for.
>
> good luck,
> p
>
>
Opinions expressed herein are my own and may not represent those of my employer.
------------------------------
Date: 9 Nov 2000 05:31:46 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: OOP and information hiding
Message-Id: <8udcs2$t0n$1@towncrier.cc.monash.edu.au>
James Taylor <james@NOSPAM.demon.co.uk> writes:
> Fascinating, Damian, is all this discussed/explained in your book?
Pages 309-326.
> Can you remind me of the title, publisher, ISBN, etc.
"Object Oriented Perl", Manning Publications, 1884777791.
See http://www.amazon.com/exec/obidos/ASIN/1884777791/
> > then you can release under 'fast' mode:
> >
> > use Tie::SecureHash 'mode';
> >
> > and the performance hit disappears too.
> Is that correct, or should it be use Tie::SecureHash 'fast'; ?
Oops, you're quite right: s/mode/fast/
And while you're at it: s/safe/strict/
%-)
Damian
------------------------------
Date: 9 Nov 2000 10:20:05 GMT
From: abigail@foad.org (Abigail)
Subject: Re: OOP and information hiding
Message-Id: <slrn90kuil.kt8.abigail@tsathoggua.rlyeh.net>
On 9 Nov 2000 01:05:41 GMT, Damian Conway (damian@cs.monash.edu.au) wrote in comp.lang.perl.misc <URL: news:<8uct95$ujo$1@towncrier.cc.monash.edu.au>>:
++
++ use Tie::SecureHash;
++
++ sub new {
++ my ($class, $arg1, $arg2, $arg3) = @_;
++ return Tie::SecureHash->new($class,
++ __attr1 => $arg1,
++ __attr2 => $arg2,
++ __attr3 => $arg3,
++ );
++ }
++
++ That's it. The object acts like a hash, but the double-underscored
++ attributes are private, and don't suffer from collisions with derived
++ class objects.
++
++ Of course, the trade-off is performance, since the object is actually
++ a tied hash (which is always slower to access). But if you develop under
++ 'safe' mode:
There is another trade-off, and that's the sheer explosion of punctuation
characters - a minor peeve I have against Perl OO style programming.
I'd write this in Perl:
my @array;
push @array => 1, 2, 3, 4;
And this in OO-Perl with SecureHashes:
my $self = shift;
push @{$self -> {__array}} => 1, 2, 3, 4;
If you don't use secure hashes, you can drop two underscores, but
there's no safeguard against making typos in attributes anymore.
Abigail
------------------------------
Date: Thu, 09 Nov 2000 10:49:55 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: OOP and information hiding
Message-Id: <hovk0ts77qsh3gh5olignjpdc4t6m6jqgs@4ax.com>
Damian Conway wrote:
>But if pressed, I think the Tie::Securehash module represents the
>closest thing to a "best practice" for most applications. That's why
>I've proposed most of its features as standard mechanisms in Perl 6.
>
>I certainly think it's simple enough to warrant wider use.
>
>You just replace the normal hash-based constructor of the class:
>
> sub new {
> my ($class, $arg1, $arg2, $arg3) = @_;
> return bless {
> __attr1 => $arg1,
> __attr2 => $arg2,
> __attr3 => $arg3,
> }, $class;
> }
>
>
>with a securehash-based one:
>
> use Tie::SecureHash;
>
> sub new {
> my ($class, $arg1, $arg2, $arg3) = @_;
> return Tie::SecureHash->new($class,
> __attr1 => $arg1,
> __attr2 => $arg2,
> __attr3 => $arg3,
> );
> }
>
>That's it. The object acts like a hash, but the double-underscored
>attributes are private, and don't suffer from collisions with derived
>class objects.
As always, Damina likes complex solutions. ;-)
In principle, the language *could* provide an easy way to give Perlish
(= so simple you can hardly believe it), private keys.
My idea is to extend the package qualification idea from global
variables, to hash keys, with a special, er, "marker". So a private hash
key "Bar" in a package "My::Class" would actually form the hash key
string "My::Class::Bar".
Here as straightforward but unoptimized (unoptimizable?) implementation.
You mark a private field with the subroutine call to a sub '__', which
is Damian's convention for a prefix for private fields, anyway.
use Data::Dumper;
print Dumper new My::Class;
package My::Class;
BEGIN {
*__ = \&Field::__; # "import" from Field
}
sub new {
my $self = shift;
return bless { Foo => 'foo', __('Bar') => 'bar' }
}
package Field;
sub __ {
return (caller)[0] . '::' . shift;
}
-->
$VAR1 = bless( {
'Foo' => 'foo',
'My::Class::Bar' => 'bar'
}, 'My::Class' );
You can still access "private" fields from outside this package, by
fully qualifying them.
The "unoptimized/unoptimizable" part is that the function call is
executed at run time, time and time again; while ideally, it would be
replaced by it's value at compile time, once. It should be as with
constants.
One more problem is with the necessary (usually) quoting of the argument
to __(). Sigh. It would be nice, through prototypes, to be able to
autoquote the argument. (Can't Lisp do that?)
I think I'd like this for syntax:
sub new {
my $self = shift;
return bless { Foo => 'foo', __ Bar => 'bar' }
}
--
Bart.
------------------------------
Date: Thu, 09 Nov 2000 08:24:11 GMT
From: vivek@cse.iitd.ernet.in
Subject: Re: Passing args as references
Message-Id: <8udmv7$a92$1@nnrp1.deja.com>
one can very easily pass the values as refernces in perl.
to pass a variable $check as reference to &foo
do the following
&foo(\$check);
now one can update check variable by $$_[0]="new value";
for more details on refernces refer to camel book (Programming Perl)
In article <YEZN5.64162$E85.1706259@news1.sttls1.wa.home.com>,
"John" <nobodyshere@com.home> wrote:
> How do you pass an argument as a reference to a function so you can
actually
> modify the original variables value as opposed to a function value?
>
> John
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 9 Nov 2000 06:14:21 GMT
From: Eli the Bearded <eli@there-is-no-more-qzto.com>
Subject: Re: percent-underscore: %_
Message-Id: <eli$0011090046@qz.little-neck.ny.us>
In comp.lang.perl.misc, Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> >> "Brian McDonald" <mcdonabNO@SPAMyahoo.com> wrote:
> >> > what is the formal perl name of the ("scratch") variable represented
> >> > by %_?
> It's real because the symbol table entry with the name _ exists. It
> has no special meaning to Perl, but you can use it if you want to.
Agreed.
> [addition after supersede]
> Actually, having thought a bit more about this... I'm not even sure
> whether the typeglob really needs to exist, or whether the name itself
> is treate specially by Perl. Anyone reading this who does know?
> [end addition]
I'm pretty sure any [^\s\w\0] char can be a single character global
in the main:: package. Some have special meanings to perl, some
don't.
> You can also use @., @1, @2, etc., %1, %2, etc., %& and all those nice
> looking line noise variables. As long as perlvar doesn't mention
> them, but does mention another 'type' of variable with the same name,
> you can safely use them. Even under strict. The ones that perlvar does
> mention may be subject to special treatment, so you can't always
> treat them as a regular variable (or array, or hash).
#!/usr/bin/perl -w
use strict;
my $fun = "\$^^ = q!Whee!";
my $games = "print qq!\$\036\n!";
my $toy = "\@\346[3,4,6] = qw!O o o!";
my $cool = "print join('',\@æ) . qq!\n!";
eval $fun;
eval $games;
eval $toy;
$^W = 0; # @\346 does not have values for [0,1,2,5], so hide the warnings
eval $cool;
__END__
:r! perl -wx %
Whee
Ooo
Elijah
------
perl -we 's ssqprint qq\0just another perl hacker\n\see'
------------------------------
Date: 9 Nov 2000 10:51:25 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: percent-underscore: %_
Message-Id: <8udvjd$crb$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Eli the Bearded
<eli@there-is-no-more-qzto.com>],
who wrote in article <eli$0011090046@qz.little-neck.ny.us>:
> I'm pretty sure any [^\s\w\0] char can be a single character global
> in the main:: package.
Not '{'. And \0 might be OK, but is not... Btw, ^D and ^Z are
"protected" in these positions...
perl -wle ' eval qq( print 11; \cZ print 22; 1) or die'
11
perl -wle ' eval qq( \$\cZ = 11; print \$\cZ; 1 ) or die'
11
perl -wle ' eval qq( \$\0 = 11; print \$\0; 1 ) or die'
syntax error at (eval 1) line 1, near "$"
syntax error at (eval 1) line 1, at EOF
...propagated at -e line 1.
Exit 255
Ilya
------------------------------
Date: Thu, 9 Nov 2000 09:15:12 +0100
From: cdemaeyer1@mmm.com (CDM)
Subject: Re: Perl on Win32 - System Call error numbers
Message-Id: <8udmfs$aud$1@magnum.mmm.com>
To get the right return code something more is needed....
$rc=system("$command");
$rc=$rc >> 8; # needs to be divided by 256 to get real return code
"Kevin Philbrick" <KPhilbrick@carolina.rr.com> wrote in message
news:K1eO5.8587$I8.1186969@typhoon.southeast.rr.com...
> Is there anyway to determine what an error number, returned from a system
> call, means? I am getting a 65280 error number with no text explanation.
>
> # run the command
> my @command = ("[path]xyz.exe");
> if( system("@command") ) {Logger("Error Running Job: $?: $@")}
>
> Logger is a sub that prints whatever to an error log.
>
> Here is the output:
>
> Error Running Job: 65280:
>
> Any help would be most appreciated.
>
> KevinP
>
>
Opinions expressed herein are my own and may not represent those of my employer.
------------------------------
Date: 9 Nov 2000 06:20:11 GMT
From: Eli the Bearded <eli@there-is-no-more-qzto.com>
Subject: Re: Problem with Inline C
Message-Id: <eli$0011090117@qz.little-neck.ny.us>
In comp.lang.perl.misc, <vidulats@yahoo.co.uk> wrote:
> Example 1 is:
> greet('Ingy');
> greet(42);
>
> use Inline C => <<'END_OF_C_CODE';
>
> void greet(char* name) {
> printf("Hello %s!\n", name);
> }
>
> END_OF_C_CODE
>
> If I execute the code as it is, its giving error on END_OF_C_CODE Line.
Have you tried it unindented? Here-documents (the << begins one)
cannot have the closing text indented.
> If I remove all the Inline related statements, it works fine.
For some useless value of 'fine', no doubt.
> My First question is: Where I will get "INLINE.h" file?
You have it already, and Inline.pm will find it, if Inline.pm is
installed correctly.
Elijah
------
maybe you could look at the test suite that came with Inline.pm for ideas
------------------------------
Date: Thu, 09 Nov 2000 07:13:58 GMT
From: craznar@hotmail.com (Christopher Burke)
Subject: Re: Pushing a hash on to a stack...
Message-Id: <8FE7AF289Craznar@24.192.1.17>
mgjv@tradingpost.com.au (Martien Verbruggen) wrote in
<slrn90kbp9.7ck.mgjv@verbruggen.comdyn.com.au>:
>You're ungrateful, and unreasonable. And very childish, too. But if
>you want to go off, and sulk in a corner, that's fine by me. Usenet
>can be hard on the ego, especially if you're of a stubborn nature.
>Some people never get over that.
>
Having read your blurb I am not ungrateful, just more wary now of asking
questions of people who I thought were superior in knowledge to me. I asked
a few people at work who are long time perl users, none of them could
answer - but neither were they critical of my question nor did they think
it a silly question.
I made it clear from the start of this thread that I HAVE A SOLUTION and
that I was clearly requesting an answer to a specific question.
I will not be sulking in a corner, but I now know that like one or two
other newsgroups I have seen that this is one to be wary of.
--
---
/* Christopher Burke - Spam Mail to craznar@hotmail.com
|* www.craznar.com - International Internet Writing Experiment
\* Real mail to cburke(at)craznar(dot)com
------------------------------
Date: Thu, 9 Nov 2000 21:34:18 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Pushing a hash on to a stack...
Message-Id: <slrn90kvda.22p.mgjv@martien.heliotrope.home>
On Thu, 09 Nov 2000 07:13:58 GMT,
Christopher Burke <craznar@hotmail.com> wrote:
> mgjv@tradingpost.com.au (Martien Verbruggen) wrote in
><slrn90kbp9.7ck.mgjv@verbruggen.comdyn.com.au>:
>
>>You're ungrateful, and unreasonable. And very childish, too. But if
>>you want to go off, and sulk in a corner, that's fine by me. Usenet
>>can be hard on the ego, especially if you're of a stubborn nature.
>>Some people never get over that.
>>
>
> Having read your blurb I am not ungrateful, just more wary now of asking
> questions of people who I thought were superior in knowledge to me. I asked
> a few people at work who are long time perl users, none of them could
> answer - but neither were they critical of my question nor did they think
> it a silly question.
>
> I made it clear from the start of this thread that I HAVE A SOLUTION and
> that I was clearly requesting an answer to a specific question.
*sigh*
My last word on this.
Let's quote your original words:
)) Can any perl experts emulate the following using the push/pop idea.
))
)) %{$fulldata[scalar @fulldata]} = %hash;
))
[snip]
)) print $fulldata[0]{X}."\n";
)) print $fulldata[0]{Y}."\n";
)) print $fulldata[1]{X}."\n";
)) print $fulldata[1]{Y}."\n";
[snip]
)) And no - I don't want to use references.
That to me doesn't sound like you have a solution. It contains two
contradictory statements.
1) You use references, yet you want us to emulate the same, without
references.
2) You talk about push/pop (implying a stack), and yet, you access the
things on that stack by index.
We insist on clarifications, and get this mystical crap about you having
your reasons, but without any explanation what they are. By now, you've
worked on a few people's nerves. Not because of the original message as
much, but much, much more because of your answers to the suggestions,
questions and other posts.
People even go through the trouble of submitting code, spome of which
uses references, and lo and behold, even two solutions that don't. You
don't even MENTION the fact that this has happened, and whether or not
it is close to what you mean. Whether this is simply because you don't
understand the code, or whether it is because you're simply an
incosiderate bastard is just terribly hard to tell from the other end of
two keyboards and monitors.
> I will not be sulking in a corner, but I now know that like one or two
> other newsgroups I have seen that this is one to be wary of.
Yes. If you behave the way you behave, this is the sort of reaction you
get. Here, and in many other places. People get annoyed when talking to
a brick wall. You were being a brick wall.
All that I mean is that you should look at your own posts and behaviour,
and really question whether you didn't accidentally, maybe, potentially
display any inflammatory behaviour. Not even a single spark? if you
conclude that you didn't, and that you are fully justified in seeing
this group as a bunch of elitist close-knit exclusive geeks, then you
will have a hard life on Usenet, except maybe on the groups with support
in their name.
And yes, the regular posters to this group, or at least some, have set
ideas about how certain things should be done in Perl, notwithstanding
that there are more ways than one to do it. This is not elitist, or
chest-beating show-offery. It is called experience.
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
NSW, Australia | being a damn fool about it.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4852
**************************************