[18303] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 471 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 12 11:05:39 2001

Date: Mon, 12 Mar 2001 08:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984413112-v10-i471@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 12 Mar 2001     Volume: 10 Number: 471

Today's topics:
        $ENV{'HTTP_REFERER'} <rworth5@home.com>
    Re: $ENV{'HTTP_REFERER'} <djberge@uswest.com>
    Re: $ENV{'HTTP_REFERER'} <skeplin@nospam.1.net>
    Re: CGI question <sorryno@email.at.all>
    Re: CGI question <rother@nortelnetworks.com>
        CPAN Question <meisterplan@t-online.de>
    Re: Detecking when new files are present, <perl@imchat.com>
        Find parent nodes in a hash <scottb@wetcanvas.com>
    Re: Find parent nodes in a hash <scottb@wetcanvas.com>
    Re: functions, operators and () (Tad McClellan)
    Re: Help Matt with small programs <tzz@beld.net>
    Re: How do I delete (ignore) part of a string? (Tad McClellan)
    Re: How do I delete (ignore) part of a string? <james@NOSPAM.demon.co.uk>
    Re: How to reverse a loop ? <bernie@fantasyfarm.com>
    Re: Please Help in Perl (Tad McClellan)
    Re: Tk based alarm clock <fellowsd@cs.man.ac.uk>
    Re: Typeglob assignment confusion <h.camp@scm.de>
    Re: Typeglob assignment confusion <james@NOSPAM.demon.co.uk>
    Re: Typeglob assignment confusion <james@NOSPAM.demon.co.uk>
    Re: Typeglob assignment confusion <galen.menzel@mail.utexas.edu>
    Re: Typeglob assignment confusion (Anno Siegel)
    Re: Typeglob assignment confusion <james@NOSPAM.demon.co.uk>
    Re: using Perl for B2B? (Tad McClellan)
    Re: Why glob doesn't take a list? (Anno Siegel)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Mar 2001 14:16:58 GMT
From: "Richard" <rworth5@home.com>
Subject: $ENV{'HTTP_REFERER'}
Message-Id: <uT4r6.3278$rB2.271347@news1.rdc1.mb.home.com>

I am wondering if anyone else is having a problem with this. I have had a
line of code on my script for the past 3 months. It has been working just
fine until about a week ago. I havent changed anything, and noticed for some
unknown reason, it has stopped working.

All I am doing is keeping a log of the referring pages.

I have even tried something as simple as

$name = $ENV{'HTTP_REFERER'};

print "$name\n";


and it won't even do that. I can get everyother environment variable to
print to screen except this inparticular.

Was hoping someone could explain.

Richard




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

Date: Mon, 12 Mar 2001 08:22:25 -0600
From: Daniel Berger <djberge@uswest.com>
Subject: Re: $ENV{'HTTP_REFERER'}
Message-Id: <3AACDBA1.5C3E6960@uswest.com>

Richard wrote:

> I am wondering if anyone else is having a problem with this. I have had a
> line of code on my script for the past 3 months. It has been working just
> fine until about a week ago. I havent changed anything, and noticed for some
> unknown reason, it has stopped working.
>
> All I am doing is keeping a log of the referring pages.
>
> I have even tried something as simple as
>
> $name = $ENV{'HTTP_REFERER'};
>
> print "$name\n";
>
> and it won't even do that. I can get everyother environment variable to
> print to screen except this inparticular.
>
> Was hoping someone could explain.
>
> Richard

Uh-oh.  Did someone go and correct the spelling of "referer"?  Just
for kicks, try "HTTP_REFERRER"  and see what happens.

Also note that Referer is not always sent to the server.

Dan





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

Date: 12 Mar 2001 10:40:26 -0500
From: Sean Keplinger <skeplin@nospam.1.net>
Subject: Re: $ENV{'HTTP_REFERER'}
Message-Id: <3aacedea_1@news2.one.net>

Daniel Berger <djberge@uswest.com> wrote:

> Uh-oh.  Did someone go and correct the spelling of "referer"?  Just
> for kicks, try "HTTP_REFERRER"  and see what happens.


Also, if you are using CGI.pm, you can do this:

   use CGI qw(:standard);

   $referrer = referer();
   $remote_ip = remote_host();


HTH,
Sean


-- 
"Have you ever walked through a room, and it was more like the 
 room passed around you; like there was a leash around your 
 neck that pulled you through?" -- Offspring, Have You Ever


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

Date: Mon, 12 Mar 2001 15:27:34 -0000
From: "Brian J" <sorryno@email.at.all>
Subject: Re: CGI question
Message-Id: <3aaceaee_2@news2.uncensored-news.com>


"Gabe Rother" <rother@nortelnetworks.com> wrote in message
news:3AACD314.EE9C904@nortelnetworks.com...
<snip>
> if the url is http://gabe.rother.com/folder1/page1.html Then where it
> shows the URL, it will this, the correct path.
>
> But, the link will be http://gabe.rother.com/cgi-bin/page1.htm
<snip>


I presume you have something like this -

print "<a href=\"$file\">whatever</a>\n";

try -

print "<a href=\"../$file\">whatever</a>\n";

or -

print "<a href=\"/$file\">whatever</a>\n";

--
Brian





______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
 With Servers In California, Texas And Virginia - The Worlds Uncensored News Source
  


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

Date: Mon, 12 Mar 2001 10:48:32 -0500
From: Gabe Rother <rother@nortelnetworks.com>
Subject: Re: CGI question
Message-Id: <3AACEFD0.1BD8FD9E@nortelnetworks.com>

There is no line like that.  It's a cgi script created by AnalogX, and I
can't modify the exe file.  There is a config file, but it doesn't show
anything like that.  Here it is:

BASEURL 
FILESPEC 
FILESPEC 
SEARCHPATH 
SKIPLIST 
EXCLUDEPATH 
EXCLUDEPATH 

Hopefully that will help you help me!!!  If I can be helped, that is!

Gabe

Brian J wrote:
> 
> I presume you have something like this -
> 
> print "<a href=\"$file\">whatever</a>\n";
> 
> try -
> 
> print "<a href=\"../$file\">whatever</a>\n";
> 
> or -
> 
> print "<a href=\"/$file\">whatever</a>\n";
> 
> --
> Brian
> 
> ______________________________________________________________________
> Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
>  With Servers In California, Texas And Virginia - The Worlds Uncensored News Source
>


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

Date: Mon, 12 Mar 2001 15:02:19 +0100
From: Klaus-Dieter =?iso-8859-1?Q?S=F6der?= <meisterplan@t-online.de>
Subject: CPAN Question
Message-Id: <3AACD6EB.882CF43A@t-online.de>

Is there a module which converts Paradox to Excel, or better text?

Oliver Söder


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

Date: Mon, 12 Mar 2001 09:57:55 -0600
From: mark <perl@imchat.com>
Subject: Re: Detecking when new files are present,
Message-Id: <3AACF203.60F1B572@imchat.com>



Michael Chapman wrote:

> I have the task of propagating huge zip files from the WAN when thaey have
> been FTP'd to a certain (known) directory and then I need to move them to
> another server on a local server. All of the files transfered have a start /
> stop file indicating that they have been FTP'd. After the zip files have
> been moved and unziped, they are deleted. We also know what the next FTP
> directory is because the directory number is increased by 1. I would like to
> know what the best possible way is to detect when the new folder has been
> added and then move the zip files, unzip them and then remove the zip files
> only. Any ideas would be appreciated!
>

    This is just a standard while loop and will run continuosly until the
machine is shutdown. Another way to do this is with a cron job.
    If you want to run this silently you'll need to redirect stdout to a file if
you want to keep a record. This is not a perfect script and I'm sure there are
more elegent ways to do it.
    If you're incrementing a directory for some reason then you'll need to
increment the directory in the script and think about running it from cron
instead of a while so that it is timed with the directory creation. Something
like that

use File::Copy;
use strict;
my $dir = 'e:/test';
my $otherDir = 'e:/test2';
while(1){
opendir FH, "$dir" or print "Can't open $dir\n";
my @files = grep(/\.zip$/i, readdir(FH));
closedir FH;
foreach my $file(@files){
copy("$dir/$file", "$otherDir/$file") or print "Can't copy $file to
$otherDir\n";
print "$file copied to $otherDir\n" if(-e "$otherDir/$file");
exec("your command line zip program with arguments");
unlink("$dir/$file") or print "Unable to delete $file";
    }
sleep(300);
}






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

Date: Mon, 12 Mar 2001 10:51:28 -0800
From: Scott Burkett <scottb@wetcanvas.com>
Subject: Find parent nodes in a hash
Message-Id: <3AAD1AB0.731F3F15@wetcanvas.com>

Thanks in advance to all who respond.

Situation:

I am using Brian Jepson's DBIx::Tree package to build a nice sorted list
of referential nodes in a tree (where the parent_id of one node
references the id column of another node).

Problem:

I need to know whether or not a user in the system has access to the
data in a given node in the tree.  The access rules are stored in
another table, and are simply text-based rules, such as:

Node 2:*
Node 4

In other words, they can access Node 2, and all of its children, and
Node 4 by itself (not its parent or peers).  Alternatively, a rule might
appear as:

Node 2: Node x, Node y

I know I need to walk the tree, and apply the rules to determine this,
but I'm still struggling with the notation of hashes in Perl.  Any help,
tips, starting points, or code examples would be much appreciated.

Data Dumper($tree) reports:

$VAR1 = bless( {
                 'table' => 'my_table',
                 'columns' => [
                                'id',
                                'name',
                                'parent_id'
                              ],
                 'method' => sub { "DUMMY" },
                 'data' => [
                             {
                               'name' => 'Base Node',
                               'id' => '0',
                               'parent_id' => 'None'
                             },
                             {
                               'name' => 'Node 1',
                               'id' => 983626631,
                               'parent_id' => 983643076
                             },
                             {
                               'name' => 'Node 2',
                               'id' => 983643069,
                               'parent_id' => '0'
                             },
                             {
                               'name' => 'Node 3',
                               'id' => 90145135,
                               'parent_id' => 983643069
                             },
                             {
                               'name' => 'Node 4',
                               'id' => 983393139,
                               'parent_id' => 90145135
                             },
                             {
                               'name' => 'Node 5',
                               'id' => 1,
                               'parent_id' => '0'
                             },
                             {
                               'name' => 'Node 6',
                               'id' => 983626614,
                               'parent_id' => 983643076
                             },
                             {
                               'name' => 'Node 7',
                               'id' => 983643076,
                               'parent_id' => '0'
                             },
                             {
                               'name' => 'Node 8',
                               'id' => 983393133,
                               'parent_id' => 90145135
                             },
                             {
                               'name' => 'Node 9',
                               'id' => 983393132,
                               'parent_id' => 983643069
                             }
                           ],
                 'start_id' => '0',
                 'id_column' => 'id',
                 'parent_id_column' => 'parent_id',
                 'match_data' => undef,
                 'dbh' => bless( {}, 'DBI::db' ),
                 'limit' => undef,
                 'data_column' => 'name'
               }, 'DBIx::Tree' );

As you can see from the above data dump, the nodes are all stored in the
"data" portion of the tree variable.

Thanks in advance!

Cheers.
Scott



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

Date: Mon, 12 Mar 2001 11:07:20 -0800
From: Scott Burkett <scottb@wetcanvas.com>
Subject: Re: Find parent nodes in a hash
Message-Id: <3AAD1E68.32868518@wetcanvas.com>


Pardon the omission of this tidbit in my previous post for help.

I have the node id and name in scope, I just need to determine whether or
not the given node id or name is accessible.

Thanks again!
Scott



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

Date: Mon, 12 Mar 2001 08:24:40 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: functions, operators and ()
Message-Id: <slrn9apjgn.sip.tadmc@tadmc26.august.net>

Alun Moon <alun.moon@unn.ac.uk> wrote:

>I had a discussion with a colleague about teaching Perl.


There is a mailing list for discussing such things:

   http://lists.perl.org/showlist.cgi?name=perl-trainers


>Initially the students would be taught to use something like
>
>  print("hello world\n");
>
>Where I would use
>
> print "hello world\n";
>
>I believe that the use of () alters the way the print handles the
>parameters.  


No, it alters the way the perl parser determines the extent
of the argument list (due to precedence). Once identified, 
the args are handled the same way.

Using _ampersand_ (&) on (non-builtin) functions does alter the 
way that subroutine arguments are handled.


>I've read through the Perldocs (perlfunc) and page 77 in
>the Camel book.
>
>My understanding is that the () make the print a function rather than
>a list operator (though I'm not sure what the distinction is), and
>alter the precidence of the statement.  Am I right?


We discussed this here a few days ago. 

   Subject: print using () functions and lists

Here is the (ridiculously long and word-wrapped) URL to the archived thread:

   http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=
      55e736a223a8d96b&seekd=919181340


Oh sheesh! It was you that started that thread!

Why are you starting the same one over again?

If you didn't like the followups, you should have followed up in
that thread asking for more, not wait 10 days and start the whole
thing over again...


>I also advocated that we teach the 
>  print "hello world\n";
>version, as this is the form used in the perldocs and Camel book.
>Does this seem right?


Yes, it *still* seems right (if you also warn them).


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


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

Date: 12 Mar 2001 10:24:41 -0500
From: Ted Zlatanov <tzz@beld.net>
Subject: Re: Help Matt with small programs
Message-Id: <m34rwzt3gm.fsf@heechee.beld.net>

abigail@foad.org (Abigail) writes:

> I actually find seperation of formatting and solving the problem on
> hand clearer than mixing formatting and algorithm in one statement.

Point taken - I tend to prefer nested functions, sometimes
subconsciously.

-- 
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Mon, 12 Mar 2001 07:37:50 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How do I delete (ignore) part of a string?
Message-Id: <slrn9apgou.sip.tadmc@tadmc26.august.net>

Nancy <pigpen@easynews.com> wrote:

>Sorry Tad, didn't try yours.  


I misunderstood the question anyway.


>I should have prefaced my post with the fact
>that I'm not a programmer.  I am modifying a very good off-the-shelf script.
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Those are extremely rare.

Since you are not a programmer, how do you arrive at the conclusion
that it is "very good"?

There are many many freely available scripts that are poor. Not
robust, security holes, etc...

Which one did you grab? Where did you get it? Maybe someone with
more experience will critique it for you.


>I first looked through the FAQ at
                                ^^
>http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq4.html


You do not need to go web surfing to find the very same file that
is already on your hard disk, just use the one that came with your
perl distribution:

   perldoc perlfaq4

For searching the FAQs on your hard disk:

   perldoc -q <search term>

To find out how to use perldoc:

   perldoc perldoc


>I usually do pretty good figuring out what I need.  


The standard docs that come with perl will help a lot with that,
perldoc is your friend.


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


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

Date: Mon, 12 Mar 2001 15:41:00 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: How do I delete (ignore) part of a string?
Message-Id: <ant121500bc8fNdQ@oakseed.demon.co.uk>

In article <slrn9apgou.sip.tadmc@tadmc26.august.net>, Tad McClellan
<URL:mailto:tadmc@augustmail.com> wrote:
>
> Nancy <pigpen@easynews.com> wrote:
> > I first looked through the FAQ at
> > http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq4.html
> 
> You do not need to go web surfing to find the very same file that
> is already on your hard disk, just use the one that came with your
> perl distribution:
> 
>    perldoc perlfaq4

Personally I find it very helpful when someone posts a URL because I
don't have a working perldoc on my system. Also, as a general rule
there is no reason to assume that the machine that someone uses for
reading Usenet is the same machine that has Perl installed. Please
don't knock people for posting URLs, they're very helpful.

-- 
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Mon, 12 Mar 2001 10:02:24 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: How to reverse a loop ?
Message-Id: <qvgpatglpu2cmcrvbigrk2i682qkcmqm7k@news.supernews.net>

mgjv@tradingpost.com.au (Martien Verbruggen) wrote:

} But unless oyu really need the $i (and you don't seem to), and depending
} on how large @bids is, it's probably nicer to do:
} 
} for my $bid_el (@bids)
} {
} 	my ($alias, $email, $bid, $time, $add1, $add2, $add3) = 
} 		read_bid($bid_el);
} }
} 
} and for the reverse
} 
} for my $bid_el (reverse @bids)
} {
} }

Meta question on efficiency: does Perl actually construct a temporary
reversed-list, or does it do some magic to optimize that out?

[NB: I already understand that at worst it does a 'shallow copy' of the
list -- that is [if you will] a list of references to the elements of the
original list [so that entry-aliasing works fine back to the -original-
[unreversed] list], and so there's no wholesale copying of the entry-data,
but I was wondering whether it actually tries to save the trouble of
building the temp list entirely, as it does [somehow..:o)] for (1..BIG)]

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Mon, 12 Mar 2001 08:28:50 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Please Help in Perl
Message-Id: <slrn9apjoi.sip.tadmc@tadmc26.august.net>

Damian James <damian@qimr.edu.au> wrote:

>Indeed, by default wildcards in (at least Perl) regular expressions are greedy.
                    ^^^^^^^^^

You should avoid calling them that. Folks expect "wildcards" to
match characters (because that is what they do in filename globbing).

Perl's quantifiers do NOT match any characters, so you give confusion
a chance to come to the party.


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


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

Date: Mon, 12 Mar 2001 15:14:45 +0000
From: "Donal K. Fellows" <fellowsd@cs.man.ac.uk>
Subject: Re: Tk based alarm clock
Message-Id: <3AACE7E5.65351832@cs.man.ac.uk>

Victor Wagner wrote:
> By the way, it would require perl or Tcl interpreter to stay in memory
> during all your login session, and this seems to much for just an alarm
> clock.

It depends on whether you already have an interpreter already present.
The overhead for a separate interpreter within an already-running
process is pretty small...

Donal.
-- 
Donal K. Fellows    http://www.cs.man.ac.uk/~fellowsd/    fellowsd@cs.man.ac.uk
-- There are worse futures that burning in hell. Imagine aeons filled with
   rewriting of your apps as WinN**X API will change through eternity...
                                           -- Alexander Nosenko <nae@titul.ru>


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

Date: Mon, 12 Mar 2001 15:44:04 +0100
From: H. Camphausen <h.camp@scm.de>
Subject: Re: Typeglob assignment confusion
Message-Id: <98in39$bs1$1@surz18.uni-marburg.de>

[F'up zu James Taylor's Posting vom Mon, 12 Mar 2001 13:28:56 +0000]

> > put
> > use vars qw(@array);
> > 
> > at the beginning.
> [...]
> Is it possible to say:
> 
> sub testsub (\@) {
>     use vars qw(@array);
>     local *array = shift;
>     ...etc

Why not try it?!
(well, it is possible. But no good style, because...)
 
> and would this scope the @array variable to the inside of the
> subroutine?

Nope.
The use-directive is executed at the very start of the program.

One question:
Why do you want to use a typeglob here?

This will do ok if you want to use an alias name for a variable, so that 
this would work:

	*bar = $foo;      # $bar = 'modified!' sets $foo to 'modified!'
	*bar = *foo;      # $foo, @foo and %foo can be 
	                  # accessed via $bar, @bar and %bar

Following your code example, this is not what you want:
You are local()-izing your @array, that is, you do not want to get any 
@array outside of your testsub() affects by any assignments to testsub()-
s @array.

Maybe you should better shift() your parameter into a my-variable, using 
the @{$a_ref}- or $a_ref->[n]-syntax to access the array later.


hth + mfg, Hartmut

-- 
CREAGEN Computerkram     Fon: 06422/850527
Hartmut Camphausen       Fax: 06422/850528
Am kleinen Born 1        E-Mail: h.camp@creagen.de
35287 Amöneburg          WWW: http://www.creagen.de


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

Date: Mon, 12 Mar 2001 14:55:01 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Typeglob assignment confusion
Message-Id: <ant121401d07fNdQ@oakseed.demon.co.uk>

In article <98ijj3$3e4$1@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel
<URL:mailto:anno4000@lublin.zrz.tu-berlin.de> wrote:
>
> James Taylor wrote:
> > 
> > Is it possible to say:
> > 
> > sub testsub (\@) {
> >     use vars qw(@array);
> >     local *array = shift;
> >     ...etc
> >
> > and would this scope the @array variable to the inside of the
> > subroutine?
> 
> This would allow unqualified use of @array from the point of the
> "use vars" to the end of the file.

Oh dear, then I wouldn't want to write it inside the subroutine as if
it were confined to the subroutine block because that would be
misleading. If it has to be file scoped then I should write it at the
top of the program to reflect this.

> Using "our @array;" in the subroutine would restrict unqualified
> access to the sub (or, in general, the block it appears in).

Great stuff. What a pity that both the RISC OS port I'm using and my
ISP's installed copy of perl are still at version 5.005_03. Also, even
if I were able to overcome those two installations and started using
Perl 6 features such as 'our', what guarantee would I have that I
would always be able to run my scripts on another server? In other
words, I think I'll have to do without 'our' until such time as Perl 6
installations become more common.

> Mind you, you're still using a global variable which is visible
> throughout the package is is declared in.  It's only access via
> the default package that is restricted.

I see. Thanks.

-- 
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Mon, 12 Mar 2001 15:10:26 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Typeglob assignment confusion
Message-Id: <ant121526345fNdQ@oakseed.demon.co.uk>

In article <98in39$bs1$1@surz18.uni-marburg.de>, H. Camphausen
<URL:mailto:h.camp@scm.de> wrote:
>
> The use-directive is executed at the very start of the program.
> 
> One question:
> Why do you want to use a typeglob here?

I need to pass the array by reference anyway because it might be very
large. I just thought that if I could use the simpler syntax of @array
and $array[2] etc within the subroutine, then the code in the
subroutine would be cleaner and easier to follow for other people that
might have to maintain my code later.

> This will do ok if you want to use an alias name for a variable, so that 
> this would work:
> 
>       *bar = $foo;      # $bar = 'modified!' sets $foo to 'modified!'

Do you mean *bar = \$foo ?

>       *bar = *foo;      # $foo, @foo and %foo can be 
>                         # accessed via $bar, @bar and %bar

Yes, I think I know how typeglob assignments are supposed to work.
I just didn't know it would be so tricky to get them to work neatly
under the influence of use strict.

> Following your code example, this is not what you want:
> You are local()-izing your @array, that is, you do not want to get any 
> @array outside of your testsub() affects by any assignments to testsub()-
> s @array.

Correct, @array is used in a read-only fashion within my subroutine.

> Maybe you should better shift() your parameter into a my-variable, using 
> the @{$a_ref}- or $a_ref->[n]-syntax to access the array later.

Yes, sadly this would seem to be the best way forward. It is a pity I
cannot do what I want without creating global variables.

> hth + mfg, Hartmut

I know that HTH = Hope That Helps but am I right in thinking
that MFG = More Friendly Garbage ?

-- 
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Mon, 12 Mar 2001 09:27:11 -0600
From: Galen Menzel <galen.menzel@mail.utexas.edu>
Subject: Re: Typeglob assignment confusion
Message-Id: <3AACEACF.CD0C883D@mail.utexas.edu>

James Taylor wrote:
> 
> In article <98in39$bs1$1@surz18.uni-marburg.de>, H. Camphausen
> <URL:mailto:h.camp@scm.de> wrote:
> >       *bar = *foo;      # $foo, @foo and %foo can be
> >                         # accessed via $bar, @bar and %bar
> 
> Yes, I think I know how typeglob assignments are supposed to work.
> I just didn't know it would be so tricky to get them to work neatly
> under the influence of use strict.

Well, this is the problem with using typeglobs, which muck around with perl's
internal symbol table, and so are implicitly global.  References were put into
perl to solve just this type of problem.  Use them.  The following code looks
perfectly readable to me, and use strict doesn't complain about it:

#!/usr/bin/perl -w

use strict;

sub testsub (\@) {
    my $array_ref = shift;

    foreach my $item (@$array_ref) {
        print $item, "\n";
    }
}

my @testarray = qw(One Two Three);
testsub @testarray;

Hope that helps.
galen


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

Date: 12 Mar 2001 15:34:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Typeglob assignment confusion
Message-Id: <98iqab$bui$1@mamenchi.zrz.TU-Berlin.DE>

According to James Taylor  <james@NOSPAM.demon.co.uk>:

[...]
 
> I know that HTH = Hope That Helps but am I right in thinking
> that MFG = More Friendly Garbage ?

"Mit freundlichen Gruessen", a conventional letter-ending in German,
much like "regards".  So you were pretty close, actually.

Anno


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

Date: Mon, 12 Mar 2001 15:54:11 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Typeglob assignment confusion
Message-Id: <ant121511f7ffNdQ@oakseed.demon.co.uk>

In article <3AACEACF.CD0C883D@mail.utexas.edu>, Galen Menzel
<URL:mailto:galen.menzel@mail.utexas.edu> wrote:
>
> The following code looks perfectly readable to me,
> and use strict doesn't complain about it:
> 
> sub testsub (\@) {
>     my $array_ref = shift;
> 
>     foreach my $item (@$array_ref) {
>         print $item, "\n";
>     }
> }

Well, this is the kind of thing I will have to do, but obviously this
example subroutine is very much simpler than the real code, and even
one extra level of indirection can make the code harder to follow when
you are dealing with an already complex data structure. I just wanted
to try to simplify the code as much as possible for the sake of clarity
and maintainability. After all, some poor sod will have to maintain it
and if I'm unlucky it'll be me.

-- 
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Mon, 12 Mar 2001 08:52:19 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: using Perl for B2B?
Message-Id: <slrn9apl4i.sip.tadmc@tadmc26.august.net>


[ no context given. was something about using Java vs. Perl ]


robert.groenewegen@removetomailme.zonnet.nl 
   <robert.groenewegen@removetomailme.zonnet.nl> wrote:
                       ^^^^^^^^^^^^^^

[ You should move your munging to the other side of the @ sign ]


>Working as software engineer with several junior collegues I would say: 
>both (Java and Perl that is)


My usual comment on "Java vs. Perl" is (colored by the intended
audience, college students):

   Java is good for getting a job.

   Perl is good for getting a promotion.

[ Perl may be good for getting a job too, depending on the swings
  of dot-coms (www work).
]

"Getting a job" is more on the minds of students, so there is little
demand for for-credit Perl classes. It isn't until after you _have_
a job that you want to start impressing your boss with high productivity.


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


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

Date: 12 Mar 2001 15:03:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why glob doesn't take a list?
Message-Id: <98iogl$3e4$3@mamenchi.zrz.TU-Berlin.DE>

According to Bart Lateur  <bart.lateur@skynet.be>:
> Craig Berry wrote:
> 
> >: I was just wondering why glob() takes only a $scalar instead of using a
> >: full @array?
> >
> >That would be kind of useful, actually.
> 
> As an aside: I have always wondered the same thing WRT undef().

Maybe it wasn't considered necessary?  There's

    ( $x, $y, @a) = ();

to undef multiple things.

Anno


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 471
**************************************


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