[22715] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4936 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 5 11:08:45 2003

Date: Mon, 5 May 2003 08:05:08 -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           Mon, 5 May 2003     Volume: 10 Number: 4936

Today's topics:
    Re: Adding time in perl <Steffen.Beyer@de.bosch.com>
    Re: boolean operations on hash values? (Anno Siegel)
    Re: Calling subs using '&' form <REMOVEsdnCAPS@comcast.net>
    Re: Calling subs using '&' form (Sara)
    Re: Calling subs using '&' form <stevenm@bogus.blackwater-pacific.com>
    Re: Compare Lists - built in Function? (James E Keenan)
    Re: creating class hierarchies with h2xs (Anno Siegel)
    Re: dereference of hash-slices (Anno Siegel)
    Re: dereference of hash-slices <occitan@esperanto.org>
    Re: dereference of hash-slices <pilsl_usenet@goldfisch.at>
    Re: Ideas where to find tutorials for coding traffic tr (James E Keenan)
    Re: Is there any way to debug PerlScript used in ASP? <nospam@raytheon.com>
        need help "cross-building"perl 5.8.0 <petem@fl.net.au>
    Re: Passing hash and string to subroutine <barryk2@SPAM-KILLER.mts.net>
    Re: Passing hash and string to subroutine (Sara)
    Re: Passing hash and string to subroutine <josef.moellers@fujitsu-siemens.com>
    Re: Perl Socket Question <Thomas.Kratz@lrp.de.nospam>
    Re: Sort array of numbers <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 5 May 2003 15:05:21 +0200
From: "Steffen Beyer" <Steffen.Beyer@de.bosch.com>
Subject: Re: Adding time in perl
Message-Id: <b95nin$cot$1@ns2.fe.internet.bosch.com>

> You want Date::Calc, which is an XS module, or Date::Manip if you need
> a pure-Perl module (Date::Calc is much faster, though).

There's also a pure-Perl version of a reasonably recent version (4.3)
of Date::Calc called Date::Pcalc.

See http://catcode.com/date/pcalc.html
or  http://www.engelschall.com/u/sb/download/
or  http://www.perl.com/CPAN/authors/id/S/ST/STBEY/

Good luck!

Cheers,
Steffen



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

Date: 5 May 2003 10:16:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: boolean operations on hash values?
Message-Id: <b95dls$2av$3@mamenchi.zrz.TU-Berlin.DE>

Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach henq:
> 
> > I hav problems undestanding how I should test for true/false values that are
> > stored as hash values. The following piece of code should return true if
> > login is not required or is required and the logged_in flag is valid:
> > 
> >    my $r = not $self->{logged_in_required} || \
                                                  ^

The backslash is wrong.

> >             $self->{logged_in_required} && $self->{session}{logged_in};
> 
> The above has the wrong precedence. It gets parsed as
> 
>     not( $self->{logged_in_required} || ... );
> 
> I assume you want
> 
>     my $r = ! $self->{logged_in_required 
>             or
>             $self->{logged_in_required} && $self->{session}{logged_in};
> 
> !, && and || bind more tightly than their wordy counterparts 'not',
> 'and' and 'or'. You can always use parens to disambiguate such
> expressions when in doubt.

There's also the spurious backslash at the end of the first line.  In
Perl you don't have to "escape line feeds" like in shells.  The backslash
will take a reference of what follows.  You don't want that.

Anno



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

Date: Mon, 05 May 2003 05:17:23 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Calling subs using '&' form
Message-Id: <Xns93723FFF34117sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Steve May <stevenm@bogus.blackwater-pacific.com> wrote in
news:b94gri$ebk$1@quark.scn.rain.com:

[OP's post rearranged a bit]
> So, probably someone has written a clear and succinct explanation
that 
> I've missed or there is a page somewhere that I could be pointed to

> which would help me clarify my thinking on this?
> 
> Because at this point I see no good reason to change my habits and
at 
> least one good one to continue as always...

Using & to invoke subroutines is not _inherently_ bad, but it has two
ramifications which will sometimes reach up and bite you in the ass. 
On the whole, it's nearly always better to omit the &.

The first thing about & is that it suppresses the processing of the
subroutine's prototypes.  This is a minor issue, as most subs don't
have prototypes.  But on the other hand, if a sub has a prototype,
it's probably there for a reason.

The other thing is more important.  If you call a subroutine with an
& and with no parentheses, it will (for annoying historic reasons)
inherit the current subroutine's @_ (argument list).  This can be a
source of bugs.

Take your example:

> # START FILE test_sub.pl (main executable)
> 
> #! /usr/bin/perl -w
> use strict;
> 
> my $val = 'Hello World';
> require "./test_sub_lib.pl" or die "can't require file: $!\n";
> 
> print_string( do_something );
> 
> exit 0;
> 
> sub print_string{
>      my $string = shift;
>      print $string;
> }
> 
> # END FILE
> 
> # START FILE test_sub_lib.pl
> 
> sub do_something{  return 'Hello World'; }
> 
> 1;
> # END FILE
> 
> 
> # at the command line:
> 
>]# ./test_sub.pl
> Bareword "do_something" not allowed while "strict subs" in use
<snip>
> Execution of ./test_sub.pl aborted due to compilation errors.

You are correct in that "print_string(do_something)" is an error and
that "print_string(&do_something)" does what you want.  But let's
tweak the example a bit:

    sub do_something {
        my $cheese = shift;     # note: modifies @_
        if ($cheese eq 'roquefort') {return "Yummmm!"}
        return "Ick.";
    }

    sub list_cheeses {
        my $first_cheese = shift;
        my $x = &do_something;
        my $second_cheese = shift;  # Wrong!  Will get the third
cheese.
    }

    &list_cheeses(qw/cheddar muenster provolone/);


The reason your test code broke is that, at the point it was
compiling the "print_string(do_something)" line, it did not know that
do_something was a subroutine.  In Perl, you may use strings without
quotes. The line you wrote was compiled as
"print_string('do_something')".  However, "use strict" forbids the
use of bareword strings, which is why your script got a compile-time
error.  The solution is to write

    print_string(do_something());

so that the compiler can tell it's a subroutine call.  Either that,
or define the do_something sub before you get to to the print_string
line.

Hope this helps.
- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+tjotY96i4h5M0egRAkcsAKCi+nNi29bzCRbPWJ4Masw/2tEweQCdFYJJ
YhnNG91eZbq0/8DK/o+rXOE=
=d8sY
-----END PGP SIGNATURE-----


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

Date: 5 May 2003 06:22:09 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Calling subs using '&' form
Message-Id: <776e0325.0305050522.69c73847@posting.google.com>

"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message news:<Xns93723FFF34117sdn.comcast@216.166.71.239>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> 
> Steve May <stevenm@bogus.blackwater-pacific.com> wrote in
> news:b94gri$ebk$1@quark.scn.rain.com:
> 
 .
 . 
 .
> The other thing is more important.  If you call a subroutine with an
> & and with no parentheses, it will (for annoying historic reasons)
> inherit the current subroutine's @_ (argument list).  This can be a
> source of bugs.
> 

Hmm I didn't know that- and actually that could be handy sometimes.

The only time I ever felt I HAD to use &sub was when I was writing a
compiler, and I was using production calls as args like

  multi(\&token);

where token was of course a sub, or

 @l=@{&$subx(\@l,1)}

where $subx contains the name of a sub I wanted to call.

But these kinds of things don't come up often. However, my experience
with the compiler showed me that sometimes the '&' is the only way to
do what I wanted to do.

Cheers,
Gx


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

Date: Mon, 05 May 2003 07:55:15 -0700
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Re: Calling subs using '&' form
Message-Id: <b95tln$6ag$1@quark.scn.rain.com>

Eric J. Roode wrote:
<snip>

>>least one good one to continue as always...
> 
> 
> Using & to invoke subroutines is not _inherently_ bad, but it has two
> ramifications which will sometimes reach up and bite you in the ass. 
> On the whole, it's nearly always better to omit the &.
> 
> The first thing about & is that it suppresses the processing of the
> subroutine's prototypes.  This is a minor issue, as most subs don't
> have prototypes.  But on the other hand, if a sub has a prototype,
> it's probably there for a reason.
> 

True, but I've never felt compelled to use prototypes (maybe I don't
know what I'm missing:-) and so can't get too excited about this one
at this time....


> The other thing is more important.  If you call a subroutine with an
> & and with no parentheses, it will (for annoying historic reasons)
> inherit the current subroutine's @_ (argument list).  This can be a
> source of bugs.

<snip>

> You are correct in that "print_string(do_something)" is an error and
> that "print_string(&do_something)" does what you want.  But let's
> tweak the example a bit:
> 
>     sub do_something {
>         my $cheese = shift;     # note: modifies @_
>         if ($cheese eq 'roquefort') {return "Yummmm!"}
>         return "Ick.";
>     }
> 
>     sub list_cheeses {
>         my $first_cheese = shift;
>         my $x = &do_something;
>         my $second_cheese = shift;  # Wrong!  Will get the third
> cheese.
>     }
> 
>     &list_cheeses(qw/cheddar muenster provolone/);
> 

I see your point.  Hmmm.....   I've never ran into this even though
I always use '&'.  Of course I've also made it a habit to always 
immediately assign ALL values in @_ to something as soon as I enter
the sub.  Seems to help me keep things straight when I come back 6
months later. :-)

sub list_cheeses {
     my $first_cheese = shift;
     my $second_cheese = shift;
     my $x = &do_something;
}

> 
> The reason your test code broke is that, at the point it was
> compiling the "print_string(do_something)" line, it did not know that
> do_something was a subroutine.  In Perl, you may use strings without
> quotes. The line you wrote was compiled as
> "print_string('do_something')".  However, "use strict" forbids the
> use of bareword strings, which is why your script got a compile-time
> error.  

AHA! Context!


> The solution is to write
> 
>     print_string(do_something());
> 
> so that the compiler can tell it's a subroutine call.  Either that,
> or define the do_something sub before you get to to the print_string
> line.
> 

Though WHY does it not know it is a subroutine?

The compiler HAD to see the sub when the required library was
loaded.

sub do_something{  return "Hello World";}

print_string( do_something );

sub print_string {
     my $string = shift;
     print $string;
}

As you say, if defined before the call, it works, but I'm not
real certain why requiring an external file does not define
the subroutines contained therin...

I'm tempted to regard this as a bug, or at least a bit odd.:-)

> Hope this helps.

Yes that did.  It looks like I don't need to worry about it too much
based on my programming style or lack thereof.

Given that my total line count of code in currently maintained programs
is in excess of 100,000 lines, I think I'll let sleeping dogs lie....

Thanks!

s.




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

Date: 5 May 2003 05:50:35 -0700
From: jkeen@concentric.net (James E Keenan)
Subject: Re: Compare Lists - built in Function?
Message-Id: <b955da04.0305050450.a7adf93@posting.google.com>

"news.chello.at" <aheissen@a1.net> wrote in message news:<0GTsa.11606$e8.141057@news.chello.at>...
> Is there any builtin function which does a compare of two sorted lists? I
> only need true for 2 lists with the same values.
> 
> thanx

When you compare two lists, it's important to be specific about what
you mean by having the "same" values.  The code you write will be
correct only insofar as it accurately reflects your understanding of
"same."  Consider these 4 examples:

1.  Each item in the list A occurs with the exact same spelling
(including whitespace) and in the exact same position in list B.

2.  All items in list A, when joined with whitespace, form a string
which is identical to the string similarly formed from list B.

3.  Each item in list A is found in list B exactly the same number of
times it is found in A -- and vice versa -- but the sequence of items
is unimportant.

4.  Each item in list A is found in list B -- and vice versa -- but
the frequency and sequence of items is unimportant.  (This is the
approach taken by List::Compare.)

Each case has practical applications, so the code which is correct is
that which solves your production problem.


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

Date: 5 May 2003 11:51:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: creating class hierarchies with h2xs
Message-Id: <b95j89$2av$4@mamenchi.zrz.TU-Berlin.DE>

Jason Parker-Burlingham  <jasonp@uq.net.au> wrote in comp.lang.perl.misc:
> I'm about to start work on a hierarchy of classes about three or four
> levels deep.  The code, when completed, will need to be distributed to
> a number of different systems so I'm planning to use h2xs to handle
> the Makefile.PL and such.
> 
> My question---such as it is---is about how to go about creating child
> and grandchild classes once I've started work.  I see that perlnewmod
> recommends running
> 
>         h2xs -AX -n Net::Acme
> 
> so my question is what does one do when I want to create Net::Coyote
> and Net::Anvil?  Should h2xs be run again from the same directory used
> to create Net::Acme?  Should I just edit the files created by h2xs for
> Net::Acme?  What about when I need Net::Anvil::Heavy?
> 
> My current guess is that I could just run h2xs over and over but that
> looks as though it will lead to lots of duplicated (or at least
> disparate) Changes files, READMEs, etc, which might *not* be the end
> of the world, but I'm not sure it's desirable either.

Quite.  Try ExtUtils::ModuleMaker from CPAN, which allows to create
the structure for more than on module in one go.

You still have to have your modules planned out from the start.  If
you later think you need another module in your project and run
ModuleMaker again, it will overwrite your work up to then, no questions
asked.

Anno


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

Date: 5 May 2003 10:06:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: dereference of hash-slices
Message-Id: <b95d2t$2av$2@mamenchi.zrz.TU-Berlin.DE>

peter pilsl  <pilsl_usenet@goldfisch.at> wrote in comp.lang.perl.misc:
> 
> 
> Assuming I've a anonymous hash and an anonymous array and I'd like to 
> evaluate the correspsonding hash-slice. By now I need to do a lot of nasty 
> explicit dereferences and like to know if there is a more elegant way, 
> espcially as I'm used to the arrow-operator for accessing anyomous 
> structures.

The arrow works only if the result is a scalar.  Slices don't have
a corresponding shortcut.

> example what I do now: 
> 
> $a={1=>1,2=>4,3=>9,4=>16};
> $b={a=>1,b=>2,c=>3,d=>4};
> $c=['a','b','d'];
> print join("-",@{$a}{@{$b}{@{$c}}}),"\n"
> 
> =>
> 1-4-16

The slices must basilally be written the way you do.  You can take
advantage of precedence and leave off a few pairs of "{}":
"@$a{@$b{@$c}}" is the same as "@{$a}{@{$b}{@{$c}}}", and in this
situation it's probably best to get rid of braces if possible.

Anno


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

Date: Mon, 5 May 2003 16:02:23 +0200
From: Daniel Pfeiffer <occitan@esperanto.org>
To: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: dereference of hash-slices
Message-Id: <20030505160223.0c59fd2a.occitan@esperanto.org>

peter pilsl <pilsl_usenet@goldfisch.at> skribis:
> Assuming I've a anonymous hash and an anonymous array and I'd like to=20
> evaluate the correspsonding hash-slice. By now I need to do a lot of nast=
y=20
> explicit dereferences and like to know if there is a more elegant way,=20
> espcially as I'm used to the arrow-operator for accessing anyomous=20
> structures.
>=20
> example what I do now:=20
>=20
> $a=3D{1=3D>1,2=3D>4,3=3D>9,4=3D>16};
> $b=3D{a=3D>1,b=3D>2,c=3D>3,d=3D>4};
> $c=3D['a','b','d'];
> print join("-",@{$a}{@{$b}{@{$c}}}),"\n"

Why does everything have to be anonymous?  Doesn't this make your life much=
 simpler:

%a=3D(1=3D>1,2=3D>4,3=3D>9,4=3D>16);
%b=3D(a=3D>1,b=3D>2,c=3D>3,d=3D>4);
@c=3Dqw(a b d);
print join("-",@a{@b{@c}}),"\n"

--=20
coralament / best Gr=F6tens / liebe Gr=FC=DFe / best regards / elkorajn sal=
utojn
Daniel Pfeiffer

-- GPL 3: take the wind out of Palladium's sails! --
 ------
  -- My other stuff here too, sawfish, make.pl...: --
   ------
    -- http://dapfy.bei.t-online.de/ --


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

Date: Mon, 5 May 2003 16:12:18 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: dereference of hash-slices
Message-Id: <3eb671a2$1@e-post.inode.at>

Daniel Pfeiffer wrote:

>
> Why does everything have to be anonymous?  Doesn't this make your life
> much simpler:
> 
> %a=(1=>1,2=>4,3=>9,4=>16);
> %b=(a=>1,b=>2,c=>3,d=>4);
> @c=qw(a b d);
> print join("-",@a{@b{@c}}),"\n"
> 

Well - this would be true for this small example. In many applications 
there are much bigger datastructures where the lists and hashes in the 
above example are embedded somewhere. Assigning variables to each of this 
list would be very irritating.

I wrote the original posting to simplify the following statement I wrote 
this morning:

$ptr->is_allowed($action,@{$ptr->{h}}{@{$ptr->{redactional}}{('entry_uid','entry_gid','entry_mod')}})

thnx,
peter

-- 
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at



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

Date: 5 May 2003 05:55:38 -0700
From: jkeen@concentric.net (James E Keenan)
Subject: Re: Ideas where to find tutorials for coding traffic trade scripts in Perl ?
Message-Id: <b955da04.0305050455.73523f51@posting.google.com>

"hobgoblin" <webmasterhcmf@yahoo.com> wrote in message news:<Yskta.42478$xw4.23644@nwrdny01.gnilink.net>...
> Thanks for taking the time to respond.
> 
> We just wanted to be directed to relevant tutorials or resources in regards
> to coding "traffic trading" scripts with Perl in a broader sense.
> 
> Specifically, we're interested in functions such as "updating stats in real
> time", "skimming", "productivity tracking", and adjustable referrer "in/out
> ratio's". We don't necessarily want to add these features, but we are
> curious enough to want to take a look at how they work.
> 
A search for "traffic trading" turns up 223 hits at search.cpan.org


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

Date: Mon, 05 May 2003 09:07:58 -0500
From: Chris Olive <nospam@raytheon.com>
Subject: Re: Is there any way to debug PerlScript used in ASP?
Message-Id: <Xeuta.3194$c6.2989@bos-service2.ext.raytheon.com>

Andrew wrote:
> Thanks Rudolf, but I still hope there's a debugger...
> 
> Does any one know if InterDev or Microsoft Script Debuger would
> work with PerlScript ?
> 
> Or maybe there is any other debugger that can debug PerlScript in
> ASP ?
> 
> In general ASP+PerlScript is a good combination for IIS,much better than PHP (performance & security ), it's a pitty everyone has
> ignored it.
> Perl is here for many years, and still is the best language ever for web
> tasks.
>  

I agree with your sentiments on the use (or lack thereof) of PerlScript 
in Classic ASP.  PerlScript ASP totally blows the doors off of other 
Classic ASP scripting engines (eg. VBScript and JScript).  Very powerful.

In general, I despise the ASP Script Debugger, so I've never tried it 
using PerlScript, but I don't believe it works anyway.  As already 
posted by others here, writing debug lines (via $Response->Write()) is 
probably your best bet.  One subroutine that I wrote that I find handy is:

sub Debug { foreach (@_) { $Response->Write( "<!-- $_ -->\n" ) } }

Then you can:

Debug( "Line 1", "Line 2", "Line 3" );
Debug( @arrayOfLines );

This will place debug statements in your HTML output, but it's not 
intrusive and does not display on client browsers because it's HTML 
commented.  But to see your debug output, you can "View Source" and see 
your debug output as well as see exactly in your Response output stream 
WHERE the debug statements where executed.

This is the best I can offer, and I consider myself a pretty heavy 
Classic ASP/PerlScript developer.

Chris
-----
Chris Olive
Systems Consultant
Raytheon Technical Services Corporation
Indianapolis, IN

email: olivec(AT)indy(DOT)raytheon(DOT)com



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

Date: Mon, 5 May 2003 20:13:07 +1000
From: "Peter J. MASON" <petem@fl.net.au>
Subject: need help "cross-building"perl 5.8.0
Message-Id: <3eb636e6@fl.net.au>

Hi group, I'm not a perl programmer but I've taken on the task of building
perl to run on an SL-5500 PDA. It's a linux/SA1110 based machine. I'm
getting there but my lack of perl familiarity is getting to be a problem,
and I'd would appreciate some help on the detail.

By 'hook and by crook' the make seems to have finally succeeded. The "make
test" works for 55% of the test, and those that fail are often failing
because of some *.pm file being found in @INC which is ../lib.

Here's a section of 'make test' output ...

ext/Fcntl/t/fcntl....................Can't locate Fcntl.pm in @INC (@INC
contains: ../lib) at ../ext/Fcntl/t/fcntl.t line 13.

BEGIN failed--compilation aborted at ../ext/Fcntl/t/fcntl.t line 13.

FAILED at test 0

ext/Fcntl/t/syslfs...................skipping test on this platform

ext/File/Glob/t/basic................Can't locate File/Glob.pm in @INC

(@INC contains: . ../lib) at ../ext/File/Glob/t/basic.t line 21.

but, look ...

[petem@petem1 perl-5.8.0]$ find . -name Fcntl.pm -print ./ext/Fcntl/Fcntl.pm

and ...

[petem@petem1 perl-5.8.0]$ find . -name Glob.pm -print
 ./ext/File/Glob/Glob.pm ./lib/File/Glob.pm

Does this suggest some process not having happened? Or can you suggest

any other hints?

Perhaps directory contents might help? I have this, for example ...

[petem@petem1 ext]$ cd File

[petem@petem1 File]$ ls

CVS Glob

[petem@petem1 File]$ ls -l Glob

total 148

-rw-rw-r-- 1 petem petem 32984 Apr 26 15:09 bsd_glob.c

-rw-rw-r-- 1 petem petem 3818 Apr 26 15:09 bsd_glob.h

-rw-rw-r-- 1 petem petem 9084 May 5 13:56 bsd_glob.o

-rw-rw-r-- 1 petem petem 1893 Apr 26 15:09 Changes

-rw-r--r-- 1 petem petem 6306 May 2 15:40 const-c.inc

-rw-r--r-- 1 petem petem 2654 May 2 15:40 const-xs.inc

drwxrwxr-x 2 petem petem 4096 May 1 23:23 CVS

-rw-r--r-- 1 petem petem 0 May 5 13:56 Glob.bs

-rw-rw-r-- 1 petem petem 5147 May 2 17:27 Glob.c

-rw-rw-r-- 1 petem petem 7428 May 5 13:56 Glob.o

-rw-rw-r-- 1 petem petem 14418 Apr 26 15:09 Glob.pm

-rw-rw-r-- 1 petem petem 1180 Apr 26 15:09 Glob.xs

-rw-r--r-- 1 petem petem 22743 May 5 11:37 Makefile

-rw-rw-r-- 1 petem petem 1052 Apr 26 15:09 Makefile.PL

-rw-rw-r-- 1 petem petem 0 May 2 17:27 pm_to_blib

drwxrwxr-x 3 petem petem 4096 Apr 26 15:11 t

-rw-rw-r-- 1 petem petem 882 Apr 26 15:09 TODO



And I'm not expecting the pm_to_blib and Glob.bs files to be empty. Should
they be?

Could that be part of my problem? I'm guessing that this happens with
Mkbootstrap?

Anyway, I'd appreciate any help from the experts.

Thanks.




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

Date: Mon, 5 May 2003 08:16:17 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Passing hash and string to subroutine
Message-Id: <MPG.192020182bcfaa4e9897bb@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <3EB5B187.3040501@hotmail.com>, Rich Pasco 
(richp1234@hotmail.com) says...
> Is it possible in Perl to pass two parameters to a subroutine,
> one of which is a hash and one of which is a string?  It sounds
> easy enough but the example below doesn't work (it doesn't print
> anything for $body):
> 
> #pass both a hash and a string
> my (%criterion, $text);
> $criterion{'a'} = 'AAA';
> $criterion{'b'} = 'BBB';
> $text = 'The Quick Brown Fox';
> process_events(%criterion,$text);
> exit;
> 
> sub process_events {
>   my(%criteria, $body) = @_;
>   print "a=$criteria{'a'}\n";
>   print "b=$criteria{'b'}\n";
>   print "\nbody = $body\n";
> }

When you pass an array or hash as a parameter in a subroutine call, its 
values are "unpacked" and placed into one long parameter list which is 
received by the called subroutine. Therefor the called subroutine has no 
way of knowing how to associate the values with arrays and hashes. What 
you need to do is pass references for arrays and hashes.


sub process_events {
    my ( $criteria_ref , $body ) = @_;
    print "a = ",$$criteria_ref{"a"},"\n";
    print "b = ",$$criteria_ref{"b"},"\n";
    print "\nbody = $body\n";
}

my (%criterion, $text);
$criterion{'a'} = 'AAA';
$criterion{'b'} = 'BBB';
$text = 'The Quick Brown Fox';
process_events(\%criterion,$text);
exit;

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: 5 May 2003 06:27:40 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Passing hash and string to subroutine
Message-Id: <776e0325.0305050527.11f7231f@posting.google.com>

Rich Pasco <richp1234@hotmail.com> wrote in message news:<3EB5B187.3040501@hotmail.com>...
> Is it possible in Perl to pass two parameters to a subroutine,
> one of which is a hash and one of which is a string?  It sounds
> easy enough but the example below doesn't work (it doesn't print
> anything for $body):
> 
> #pass both a hash and a string
> my (%criterion, $text);
> $criterion{'a'} = 'AAA';
> $criterion{'b'} = 'BBB';
> $text = 'The Quick Brown Fox';
> process_events(%criterion,$text);
> exit;
> 
> sub process_events {
>   my(%criteria, $body) = @_;
>   print "a=$criteria{'a'}\n";
>   print "b=$criteria{'b'}\n";
>   print "\nbody = $body\n";
> }


Rich:

Since its common to have to pass non-scalars to subroutines, consider
just working with them through a reference to an anonymous hash all
the time.
It make life easier:

my $criterion = {};
my $text;
$criterion->{a} = 'AAA';
$criterion->{b} = 'BBB';
$text = 'The Quick Brown Fox';
 process_events($criterion,$text);
exit;

sub process_events {
  my($criteria, $body) = @_;
  print "a=$criteria->{a}\n";
  print "b=$criteria->{b}\n";
  print "\nbody = $body\n";
 }


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

Date: Mon, 05 May 2003 15:52:43 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Passing hash and string to subroutine
Message-Id: <3EB66CAB.A5E0E13@fujitsu-siemens.com>

Barry Kimelman wrote:

> When you pass an array or hash as a parameter in a subroutine call, its=

> values are "unpacked" and placed into one long parameter list which is
> received by the called subroutine. Therefor the called subroutine has n=
o
> way of knowing how to associate the values with arrays and hashes. What=

> you need to do is pass references for arrays and hashes.

TMTOWTDI, how about passing the hash/array as the last argument?

process_events($text,%criterion);

sub process_events {
   my $body =3D shift;
   my %criteria =3D @_;
=2E..
}

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Mon, 5 May 2003 15:20:13 +0200
From: "Thomas Kratz" <Thomas.Kratz@lrp.de.nospam>
Subject: Re: Perl Socket Question
Message-Id: <3eb66cfd.0@juno.wiesbaden.netsurf.de>

DQoiSnVzdGluIiA8aW1hcmluZWp0QGhvdG1haWwuY29tPiB3cm90ZS4uLg0KDQo+IEhpLA0KPiAN
Cj4gSSBoYXZlIHRoZSBmb2xsb3dpbmcgY29kZToNCj4gDQo+IG15ICR3Yl9zZXJ2ZXIgPSBJTzo6
RG9ja2V0OjpJTkVULT5uZXcoTG9jYWxQb3J0ID0+ICR3Yl9zZXJ2ZXJfcG9ydCwNCj4gUHJvdG8g
PT4gInRjcCIsDQo+IExpc3RlbiA9PiAyNTAgKSBvciBkaWUgImVycm9yIjsNCj4gDQo+IG15ICRs
Y19zZXJ2ZXIgPSBJTzo6U29ja2V0OjpJTkVULT5uZXcoTG9jYWxQb3J0ID0+ICRsY19zZXJ2ZXJf
cG9ydCwNCj4gUHJvdG8gPT4gInVkcCIpIG9yIGRpZSAiRXJyb3IgVURQIjsNCj4gDQo+IFRoaXMg
Y29kZSB3b3JrcywgaG93ZXZlciBpZiBJIGluc2VydCBhIGxpc3RlbiA9PiAxMCBpbnRvIHRoZSBV
RFAgc2VydmVyIGNvbm5lY3Rpb24gSSBnZXQNCj4gYW4gZXJyb3IuICBBbnlvbmUgZXhwbGFpbiB3
aHkgdGhpcyBpcz8NCg0KSWYgeW91IHdhbnQgYSB0aG9yb3VnaCBleHBsYW5hdGlvbiwgcGxlYXNl
IGxvb2t1cCBhIHJlZmVyZW5jZSBvciB0dXRvcmlhbCBhYm91dCBzb2NrZXQgcHJvZ3JhbW1pbmcg
aW4gZ2VuZXJhbC4gVGhpcyBpcyAqbm90KiBQZXJsIHNwZWNpZmljLiBUcnkgZ29vZ2xpbmcuDQoN
CkhhdmluZyBzYWlkIHRoaXMsIGEgc2hvcnQgaGludDoNCg0KVURQIGlzIGEgY29ubmVjdGlvbmxl
c3MgcHJvdG9jb2wuIFRoZSBsaXN0ZW4gZnVuY3Rpb24gYXBwbGllcyBvbmx5IHRvIHNvY2tldHMg
dGhhdCBzdXBwb3J0IGNvbm5lY3Rpb25zLCBpbiBvdGhlciB3b3JkcywgdGhvc2Ugb2YgdHlwZSBT
T0NLX1NUUkVBTS4NCg0KQXMgdGhlIGRvY3VtZW50YXRpb24gZm9yIElPOjpTb2NrZXQ6OklORVQg
c3BlY2lmaWVzOg0KDQogIElmIExpc3RlbiBpcyBkZWZpbmVkIHRoZW4gYSBsaXN0ZW4gc29ja2V0
IGlzIGNyZWF0ZWQsIGVsc2UgaWYgdGhlIHNvY2tldCB0eXBlLA0KICB3aGljaCBpcyBkZXJpdmVk
IGZyb20gdGhlIHByb3RvY29sLCBpcyBTT0NLX1NUUkVBTSB0aGVuIGNvbm5lY3QoKSBpcyBjYWxs
ZWQuDQoNCiAgRm9yIFVEUCB0aGUgc29ja2V0IHR5cGUgaXMgU09DS19ER1JBTS4gSW4gdGhpcyBj
YXNlIG5laXRoZXIgbGlzdGVuKCkgbm9yDQogIGNvbm5lY3QoKSBhcmUgY2FsbGVkLiBUaGUgc29j
a2V0IGlzIHNpbXBseSBib3VuZCB0byB0aGUgc29ja2V0IHdpdGggYmluZCgpLg0KDQpTbyBzcGVj
aWZ5aW5nIHRoZSBMaXN0ZW4gcGFyYW1ldGVyIHdpdGggdGhlIFVEUCBwcm90b2NvbCBtYWtlcyBu
byBzZW5zZS4gUGVyaGFwcyB0aGUgTW9kdWxlIHNob3VsZCBjaGVjayBmb3IgdGhhdCBhbmQgY3Jv
YWssIGJ1dCBhdm9pZGluZyB0aGlzIGlzIGVhc3k6IGRvbid0IGRvIGl0IDstKQ0KDQpUaG9tYXMN
Cg==



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

Date: Mon, 5 May 2003 15:15:51 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Sort array of numbers
Message-Id: <Pine.LNX.4.53.0305051506290.24368@lxplus080.cern.ch>

On Mon, May 5, Gunnar Hjalmarsson inscribed on the eternal scroll:

> I have a confession to make: When checking for guidance about this
> problem in perlfunc and the sort docs, the solution wasn't immediately
> apparent to me.

You could have tried the FAQs.  "perldoc -q sort" or equivalent.

< http://www.perldoc.com/perl5.8.0/pod/perlfaq4.html
#How-do-I-sort-an-array-by-(anything)- >

> You need to know the exact meaning of "sort lexically"
> respective "sort numerically" in order to find the answer via the
> docs.

The FAQ talks about "string comparison", which I would have thought
was a reasonably intuitive start, no?

> I don't know about you guys, but I was not born with that
> knowledge...

Everyone can make mistakes, but the respondents evidently got the
impression that you hadn't done enough homework.  I've been in this
situation myself often enough...  I'd suggest the best response might
be to concede that they had a point, and resolve to look at the FAQs
next time before posting.  It also helps if you actually cite the
parts of the documentation you're having trouble with - at least then
they'd be willing to credit that you bothered to look (at least,
that's my impression of the way things happen here).

cheers


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

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.  

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


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