[28071] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9435 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 7 14:06:56 2006

Date: Fri, 7 Jul 2006 11:05: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           Fri, 7 Jul 2006     Volume: 10 Number: 9435

Today's topics:
        An issue with "Require" <bill@ts1000.us>
    Re: An issue with "Require" anno4000@radom.zrz.tu-berlin.de
    Re: An issue with "Require" <chris-usenet@roaima.co.uk>
    Re: An issue with "Require" <mumia.w.18.spam+nospam.usenet@earthlink.net>
    Re: Get the reference to an array from a function... <howachen@gmail.com>
    Re: Get the reference to an array from a function... <mritty@gmail.com>
    Re: Get the reference to an array from a function... <howachen@gmail.com>
    Re: Get the reference to an array from a function... <sherm@Sherm-Pendleys-Computer.local>
    Re: Get the reference to an array from a function... <David.Squire@no.spam.from.here.au>
    Re: Get the reference to an array from a function... <syscjm@gwu.edu>
    Re: Get the reference to an array from a function... <howachen@gmail.com>
    Re: Getting Net::SFTP handle takes FOR-FLIPPIN-EVER <rahed@e-last-minute.com>
    Re: Getting Net::SFTP handle takes FOR-FLIPPIN-EVER xhoster@gmail.com
    Re: global variables in a web service <el.dodgero@gmail.com>
    Re: global variables in a web service <el.dodgero@gmail.com>
        help with some capturing syntax <ih8spam@spamsux.org>
    Re: How to make env-vars effective on return from perl  <owen@uvsoftware.ca>
    Re: Inner classes, sort of? <ced@blv-sam-01.ca.boeing.com>
        LWP and LocalAddr <lehmannmapson@cnm.de>
    Re: LWP and LocalAddr <primzahl@gmail.com>
        Perl-1.0.0 (Otto J. Makela)
    Re: prematurely closed filehandle <please.reply@to.group>
    Re: prematurely closed filehandle <sherm@Sherm-Pendleys-Computer.local>
    Re: reading in a nested formatted data structure with q <el.dodgero@gmail.com>
    Re: reading in a nested formatted data structure with q <David.Squire@no.spam.from.here.au>
    Re: reading in a nested formatted data structure with q <el.dodgero@gmail.com>
    Re: reading in a nested formatted data structure with q <tadmc@augustmail.com>
    Re: reading in a nested formatted data structure with q <el.dodgero@gmail.com>
    Re: Symbol Table and References <bol@adv.magwien.gv.at>
    Re: Symbol Table and References <sherm@Sherm-Pendleys-Computer.local>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Jul 2006 05:18:26 -0700
From: "Bill H" <bill@ts1000.us>
Subject: An issue with "Require"
Message-Id: <1152274706.258624.172470@m79g2000cwm.googlegroups.com>

In many of my programs I use require as a sort of conditional include
to use code only when needed. I have noticed that if a "required"
program also has a "require" in it that the 2nd one does not have
access to the variables from the first, but does have access to the
variables from the main code. Is this normal or am I doing something
wrong? Here is a rough example on how I am using it:

Main program

require "global.pm"; # These are global routines used by everything

if ($var == 1)
{
require "subprog.pm";
}

Subprog.pm

$page = "index.htm";
&SendPage($page); # this is a routine in global.pm to load and display
the file named in $page

The above will work fine, but if I do this:

Subprog.pm

$page = "index.htm"
if ($page eq "index.htm")
{
require "subprog2.pm";
}

Subprog2.pm

&SendPage($page);

Subprog2.pm does not get the value for $page passed to it by
Subprog,pm.

I know this is rough but I hope it illustrates the idea. There is
probably something simple I am not doing but I have not been able to
figure out how to get a required program to allow its variables to be
accessed by another one. Am i right in assuming that code that is
included using "require" just gets "run" in the place where the require
is at (similar to using #include in C), or is it run as a form of
subroutine?

Bill H www.ts1000.us



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

Date: 7 Jul 2006 12:32:35 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: An issue with "Require"
Message-Id: <4h72j3F1pntjiU4@news.dfncis.de>

Bill H <bill@ts1000.us> wrote in comp.lang.perl.misc:
> In many of my programs I use require as a sort of conditional include
> to use code only when needed. I have noticed that if a "required"
> program also has a "require" in it that the 2nd one does not have
> access to the variables from the first, but does have access to the
> variables from the main code. Is this normal or am I doing something
> wrong? Here is a rough example on how I am using it:
> 
> Main program
> 
> require "global.pm"; # These are global routines used by everything
> 
> if ($var == 1)
> {
> require "subprog.pm";
> }
> 
> Subprog.pm

This doesn't call a program in Perl.  Under strictures it's a syntax
error, with "no strict 'subs'" it is a concatenation of two barewords.

> $page = "index.htm";
> &SendPage($page); # this is a routine in global.pm to load and display
> the file named in $page
> 
> The above will work fine, but if I do this:

Define "work".  It doesn't look like it does what it is meant to do.

[more similar code snipped]

Anno


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

Date: Fri, 7 Jul 2006 17:01:35 +0100
From: Chris Davies <chris-usenet@roaima.co.uk>
Subject: Re: An issue with "Require"
Message-Id: <v3d2o3-erm.ln1@news.roaima.co.uk>

Bill H <bill@ts1000.us> wrote:
> In many of my programs I use require as a sort of conditional include
> to use code only when needed. I have noticed that if a "required"
> program also has a "require" in it that the 2nd one does not have
> access to the variables from the first, but does have access to the
> variables from the main code. Is this normal or am I doing something
> wrong? Here is a rough example on how I am using it:

It seems to work fine here using perl 5.8.7 on GNU/Linux. Incidentally,
why are you using &SendPage() instead of SendPage()?

main.pl:
    #!/usr/bin/perl
    #
    use strict;
    use warnings;

    warn "requiring global.pm\n";
    require "global.pm";

    my $page;
    my $var = 0+ ((shift @ARGV) || 0);
    warn "var=$var\n";

    if ($var == 1) {
	warn "requiring subprog.pm\n";
	require "subprog.pm";
    }

global.pm:
    warn "running global.pm\n";

    sub SendPage
    {
	my $page = shift;
	warn ">> SendPage($page)\n";
    }

subprog.pm:
    warn "running subprog.pm\n";

    $page = "index.htm";

    warn 'calling &SendPage()', "\n";
    &SendPage($page);

    warn 'calling SendPage()', "\n";
    SendPage($page);

    if ($page eq 'index.htm') {
	warn "requiring subprog2.pm\n";
	require "subprog2.pm";
    }

subprog2.pm:
    warn "running subprog2.pm\n";

    warn 'calling &SendPage()', "\n";
    &SendPage($page);

    warn 'calling SendPage()', "\n";
    SendPage($page);


This lot produces this output, which seems to be what you're wanting:
    $ perl main.pl 1
    requiring global.pm
    running global.pm
    var=1
    requiring subprog.pm
    running subprog.pm
    calling &SendPage()
    >> SendPage(index.htm)
    calling SendPage()
    >> SendPage(index.htm)
    requiring subprog2.pm
    running subprog2.pm
    calling &SendPage()
    >> SendPage(index.htm)
    calling SendPage()
    >> SendPage(index.htm)

Chris


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

Date: Fri, 07 Jul 2006 17:33:15 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: An issue with "Require"
Message-Id: <vVwrg.4544$ye3.3499@newsread1.news.pas.earthlink.net>

Bill H wrote:
> [...] Am i right in assuming that code that is
> included using "require" just gets "run" in the place where the require
> is at (similar to using #include in C), or is it run as a form of
> subroutine?
> 

No. "Required" files are loaded and run *once*. After that, they are 
never loaded again--no matter how many times you "require" them.

If you say this:

require "myprogram.pm";
require "myprogram.pm";

"Myprogram.pm" will only be loaded and run once. The second "require" 
will essentially be ignored. "Require" is a way of telling perl you need 
the functionality of a script, and the script you require should do 
little beyond initialize itself because perl wants to be efficient by 
loading the script only once.

If you want perl to do something with a script each time it's called, 
use the "do" command:

do "myprogram.pm";
do "myprogram.pm";

Now "myprogram.pm" will be executed twice.


> Bill H www.ts1000.us
> 

perldoc -f require
perldoc -f do


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

Date: 7 Jul 2006 08:12:45 -0700
From: "howa" <howachen@gmail.com>
Subject: Re: Get the reference to an array from a function...
Message-Id: <1152285165.699132.300360@k73g2000cwa.googlegroups.com>


David Squire wrote:
> howa wrote:
> > hi,
> >
> > consider the program, why reference to an array returning from a
> > function did not work?
>
> If I were doing this, I would have the subroutine return an array ref:
>
> >
> > #------------------------------
> >
> > sub test {
> >
> > 	my @arr = ("1", "2", "3");
> > 	return @arr;
>
> return \@arr;
>
> > }
> >
> > my $size = test();
> > my @arr = test();
> >
> > my $arr_ref = \test();
>
> my $arr_ref = test();
>
> >
> > use Data::Dumper;
> > #print Dumper ( $size );
> > #print Dumper ( @arr );
> > print Dumper ( $arr_ref ); # DIDN'T WORK!
> >

yes you are right, i just wonder why syntaxically my way is not
allowed....



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

Date: 7 Jul 2006 08:22:29 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Get the reference to an array from a function...
Message-Id: <1152285749.033697.314030@s16g2000cws.googlegroups.com>

howa wrote:
> yes you are right, i just wonder why syntaxically my way is not
> allowed....

Because your way syntactically means something completely different.  A
\ applied to a list means "create a list with references to each item".
 It does not mean "create a reference to an array that contains these
items."  This has now been explained to you four different times by
three different people.  What are you not understanding about it?

Paul Lalli



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

Date: 7 Jul 2006 08:28:17 -0700
From: "howa" <howachen@gmail.com>
Subject: Re: Get the reference to an array from a function...
Message-Id: <1152286097.005713.133190@s53g2000cws.googlegroups.com>


Paul Lalli wrote:
> howa wrote:
> > yes you are right, i just wonder why syntaxically my way is not
> > allowed....
>
> Because your way syntactically means something completely different.  A
> \ applied to a list means "create a list with references to each item".
>  It does not mean "create a reference to an array that contains these
> items."  This has now been explained to you four different times by
> three different people.  What are you not understanding about it?
>
> Paul Lalli

i really don't understand their difference...i suppose they "should" be
the same

1. return \@arr; assign to $arr_ref

2. return @arr, assigh \test() to $arr_ref



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

Date: Fri, 07 Jul 2006 11:56:46 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: Get the reference to an array from a function...
Message-Id: <m28xn5pfwh.fsf@Sherm-Pendleys-Computer.local>

"howa" <howachen@gmail.com> writes:

> i really don't understand their difference...i suppose they "should" be
> the same
>
> 1. return \@arr; assign to $arr_ref
>
> 2. return @arr, assigh \test() to $arr_ref

I think I see what's tripping you up. Unlike C and similar languages, Perl
can return a list of values. So if test() returns @arr, what's on the stack
is not a single array value (an AV* internally), it's one or more scalar
values (SV*).

That's a critical difference, because \test() takes a reference to each of
the return value(s) that test() placed on the stack. So when test() places
multiple scalars on the stack, the result of \test() will be a list of scalar
references, not a single array reference.

If you want test() to return an array reference, you need to do that inside
of test() itself, like this:

    sub test {
        my @arr = ( 'foo', 'bar', 'baz' );
        return \@arr;
    }

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 07 Jul 2006 17:03:11 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Get the reference to an array from a function...
Message-Id: <e8m0k0$85c$1@gemini.csx.cam.ac.uk>

howa wrote:
> Paul Lalli wrote:
>> howa wrote:
>>> yes you are right, i just wonder why syntaxically my way is not
>>> allowed....
>> Because your way syntactically means something completely different.  A
>> \ applied to a list means "create a list with references to each item".
>>  It does not mean "create a reference to an array that contains these
>> items."  This has now been explained to you four different times by
>> three different people.  What are you not understanding about it?
>>
>> Paul Lalli
> 
> i really don't understand their difference...i suppose they "should" be
> the same

No. I suspect that your misunderstanding perhaps stems from thinking 
that a list and an array are the same thing. They are not.

> 
> 1. return \@arr; assign to $arr_ref

In this case, the function test() returns a reference to an array - a 
variable that was created in the body of test(). test() is thus a 
function that returns a scalar.

> 
> 2. return @arr,

In this case test() returns a *list*, which contains the elements that 
are stored in the array @arr, but it is not the same thing as @arr

> assigh \test() to $arr_ref

Now you have a problem. test() returns a list. You apply \ to this list, 
which returns a list of references to the elements of the list. Then you 
assign this list to the scalar $array_ref. When you assign a list to a 
scalar, you end up with the last element of the list (which is a 
reference to the last thing in the list returned by test() ). Not what 
you wanted at all.

Consider:

@foo = ('a', 'b', $bar);

$scalar1 = @foo; # $scalar1 = 3

$scalar2 = ('a', 'b', $bar); # $scalar2 = $bar

$scalar3 = \@foo; # $scalar3 holds a reference to the array @foo

$scalar4 = \('a', 'b', $bar); # $scalar4 holds a reference to $bar

Perhaps this SBCS will make it ever clearer:

----

#!/usr/bin/perl
use strict;
use warnings;

my @foo = ('a', 'fine', 'kettle', 'of', 'fish');
my ($x, $y, $z) = \('bib', 'bob', @foo);
my $q = \('bib', 'bob', @foo);

print $$x, ' ';
foreach my $element (@$z) {
	print "$element ";
}
print "\n";

print $$y, ' ';
foreach my $element (@$q) {
	print "$element ";
}

----

Output:

bib a fine kettle of fish
bob a fine kettle of fish

----


DS


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

Date: Fri, 07 Jul 2006 12:08:48 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Get the reference to an array from a function...
Message-Id: <12at1tlijh42v36@corp.supernews.com>

howa wrote:
> Paul Lalli wrote:
> 
>>howa wrote:
>>
>>>yes you are right, i just wonder why syntaxically my way is not
>>>allowed....
>>
>>Because your way syntactically means something completely different.  A
>>\ applied to a list means "create a list with references to each item".
>> It does not mean "create a reference to an array that contains these
>>items."  This has now been explained to you four different times by
>>three different people.  What are you not understanding about it?
>>
>>Paul Lalli
> 
> 
> i really don't understand their difference...i suppose they "should" be
> the same
> 
> 1. return \@arr; assign to $arr_ref
> 
> 2. return @arr, assigh \test() to $arr_ref
> 

Your basic problem is that you think you're returning an array, or a
reference to an array, and you're not.  You can't.

A subroutine returns a list.  Always, and only, a list.

You can have it return a list whose only element is a reference to
an array, which is what is done in 1.  Or you can have it return a
list that you mean to load into an array.  If you do the latter, you
can then load that list into an anonymous array and get the reference
to that array, which Aukjan described how to do upthread.  You
*can't* get a reference to the list, because there's no such thing
as a reference to a list.


CHris Mattern


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

Date: 7 Jul 2006 09:17:02 -0700
From: "howa" <howachen@gmail.com>
Subject: Re: Get the reference to an array from a function...
Message-Id: <1152289022.120760.102840@m73g2000cwd.googlegroups.com>


Chris Mattern =E5=AF=AB=E9=81=93=EF=BC=9A

> howa wrote:
> > Paul Lalli wrote:
> >
> >>howa wrote:
> >>
> >>>yes you are right, i just wonder why syntaxically my way is not
> >>>allowed....
> >>
> >>Because your way syntactically means something completely different.  A
> >>\ applied to a list means "create a list with references to each item".
> >> It does not mean "create a reference to an array that contains these
> >>items."  This has now been explained to you four different times by
> >>three different people.  What are you not understanding about it?
> >>
> >>Paul Lalli
> >
> >
> > i really don't understand their difference...i suppose they "should" be
> > the same
> >
> > 1. return \@arr; assign to $arr_ref
> >
> > 2. return @arr, assigh \test() to $arr_ref
> >
>
> Your basic problem is that you think you're returning an array, or a
> reference to an array, and you're not.  You can't.
>
> A subroutine returns a list.  Always, and only, a list.
>
> You can have it return a list whose only element is a reference to
> an array, which is what is done in 1.  Or you can have it return a
> list that you mean to load into an array.  If you do the latter, you
> can then load that list into an anonymous array and get the reference
> to that array, which Aukjan described how to do upthread.  You
> *can't* get a reference to the list, because there's no such thing
> as a reference to a list.
>
>
> CHris Mattern

hi all,

i now understand my problem as in language such as c or java, there are
no such thing as returning a list!

thanks all guy!



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

Date: Fri, 07 Jul 2006 13:30:14 +0200
From: rahed <rahed@e-last-minute.com>
Subject: Re: Getting Net::SFTP handle takes FOR-FLIPPIN-EVER
Message-Id: <uejwxejp5.fsf@e-last-minute.com>

usenet@DavidFilmer.com writes:

> I'm baffled!  It makes NO sense!  If anyone has any 'try this and see
> what happens' suggestions then I'm open to testing anything!  If anyone
> has an IBM p620 (not a 520 as I typo'd earlier) or something similar
> with AIX 5.3 then I'd appreciate it if you would try my script and tell
> me your results.

Try to install Math::BigInt::GMP if it's not already there.  That helped
when I met weird behaviour with long ssh authentication times.

-- 
Radek


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

Date: 07 Jul 2006 15:23:43 GMT
From: xhoster@gmail.com
Subject: Re: Getting Net::SFTP handle takes FOR-FLIPPIN-EVER
Message-Id: <20060707112639.318$ls@newsreader.com>

usenet@DavidFilmer.com wrote:
> Sisyphus wrote:
> > Could it be that on the fast machine those computations are being
> > performed by compiled (XS) code, but are being performed by
> > comparatively slow pure perl code on the slow machine
>
> I would agree with your idea if Net::SSH::Perl also had these delays on
> the slow machine.  That's a pure Perl implementation of ssh.  And,
> according to the docs, Net::SFTP uses Net::SSH::Perl to broker its
> connection.
>
> This problem would make a LOT more sense if Net::SSH::Perl showed
> similar delays. But I get instant connections with that module, even
> though that very same module is used to establish the Net::SFTP
> connection (and it really is - I looked at the source).

Look at the %INC to make sure it is the same path to the same module.

>
> I'm baffled!  It makes NO sense!  If anyone has any 'try this and see
> what happens' suggestions then I'm open to testing anything!

What is the CPU doing during these long pauses?  Idle or working hard?

Another thing I might do is strace it (or whatever the AIX version of that
is) and see what system calls are going on during or just before and just
after the pauses.

I looked in the Net::SFTP source put couldn't find the lines that trigger
the debug messages you showed (the ones before and after the pauses).  So
presumably they are coming from one of the modules used inside it.  It
might help if you track those message sources down.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 7 Jul 2006 03:21:07 -0700
From: "Dodger" <el.dodgero@gmail.com>
Subject: Re: global variables in a web service
Message-Id: <1152267667.187725.185690@m79g2000cwm.googlegroups.com>


Ben Morrow wrote:

> Please explain what you think a 'true' global is if a package variable
> isn't one.

While I was honestly tempted to just say 'no' and to qualify that by
stating that I don't *think* I *know*...

http://perldoc.perl.org/perlvar.html

They're in there.



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

Date: 7 Jul 2006 03:24:36 -0700
From: "Dodger" <el.dodgero@gmail.com>
Subject: Re: global variables in a web service
Message-Id: <1152267876.552841.116350@b28g2000cwb.googlegroups.com>


Though admittedly, I was more referring to the fact that registry
scripts under mod_perl are evaled and thus sort of run in a sandbox of
sorts, where to reach things in Main:: you have to do so explicitly --
and usually you don't really want to.



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

Date: Fri, 7 Jul 2006 13:15:19 -0400
From: "Matt Williamson" <ih8spam@spamsux.org>
Subject: help with some capturing syntax
Message-Id: <e8m4gg$tqu$1@nntp.aioe.org>

Given the following, is there an easy way to preface the print $status, 
"\n"; line with job started, job ended or job completion status? I've been 
reading about about capturing in the blue camel, but I can't figure out if 
or how to make it work.

foreach my $line (@content){
      if ($line =~ /(?:job started|job ended|job completion status)/i) {
        $line =~ /:(.*)$/;
        my $status = $1;
        chomp $status;
        for ($status) {
         s/^\s+//;
         s/\s+$//;
        }
        print |insert the status that matched above| $status, "\n";
     }
}

TIA

Matt 




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

Date: 7 Jul 2006 07:55:32 -0700
From: "Owen_Townsend" <owen@uvsoftware.ca>
Subject: Re: How to make env-vars effective on return from perl module subrtn ?
Message-Id: <1152284132.629799.147220@75g2000cwc.googlegroups.com>


Thanks to all above (Sinan Unar, kenslate,& anno4) for good advice.
I should have explained what I amn trying to do here.
I am converting mainframe JCL to perl scripts to run on unix/linux.
My objective was to define files for COBOL using just 1 line per file,
since there could be many files prior to each COBOL program execution.
I think now I need 2 lines per file as follows:

1.  exportfile("SORTIN","ar/sales.items");  # subrtn adds SORTIN to env
    #=====================================  # via: $ENV{$_[0]} =
"$_[1]";
2a. use Env ("SORTIN");       # suggested by kenslate & anno4 <-- IT
WORKS
    #==================
2b. $SORTIN = $ENV{SORTIN};   # OR I could use this (less overhead ?)
    #======================

I think I should probably use '2b.' above as the 2nd line,
since I assume there would be less overhead.
I am fairly new to perl & I got something useful from all who replied.
I was converting JCL to Korn shell scripts & am now changing over to
perl.
If interested please see www.uvsoftware.ca/mvsjcl.htm
and I will soon have a new doc called mvsjclperl.htm.
Thanks again to all the respondents above. 

Owen



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

Date: Fri, 7 Jul 2006 13:23:44 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Inner classes, sort of?
Message-Id: <J21BvK.1p7@news.boeing.com>

fishfry wrote:
> Sometimes you have a class with a method that returns a list of 
> identical hashes, like this ...
> 
> sub listOfItems {
>     push @items, {_name => "larry", _value => 47};
>     push @items, {_name => "curly", _value => 93};
>     push @items, {_name => "moe", _value => 12};
> 
>     return \@items;
> }
> 
> The caller is going to iterate through the list and access the data like 
> this:
> 
>    $items = listOfItems();
>    foreach $item (@$items) {
>       $name = $item->{_name};
> }
> 
> For reasons of encapsulation and object-purity and so forth, you don't 
> want the caller to do that ... you'd rather have them write
>   
>    $name = $item->name();
> 
> In order to do that, you'd have to make a separate package to define a 
> class for the name/value hash. But that's sort of an overkill ... not 
> every little hash deserves to be a class.
> 
> I'm wondering if there is some way to make the name/value hash a 
> mini-class somehow, so that you could define accessor methods, without 
> having to write a full-blown package that blesses the hash into a class.
> 
> I believe in Java this would be called an inner class. Is that right? 
> And on CPAN I've noticed a couple of contributions that say they 
> implement inner classes.
> 
> Is there a clever technique to do what I want? And/or is one of the 
> inner class CPAN packages appropriate?

If you want to restrict how the list is accessed, couldn't you just 
privatize the list and provide special accessors, eg.,


package MyClass;

  sub _listOfItems {
      push @items, {_name => "larry", _value => 47};
      push @items, {_name => "curly", _value => 93};
      push @items, {_name => "moe", _value => 12};
  }

  sub new { ...
      _listOfItems();   # populate restricted list
      ...
  }

  #
  my $index = 0;
  sub ListName {
      $index =  $index >= @items ? 0 : $index;
      return $items[$index++]->{_name};
  }
  sub ListValue {
     return unless my $name = $_[1];
     for (@items) {
         return $_->{_value} if  $_->{_name} eq $name;
    }
  }

  ...


-- 
Charles DeRykus


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

Date: Fri, 07 Jul 2006 16:55:12 +0200
From: Marten Lehmann <lehmannmapson@cnm.de>
Subject: LWP and LocalAddr
Message-Id: <4h7b1tF1pisi9U1@individual.net>

Hello,

on my server I have several IP-addresses. I need to connect to a 
firewalled service, that only allows me to connect from a certain 
IP-address. Unfortunately, the server seems to use another IP-address 
than expected when I'm conneting with LWP. How can I set the local 
ip-address which LWP shall use?

Regards
Marten


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

Date: 7 Jul 2006 10:53:21 -0700
From: "Reto" <primzahl@gmail.com>
Subject: Re: LWP and LocalAddr
Message-Id: <1152294801.054223.240890@s13g2000cwa.googlegroups.com>

Marten,
Of course you can't (or you should not) spoof your source IP address
;-)

It's a common practice to connect through a proxy host in that case.
You might ask your IT contact for a proxy host that is trusted to your
service.

You may then tell LWP to connect through the proxy host:

$ua = LWP::UserAgent->new();
$ua->proxy(['http', 'https'], 'your_trusted_proxy_host');

The easiest way would be to allow all screened IP addresses from your
source host ;-)
It depends on the kind of paranoia of the person who's in charge for
security.

hth
--Reto

Marten Lehmann wrote:
> Hello,
>
> on my server I have several IP-addresses. I need to connect to a
> firewalled service, that only allows me to connect from a certain
> IP-address. Unfortunately, the server seems to use another IP-address
> than expected when I'm conneting with LWP. How can I set the local
> ip-address which LWP shall use?
> 
> Regards
> Marten



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

Date: Fri, 07 Jul 2006 10:30:41 GMT
From: om@iki.fi (Otto J. Makela)
Subject: Perl-1.0.0
Message-Id: <m3mzbl4sha.fsf@nimrod.pool.sonera.fi>

I'm trying to install to php the Perl-1.0.0.tgz package (from
http://pecl.php.net/package/perl, enabling one to call perl libraries)
to a pre-existing Solaris system.

Unfortunately, the attempt fails in a rather dramatic way, spewing out
thousands of "relocation remains"... I'm somewhat lost on what to do
next, the documentation that came along with the Perl package is
somewhat sparse. Anyone have suggestions?

% uname -a
SunOS swen 5.8 Generic_117000-01 sun4u sparc SUNW,Sun-Fire-V240
% php --version
PHP 5.1.4 (cli) (built: Jun  5 2006 21:52:15) (DEBUG)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
% perl --version
This is perl, v5.8.0 built for sun4-solaris

Copyright 1987-2002, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

% make
/bin/bash /home/otto/Software/perl-1.0.0/libtool --mode=link gcc -DPHP_ATOM_INC -I/home/otto/Software/perl-1.0.0/include -I/home/otto/Software/perl-1.0.0/main -I/home/otto/Software/perl-1.0.0 -I/opt/php/include/php -I/opt/php/include/php/main -I/opt/php/include/php/TSRM -I/opt/php/include/php/Zend -I/opt/php/include/php/ext  -DHAVE_CONFIG_H  -g -O2 -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/opt/local/lib/perl5/5.8.0/sun4-solaris/CORE  -o perl.la -export-dynamic -avoid-version -prefer-pic -module -rpath /home/otto/Software/perl-1.0.0/modules -L/usr/local/lib -L/opt/local/lib /opt/local/lib/perl5/5.8.0/sun4-solaris/auto/DynaLoader/DynaLoader.a -L/opt/local/lib/perl5/5.8.0/sun4-solaris/CORE -lperl -lsocket -lnsl -ldl -lm -lc php_perl.lo

*** Warning: Linking the shared library perl.la against the
*** static library /opt/local/lib/perl5/5.8.0/sun4-solaris/auto/DynaLoader/DynaLoader.a is not portable!
gcc -shared -Wl,-h -Wl,perl.so -o .libs/perl.so  .libs/php_perl.o  -L/usr/local/lib -L/opt/local/lib /opt/local/lib/perl5/5.8.0/sun4-solaris/auto/DynaLoader/DynaLoader.a -L/opt/local/lib/perl5/5.8.0/sun4-solaris/CORE -lperl -lsocket -lnsl -ldl -lm -lc -lc
Text relocation remains                         referenced
    against symbol                  offset      in file
<unknown>                           0x2118      /opt/local/lib/perl5/5.8.0/sun4-solaris/CORE/libperl.a(perl.o)
<unknown>                           0x211c      /opt/local/lib/perl5/5.8.0/sun4-solaris/CORE/libperl.a(perl.o)
<unknown>                           0x2120      /opt/local/lib/perl5/5.8.0/sun4-solaris/CORE/libperl.a(perl.o)
[... several thousands of lines removed ...]
solaris/CORE/libperl.a(pp_sys.o)
__floatdidf                         0x8700      /opt/local/lib/perl5/5.8.0/sun4-solaris/CORE/libperl.a(pp_sys.o)
__floatdidf                         0x8fc8      /opt/local/lib/perl5/5.8.0/sun4-solaris/CORE/libperl.a(pp_sys.o)
ld: fatal: relocations remain against allocatable but non-writable sections
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `perl.la'

-- 
   /* * * Otto J. Makela <om@iki.fi> * * * * * * * * * * * * * * * */
  /* Phone: +358 40 765 5772, FAX: +358 42 7655772, ICBM: 60N 25E */
 /* Mail: Mechelininkatu  26 B 27,  FI-00100  Helsinki,  FINLAND */
/* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * */


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

Date: Fri, 7 Jul 2006 11:02:05 -0500
From: "Jim Moon" <please.reply@to.group>
Subject: Re: prematurely closed filehandle
Message-Id: <e8m0i0$inb$1@SonOfMaze.dpo.uab.edu>


"Tad McClellan" <tadmc@augustmail.com> wrote in message 
news:slrnea8qq2.12v.tadmc@magna.augustmail.com...
> Jim Moon <please.reply@to.group> wrote:
>> "Jim" <jmoon@uab.edu> wrote in message
>
>
> Please choose one posting address and stick with it.
>

I'll think about it.

>
>>>> This script (below) runs fine from the command line, but not in IIS,
>                                           ^^^^^^^^^^^^
>
>   perldoc -q "command line"
>
>       My CGI script runs from the command line but not the browser.  (500
>       Server Error)
>
>
>> I have determined the cause of the error.  It was a permissions issue.
>
>
> Then it was not a Perl problem.
>

Given my unfamiliarity with Perl and no knowledge of what "Bad file 
descriptor" might actually mean, I believe that you may be mistaken.

>
>> Hence "Bad file descriptor".  I rarely work with Perl,
>
>
> That is irrelevant, since you did not have a Perl problem to begin with.
>

Given my unfamiliarity with Perl and no knowledge of what "Bad file 
descriptor" might actually mean, I believe that you may be mistaken.

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




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

Date: Fri, 07 Jul 2006 12:08:16 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: prematurely closed filehandle
Message-Id: <m2wtapo0sv.fsf@Sherm-Pendleys-Computer.local>

"Jim Moon" <please.reply@to.group> writes:

> Given my unfamiliarity with Perl and no knowledge of what "Bad file 
> descriptor" might actually mean, I believe that you may be mistaken.

Given your unfamiliarity with Perl, perhaps you'd be better off taking
advice from those who *are* familiar with it, instead of arguing with
them.

Not a flame, just advice.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 7 Jul 2006 03:26:34 -0700
From: "Dodger" <el.dodgero@gmail.com>
Subject: Re: reading in a nested formatted data structure with quirks
Message-Id: <1152267994.084733.266810@75g2000cwc.googlegroups.com>


Dr.Ruud wrote:
> el.dodgero@gmail.com schreef:
>
> > However, there is someone out there who's wanting to answer this in
> > some asshole way just to get some smartass comment in for no good
> > reason than their own narcissistic joy at seeing the oh-so-clever
> > thing they typed. I know this deep in my soul because I know this is
> > usenet. So, if you are that person, just get a life instead, ok?
> 
> Pot. Kettle. Black.

Yeah, you. Fuck off.



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

Date: Fri, 07 Jul 2006 12:31:11 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: reading in a nested formatted data structure with quirks
Message-Id: <e8lgm0$333$1@gemini.csx.cam.ac.uk>

Dodger wrote:
> Dr.Ruud wrote:
>> el.dodgero@gmail.com schreef:
>>
>>> However, there is someone out there who's wanting to answer this in
>>> some asshole way just to get some smartass comment in for no good
>>> reason than their own narcissistic joy at seeing the oh-so-clever
>>> thing they typed. I know this deep in my soul because I know this is
>>> usenet. So, if you are that person, just get a life instead, ok?
>> Pot. Kettle. Black.
> 
> Yeah, you. Fuck off.
> 

*plonk*


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

Date: 7 Jul 2006 05:37:27 -0700
From: "Dodger" <el.dodgero@gmail.com>
Subject: Re: reading in a nested formatted data structure with quirks
Message-Id: <1152275847.525079.273900@m79g2000cwm.googlegroups.com>


David Squire wrote:
> *plonk*

After scanning through for other posts by David Squire, though he won't
read this, I want to thank him. By killfiling me, he'll never reply to
one of my posts. Therefore, I wont ever have to get my hopes up that
someone has posted an answer when it was just him.



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

Date: Fri, 7 Jul 2006 08:10:26 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: reading in a nested formatted data structure with quirks
Message-Id: <slrneasna2.kva.tadmc@magna.augustmail.com>

Dodger <el.dodgero@gmail.com> wrote:
> 
> Dr.Ruud wrote:
>> el.dodgero@gmail.com schreef:
>>
>> > However, there is someone out there who's wanting to answer this in
>> > some asshole way just to get some smartass comment in for no good
>> > reason than their own narcissistic joy at seeing the oh-so-clever
>> > thing they typed. I know this deep in my soul because I know this is
>> > usenet. So, if you are that person, just get a life instead, ok?
>> 
>> Pot. Kettle. Black.


At this point it was merely speculation that you are an ass.


> Yeah, you. Fuck off.


It is no longer just speculation.

Thanks for providing the confirmation.


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


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

Date: 7 Jul 2006 07:51:56 -0700
From: "Dodger" <el.dodgero@gmail.com>
Subject: Re: reading in a nested formatted data structure with quirks
Message-Id: <1152283916.479122.279600@p79g2000cwp.googlegroups.com>


Tad McClellan wrote:

> It is no longer just speculation.
> Thanks for providing the confirmation.

Absolutely. I'm totally not someone who needs to waste time on little
trolls who think delivering 'clever' little smartarse responses are the
best thing to do with it. I didn't think I'd given that impression in
the first place.

I'm perfectly happy to help anyone else and share. However, pointless
little snarks simply crowd my inbox (and those of anyone else watching
a given thread) with the mistaken impression that someone had something
worthwhile to say.

Of course, it was disappointing to have someone almost immediately
respond with one to an expression that I'd rather not deal with them.
I'm using Google groups, due to a lack of a proper usenet server
(thanks to Comcast). I don't have a killfile, and honestly the little
twit armies who think it's oh-so-important that they post their snarky
nonsense for everyone to see are simply making places like usenet less
useful for people who really want to share knowledge.

Or did you mean something else?



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

Date: Fri, 7 Jul 2006 18:22:56 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: Symbol Table and References
Message-Id: <1152289379.718341@proxy.dienste.wien.at>

Anno:

> That much research ought to be conserved somewhere better than in a
> random Usenet posting.  If you were to rewrite it as a tutorial in
> pod format, I bet p5p would take it aboard as perlglobtut or something.

First, many thanks - glad to read this.

Well, I had this idea already some time ago and wrote a litte document
for our Perl people here - but in German. I'd have to complete it and to
translate it into English and into pod, and I'm afraid this is a relatively
time-consuming task...

I'm not sure whether this will still make sense, with Perl 6  appearing
on the horizon...and thinking of Parrot, I'd assume that a description
about stashes and typeglobs would of interest for Perl 5 only, wouldn't
it?

Folks, what about this? If there are interests, perhaps I'll change my
opinion and start with that project...

Greetings, Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at




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

Date: Fri, 07 Jul 2006 12:29:42 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: Symbol Table and References
Message-Id: <m2slldnzt5.fsf@Sherm-Pendleys-Computer.local>

"Ferry Bolhar" <bol@adv.magwien.gv.at> writes:

> Anno:
>
>> That much research ought to be conserved somewhere better than in a
>> random Usenet posting.  If you were to rewrite it as a tutorial in
>> pod format, I bet p5p would take it aboard as perlglobtut or something.
>
> First, many thanks - glad to read this.
>
> Well, I had this idea already some time ago and wrote a litte document
> for our Perl people here - but in German. I'd have to complete it and to
> translate it into English and into pod, and I'm afraid this is a relatively
> time-consuming task...

You could post the original German-language POD to p5p, and ask for help
with the translation.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

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


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