[31742] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3005 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 26 09:09:22 2010

Date: Sat, 26 Jun 2010 06:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 26 Jun 2010     Volume: 11 Number: 3005

Today's topics:
        Accessing Web Site Files Questions <edgrsprj@ix.netcom.com>
    Re: Accessing Web Site Files Questions (Jens Thoms Toerring)
    Re: bulk flush input <derykus@gmail.com>
    Re: bulk flush input <derykus@gmail.com>
    Re: bulk flush input <nospam-abuse@ilyaz.org>
    Re: bulk flush input <jak@isp2dial.com>
    Re: bulk flush input <derykus@gmail.com>
    Re: bulk flush input <jak@isp2dial.com>
    Re: bulk flush input <jak@isp2dial.com>
    Re: bulk flush input <willem@turtle.stack.nl>
        line numbers within code <robin1@cnsp.com>
    Re: line numbers within code <uri@StemSystems.com>
    Re: line numbers within code (Jens Thoms Toerring)
    Re: Proposing a new module: Parallel::Loops <4ux6as402@sneakemail.com>
    Re: Proposing a new module: Parallel::Loops <4ux6as402@sneakemail.com>
    Re: Proposing a new module: Parallel::Loops <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 26 Jun 2010 00:12:13 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Accessing Web Site Files Questions
Message-Id: <OtadnesmsqezEbjRnZ2dnUVZ_u-dnZ2d@earthlink.com>

DOWNLOADING And PRINTING WEB SITE FILES QUESTIONS

I am running a recent version of the ActiveState Perl program with Windows 
XP and Vista operating systems.  The LWP module has been installed.

Could someone list the correct Perl code to use for having a Perl program 
download and store or print a file from a Web site?

I read all of the online documentation I could locate and tried various 
commands.  However, error messages keep appearing that say that the Web 
hosts cannot be accessed etc.

This is a command that I tried for simply printing a text file to the 
monitor.  (A real Web site address was used, not the one listed here.)

use LWP::Simple;
LWP::Simple::getprint("http://www.webhost.com/file.txt");



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

Date: 26 Jun 2010 12:47:33 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Accessing Web Site Files Questions
Message-Id: <88mb75Fu53U1@mid.uni-berlin.de>

E.D.G. <edgrsprj@ix.netcom.com> wrote:
> I am running a recent version of the ActiveState Perl program with Windows 
> XP and Vista operating systems.  The LWP module has been installed.

> Could someone list the correct Perl code to use for having a Perl program 
> download and store or print a file from a Web site?

> I read all of the online documentation I could locate and tried various 
> commands.  However, error messages keep appearing that say that the Web 
> hosts cannot be accessed etc.

> This is a command that I tried for simply printing a text file to the 
> monitor.  (A real Web site address was used, not the one listed here.)

> use LWP::Simple;
> LWP::Simple::getprint("http://www.webhost.com/file.txt");

And that should work - it does for me when putting it into a
Perl script or using e.g.

perl -MLWP::Simple -e 'getprint "http://www.sn.no"'

from the command line. Getting error messages about not being
able to access the web server could be the result of a mis-
configured system, that you entered an incorrect URL or that
you either try to download a page that the web server is not
allowed to serve. To find out what's going on you would have
to post the error messages with the exact code you're using,
without that everything is just pure guesswork. And also keep
in mind that the module doesn't do authentification, a web
page that you can view in your browser might only be available
since you're logged in into that site already.

                               Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Fri, 25 Jun 2010 22:08:54 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: bulk flush input
Message-Id: <fe2a5266-3620-4835-aaf9-b19c6032e254@31g2000prq.googlegroups.com>

On Jun 25, 7:47=A0pm, John Kelly <j...@isp2dial.com> wrote:
> On Sat, 26 Jun 2010 03:21:08 +0100, Ben Morrow <b...@morrow.me.uk> wrote:
>
> >Quoth John Kelly <j...@isp2dial.com>:
>
> >> #!/usr/bin/perl
>
> >> use strict;
> >> use warnings;
>
> >> my $data;
>
> >> while (<>) {
> >> =A0 =A0 chomp;
> >> =A0 =A0 if (!$data && $_) {
> >> =A0 =A0 =A0 =A0 $data =3D $_;
> >> =A0 =A0 }
> >> }
>
> >> print "data=3D$data\n";
>
> >> This code reads STDIN and remembers the first non-empty line. =A0That'=
s
> >> all it cares about.
>
> >No, it remembers the first line that doesn't evaluate to boolean false.
> >Since you are chomping the lines, a line containing only "0" will be
> >considered 'empty'. You want to check length $data.
>
> Yeah, shot myself in the foot again.
>
>
>
> >> But it also keeps reading till EOF, acting like the "cat" utility, to
> >> flush the extra input and avoid broken pipe errors.
>
> >> But reading line by line, just to throw away the unwanted garbage, is
> >> inefficient. =A0I would like to jump out of the loop and "bulk flush" =
the
> >> remaining input stream.
>
> >> I don't think
>
> >> >$io->flush
>
> >> >flush causes perl to flush any buffered data at the perlio
> >> >api level. Any unread data in the buffer will be discarded,
>
> >> will work, because that it flushes the buffer, not the entire input
> >> stream. =A0I want to flush the whole file. =A0And keep in mind, I don'=
t want
> >> a broken pipe either.
>
> >> Suggestions?
>
> > =A0 =A0my $data;
> > =A0 =A0while (<>) {
> > =A0 =A0 =A0 =A0chomp;
> > =A0 =A0 =A0 =A0length or next;
> > =A0 =A0 =A0 =A0$data =3D $_;
> > =A0 =A0 =A0 =A0last;
> > =A0 =A0}
> > =A0 =A0{
> > =A0 =A0 =A0 =A0local $/ =3D \2048;
> > =A0 =A0 =A0 =A01 while <>;
> > =A0 =A0}
>
> >Ben
>
> That looks interesting, =A0I get the first part, the rest will give me
> something to chew on ...
>

But, this'll just read/toss 2048 byte chunks
till EOF. Alternatively, if you want to toss
the entire stream after exiting the loop, a
single statement:

     <>;

does what you want due to the list context. I
suspect there's little to gain by changing $/.


--
Charles DeRykus


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

Date: Fri, 25 Jun 2010 23:05:11 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: bulk flush input
Message-Id: <2d76f047-f3be-45ce-8fe9-4ab8f53d63d6@z21g2000prc.googlegroups.com>

On Jun 25, 10:08=A0pm, "C.DeRykus" <dery...@gmail.com> wrote:
> On Jun 25, 7:47=A0pm, John Kelly <j...@isp2dial.com> wrote:
>
>
>
> > On Sat, 26 Jun 2010 03:21:08 +0100, Ben Morrow <b...@morrow.me.uk> wrot=
e:
>
> > >Quoth John Kelly <j...@isp2dial.com>:
>
> > >> #!/usr/bin/perl
>
> > >> use strict;
> > >> use warnings;
>
> > >> my $data;
>
> > >> while (<>) {
> > >> =A0 =A0 chomp;
> > >> =A0 =A0 if (!$data && $_) {
> > >> =A0 =A0 =A0 =A0 $data =3D $_;
> > >> =A0 =A0 }
> > >> }
>
> > >> print "data=3D$data\n";
>
> > >> This code reads STDIN and remembers the first non-empty line. =A0Tha=
t's
> > >> all it cares about.
>
> > >No, it remembers the first line that doesn't evaluate to boolean false=
 .
> > >Since you are chomping the lines, a line containing only "0" will be
> > >considered 'empty'. You want to check length $data.
>
> > Yeah, shot myself in the foot again.
>
> > >> But it also keeps reading till EOF, acting like the "cat" utility, t=
o
> > >> flush the extra input and avoid broken pipe errors.
>
> > >> But reading line by line, just to throw away the unwanted garbage, i=
s
> > >> inefficient. =A0I would like to jump out of the loop and "bulk flush=
" the
> > >> remaining input stream.
>
> > >> I don't think
>
> > >> >$io->flush
>
> > >> >flush causes perl to flush any buffered data at the perlio
> > >> >api level. Any unread data in the buffer will be discarded,
>
> > >> will work, because that it flushes the buffer, not the entire input
> > >> stream. =A0I want to flush the whole file. =A0And keep in mind, I do=
n't want
> > >> a broken pipe either.
>
> > >> Suggestions?
>
> > > =A0 =A0my $data;
> > > =A0 =A0while (<>) {
> > > =A0 =A0 =A0 =A0chomp;
> > > =A0 =A0 =A0 =A0length or next;
> > > =A0 =A0 =A0 =A0$data =3D $_;
> > > =A0 =A0 =A0 =A0last;
> > > =A0 =A0}
> > > =A0 =A0{
> > > =A0 =A0 =A0 =A0local $/ =3D \2048;
> > > =A0 =A0 =A0 =A01 while <>;
> > > =A0 =A0}
>
> > >Ben
>
> > That looks interesting, =A0I get the first part, the rest will give me
> > something to chew on ...
>
> But, this'll just read/toss 2048 byte chunks
> till EOF. Alternatively, if you want to toss
> the entire stream after exiting the loop, a
> single statement:
>
> =A0 =A0 =A0<>;
      ^^^^^^^

      () =3D <>;

--
Charles DeRykus
Charles DeRykus




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

Date: Sat, 26 Jun 2010 06:16:29 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: bulk flush input
Message-Id: <slrni2b6pt.u78.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-06-26, C.DeRykus <derykus@gmail.com> wrote:
>       () = <>;

Try to do it with a terabyte file...

Yours,
Ilya


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

Date: Sat, 26 Jun 2010 06:48:20 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Re: bulk flush input
Message-Id: <8j6b26dgpigf8cfp0adafkf1sm4s61jpsd@4ax.com>

On Fri, 25 Jun 2010 22:08:54 -0700 (PDT), "C.DeRykus"
<derykus@gmail.com> wrote:

>> >    my $data;
>> >    while (<>) {
>> >        chomp;
>> >        length or next;
>> >        $data = $_;
>> >        last;
>> >    }
>> >    {
>> >        local $/ = \2048;
>> >        1 while <>;
>> >    }
>>
>> >Ben
>>
>> That looks interesting,  I get the first part, the rest will give me
>> something to chew on ...
>>
>
>But, this'll just read/toss 2048 byte chunks
>till EOF. Alternatively, if you want to toss
>the entire stream after exiting the loop, a
>single statement:
>
>     <>;
>
>does what you want due to the list context. I
>suspect there's little to gain by changing $/.

That doesn't look like list context to me.  Testing a small data set
containing:

>
>
>
>one
>two
>
>three
>
>four
>

with this code:

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

#!/usr/bin/perl

use strict;
use warnings;

my $data = '';

while (<>) {
    chomp;
    /^\s*$/ and next;
    $data = $_;
    print "data=\"$data\"\n";
    last;
}

<> or die "1 EOF\n";
<> or die "2 EOF\n";
<> or die "3 EOF\n";
<> or die "4 EOF\n";
<> or die "5 EOF\n";
<> or die "6 EOF\n";
<> or die "7 EOF\n";
<> or die "8 EOF\n";
<> or die "9 EOF\n";

close STDIN;


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

produces output:

>data="one"
>6 EOF


Which seems to prove that a bare <> is scalar context.



-- 
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php
 


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

Date: Fri, 25 Jun 2010 23:53:08 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: bulk flush input
Message-Id: <f8317bf9-3d72-4061-9368-3dbf2f171980@y32g2000prc.googlegroups.com>

On Jun 25, 11:16=A0pm, Ilya Zakharevich <nospam-ab...@ilyaz.org> wrote:
> On 2010-06-26, C.DeRykus <dery...@gmail.com> wrote:
>
> > =A0 =A0 =A0 () =3D <>;
>
> Try to do it with a terabyte file...
>

Hm, sounds like I need to look more closely...

So a humongous temp array gets built with only
the resulting  assignment being optimized away...?

--
Charles DeRykus

perl -MO=3DConcise -e "()=3D<>"
8  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v:{ ->3
7     <2> aassign[t3] vKS ->8
-        <1> ex-list lK ->6
3           <0> pushmark s ->4
5           <1> readline[t2] lK/1 ->6
4              <#> gv[*ARGV] s ->5
-        <1> ex-list lK ->7
6           <0> pushmark s ->7
-           <0> stub lPRM* ->-


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

Date: Sat, 26 Jun 2010 06:53:18 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Re: bulk flush input
Message-Id: <io8b26tdt1ul539iep5laaj0jajhtdb2ps@4ax.com>

On Sat, 26 Jun 2010 06:16:29 +0000 (UTC), Ilya Zakharevich
<nospam-abuse@ilyaz.org> wrote:

>On 2010-06-26, C.DeRykus <derykus@gmail.com> wrote:
>>       () = <>;
>
>Try to do it with a terabyte file...

Aim gun at foot.  Pull trigger.  Not my concept of fun.


-- 
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php
 


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

Date: Sat, 26 Jun 2010 07:22:12 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Re: bulk flush input
Message-Id: <tbab26929kg12bdoq4i1qfvmn8aon0uh0v@4ax.com>


Thanks for the ideas, wrong ones too.  They taught me more Perl, and got
me pointed in the right direction.


-- 
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php
 


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

Date: Sat, 26 Jun 2010 08:40:43 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: bulk flush input
Message-Id: <slrni2bf8b.dpj.willem@turtle.stack.nl>

John Kelly wrote:
<snip>
)<> or die "1 EOF\n";
)<> or die "2 EOF\n";
)<> or die "3 EOF\n";
)<> or die "4 EOF\n";
)<> or die "5 EOF\n";
)<> or die "6 EOF\n";
)<> or die "7 EOF\n";
)<> or die "8 EOF\n";
)<> or die "9 EOF\n";
<snip>
) produces output:
)
)>data="one"
)>6 EOF
)
)
) Which seems to prove that a bare <> is scalar context.

No, it proves that the left-hand side of 'or' has scalar context.

I'm pretty sure that a bare <> has void context, (which usually
 translates to scalar context).

It is really a lot faster to change the line separator.
Setting it to \2048 means that it will always read that many bytes,
and undef'ing it would mean it will read the whole rest of the file.
I don't know if <> is smart enough to recognize void context though,
can probably be tested with a large file and a memory checker tool.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


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

Date: Sat, 26 Jun 2010 00:59:24 -0700 (PDT)
From: Robin <robin1@cnsp.com>
Subject: line numbers within code
Message-Id: <0b9f436f-3080-47eb-a8d5-0205f5957662@t10g2000yqg.googlegroups.com>

How can I get the line number in perl of the currently running perl
program, what perl code will return it and put it in a variable?

I have found it very difficult to figure this out.

Thank you,
-Robin


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

Date: Sat, 26 Jun 2010 04:12:01 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: line numbers within code
Message-Id: <87aaqirz5a.fsf@quad.sysarch.com>

>>>>> "R" == Robin  <robin1@cnsp.com> writes:

  R> How can I get the line number in perl of the currently running perl
  R> program, what perl code will return it and put it in a variable?

  R> I have found it very difficult to figure this out.

i have found it very difficult to respond to a spammer. have you tried
reading the documentation? it is in there.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: 26 Jun 2010 10:57:37 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: line numbers within code
Message-Id: <88m4p1Fnm8U1@mid.uni-berlin.de>

Robin <robin1@cnsp.com> wrote:
> How can I get the line number in perl of the currently running perl
> program, what perl code will return it and put it in a variable?

> I have found it very difficult to figure this out.

Have you tried to google for "perl line number"? The answer
(by using the variable '__LINE__', that's two underscores be-
fore and after 'LINE') is given already in the third link...

                              Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Sat, 26 Jun 2010 00:15:07 -0700 (PDT)
From: =?ISO-8859-1?Q?Peter_Valdemar_M=F8rch?= <4ux6as402@sneakemail.com>
Subject: Re: Proposing a new module: Parallel::Loops
Message-Id: <535ab347-c4ce-4455-b27f-74f7c4df5d6e@5g2000yqz.googlegroups.com>

On Jun 26, 12:34 am, Ben Morrow <b...@morrow.me.uk> wrote:
> Personally I find
>
>     my %output :shared;
>
>     for my $i (@input) {
>         async {
>             $output{$i} = do_some_hefty_calculation($i);
>         }
>     }
>
> somewhat clearer, but that's just a matter of taste. (With 5.10
> presumably a 'my $_' would make $_ work too.)

In fact, I think that looks better too. I do have a few concerns:

* Having "my %output : shared" and just async without a
Parallel::Loops reference parameter inevitably leads to global
variables. I don't like them. One could have two different
calculations in different sections of the code, that don't need the
same variables "shared", so I'd prefer to have info about shared
variables associated with a specific Parallel::Loops instance. What do
you think?

* About the async {} instead of $pl->foreach: The implementation needs
to wait for the last loop to finish, and only continue after the '}'
after all the processes have finished. I don't know how to do that
unless something like:

for my $i (@input) {
    # This fires up the parallel processes
    $pl->async {
        $output{$i} = do_some_hefty_calculation($i);
    }
}
# This waits for them all to finish before continuing.
$pl->joinAll();

This syntax could easily co-exist with the $pl->foreach and $pl->while
syntax. I'm worried though that people will forget to call $pl-
>joinAll()! I guess one could also have async return some reference to
the actual forked process (pid comes to mind) and then $pl->join($pid)
to wait for it to finish.

Regardless, I now think $pl->share(\%output) is a better name than $pl-
>tieOutput(\%output)

The rest of this post is about "my %difficulties : with shared;" :-) -
this syntax is how (threads|forks)::shared does it too. I like it, but
don't yet understand how to implement it. Have looked at "perldoc
attributes" and experimented a little. In fact I could get attributes
like "Shared" (==ucfirst("shared")) to work. "xxshared" works, but
issues a warning, but "shared" simply doesn't work (perl 5.10). Also,
I guess it isn't possible for several packages to be "listening" for
attributes at the same time, as they'd step on each other's exports of
e.g. sub MODIFY_SCALAR_ATTRIBUTES, wouldn't they?

Here is a little snippet I wrote to experiment:

me@it:~> cat attributes.pl
#!perl -w
use strict;
use attributes;
use Data::Dumper;

sub MODIFY_SCALAR_ATTRIBUTES {
    my ($pkg, $ref, $attributes) = @_;
    print Dumper(\@_, attributes::get($ref));
    return ();
}

my $shared : shared;
my $xshared : xshared;
my $Shared : Shared;

me@it:~> perl attributes.pl
$VAR1 = [
          'main',
          \undef
        ];
$VAR1 = [
          'main',
          \undef,
          'xshared'
        ];
SCALAR package attribute may clash with future reserved word: xshared
at attributes.pl line 13
$VAR1 = [
          'main',
          \undef,
          'Shared'
        ];


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

Date: Sat, 26 Jun 2010 00:16:41 -0700 (PDT)
From: =?ISO-8859-1?Q?Peter_Valdemar_M=F8rch?= <4ux6as402@sneakemail.com>
Subject: Re: Proposing a new module: Parallel::Loops
Message-Id: <321c1dbe-5f00-414a-9e9b-b677abd27f74@j4g2000yqh.googlegroups.com>

On Jun 25, 5:33=A0pm, Ted Zlatanov <t...@lifelogs.com> wrote:
> I like that syntax better personally than join() and detach().

Thanks for the support! :-)

> `forks' brings in socket IPC which can be an issue. =A0Your approach seem=
s
> a little cleaner IIUC.

As Ben says, it has to be done somehow. I use a pipe behind the
scenes.

Peter


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

Date: Sat, 26 Jun 2010 13:33:41 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Proposing a new module: Parallel::Loops
Message-Id: <5m8hf7-48j1.ln1@osiris.mauzo.dyndns.org>


Quoth =?ISO-8859-1?Q?Peter_Valdemar_M=F8rch?= <4ux6as402@sneakemail.com>:
> On Jun 26, 12:34 am, Ben Morrow <b...@morrow.me.uk> wrote:
> > Personally I find
> >
> >     my %output :shared;
> >
> >     for my $i (@input) {
> >         async {
> >             $output{$i} = do_some_hefty_calculation($i);
> >         }
> >     }
> >
> > somewhat clearer, but that's just a matter of taste. (With 5.10
> > presumably a 'my $_' would make $_ work too.)
> 
> In fact, I think that looks better too. I do have a few concerns:
> 
> * Having "my %output : shared" and just async without a
> Parallel::Loops reference parameter inevitably leads to global
> variables. I don't like them. One could have two different
> calculations in different sections of the code, that don't need the
> same variables "shared", so I'd prefer to have info about shared
> variables associated with a specific Parallel::Loops instance. What do
> you think?

They're not global. %output can be scoped as tightly as you like around
the async call: async takes a closure, so it will make available (either
shared or as copies) any lexicals in scope at the time. (This is why $_
won't work: it isn't a lexical.)

> * About the async {} instead of $pl->foreach: The implementation needs
> to wait for the last loop to finish, and only continue after the '}'
> after all the processes have finished. I don't know how to do that
> unless something like:
> 
> for my $i (@input) {
>     # This fires up the parallel processes
>     $pl->async {
>         $output{$i} = do_some_hefty_calculation($i);
>     }
> }
> # This waits for them all to finish before continuing.
> $pl->joinAll();

Well, again using forks, you would write

    my %output :shared;
    my @thr;

    for my $i (@input) {
        push @thr, async {
            $output{$i} = ...;
        }
    }
    $_->join for @thr;

> This syntax could easily co-exist with the $pl->foreach and $pl->while
> syntax.

Not like that it can't, since methods don't have prototypes. If you want
a method call it would have to look like

    $pl->async(sub { ... });

> I'm worried though that people will forget to call $pl-
> >joinAll()!

Stick it in DESTROY.

> I guess one could also have async return some reference to
> the actual forked process (pid comes to mind) and then $pl->join($pid)
> to wait for it to finish.
> 
> Regardless, I now think $pl->share(\%output) is a better name than $pl-
> >tieOutput(\%output)
> 
> The rest of this post is about "my %difficulties : with shared;" :-) -
> this syntax is how (threads|forks)::shared does it too. I like it, but
> don't yet understand how to implement it. Have looked at "perldoc
> attributes" and experimented a little. In fact I could get attributes
> like "Shared" (==ucfirst("shared")) to work. "xxshared" works, but
> issues a warning, but "shared" simply doesn't work (perl 5.10).

Yup. That's by design. Lowercase attributes are reserved to the core;
:shared, specifically, is handled internally as part of the threads
code, and is never seen by MODIFY_*_ATTRIBUTES. (Obviously it is
possible to hijack it, since forks manages to do so, but it can only be
done globally.)

> Also,
> I guess it isn't possible for several packages to be "listening" for
> attributes at the same time, as they'd step on each other's exports of
> e.g. sub MODIFY_SCALAR_ATTRIBUTES, wouldn't they?

That is certainly a possibility. IIRC Attribute::Handlers handles this
for you, since there's then only one MODIFY_*_ATTR sub to install.
Alternatively, keep a ref to the old sub (if there is one) and call it
if you don't see an attr you recognise.

Ben



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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 3005
***************************************


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