[16809] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4221 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 4 11:10:41 2000

Date: Mon, 4 Sep 2000 08:10:25 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968080224-v9-i4221@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 4 Sep 2000     Volume: 9 Number: 4221

Today's topics:
        last/control structure problem <lincolnmarr@nospam.europem01.nt.com>
    Re: last/control structure problem <stephenk@cc.gatech.edu>
    Re: last/control structure problem <lincolnmarr@nospam.europem01.nt.com>
    Re: last/control structure problem <stephenk@cc.gatech.edu>
    Re: Local install of perl modules <mark@orctel.co.uk>
    Re: Looking for Netware NDS Perl Module <carvdawg@patriot.net>
        Optimization of Perl code <heydenreich@delta.de>
    Re: Optimization of Perl code <foo@bar.va>
    Re: Optimization of Perl code (Anno Siegel)
    Re: Optimization of Perl code <heydenreich@delta.de>
    Re: Optimization of Perl code (Anno Siegel)
    Re: Optimization of Perl code <bart.lateur@skynet.be>
    Re: Parsing MySQL TEXT field <gellyfish@gellyfish.com>
    Re: Pattern Matching <gellyfish@gellyfish.com>
        Relative path on NT? <reevehotNOSPAM@hotmail.com>
    Re: Relative to Absolute help? <gellyfish@gellyfish.com>
    Re: Sony Versus Microsoft reg_exp@my-deja.com
        Sv: Appending two arrays fast? <Mads@Troest.NEVERMORE.dk>
        using the value of a variable for another varible's nam (dionysus)
    Re: using the value of a variable for another varible's <lincolnmarr@nospam.europem01.nt.com>
    Re: using the value of a variable for another varible's nobull@mail.com
    Re: using the value of a variable for another varible's <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 4 Sep 2000 14:03:14 +0200
From: "Lincoln Marr" <lincolnmarr@nospam.europem01.nt.com>
Subject: last/control structure problem
Message-Id: <8p031n$c62$1@qnsgh006.europe.nortel.com>

Hi,

I'm having a problem getting the below code to work. Firstly, the code:
-------------------------------------------------
1    #!/bin/perl
2
3    # huge amount of irrelevant code here....
4
5    if ($customer_type eq "ION and Switching") {
6                    $file = $ion_customers;
7                    open(FILE,"$file") || die "Can't open $file, $!\n";
8                        @line = <FILE>;
9                     close(FILE);
10
11             foreach (@line) {
12                    @fields = split(/\|/,$_);
13                           last if ($fields[0] eq $key);
14                $file = $switching_customers;
15    } #end of foreach
16    #last should go here
17    } #end of if
18    open(UP,"$file") || die "Can't open $file, $!\n";
-----------------------------------------------------------
The problem?? I am finding that by the time the loop has executed $file =
$switching_customers, always. This shouldn't always occur - if $fields[0]
matches $key, then $file should still contain $ion_customers (because the
last statement should skip line 14 if the condition is true). However it
doesn't seem to be skipping line 14 if that statement is true, resulting in
line 18 not opening the file I want it to.

Any help would be greatly appreciated.

--Lincoln.





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

Date: Mon, 04 Sep 2000 08:48:25 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: last/control structure problem
Message-Id: <39B39A18.E6A5C01C@cc.gatech.edu>

Lincoln Marr wrote:

> Hi,
>
> I'm having a problem getting the below code to work. Firstly, the code:
> -------------------------------------------------

> <fragment snipped>

> 11             foreach (@line) {
> 12                    @fields = split(/\|/,$_);
> 13                           last if ($fields[0] eq $key);
> 14                $file = $switching_customers;
> 15    } #end of foreach
> 16    #last should go here
> 17    } #end of if
> 18    open(UP,"$file") || die "Can't open $file, $!\n";
> -----------------------------------------------------------
> The problem?? I am finding that by the time the loop has executed $file =
> $switching_customers, always. This shouldn't always occur - if $fields[0]
> matches $key, then $file should still contain $ion_customers (because the
> last statement should skip line 14 if the condition is true). However it
> doesn't seem to be skipping line 14 if that statement is true, resulting in
> line 18 not opening the file I want it to.
>
> Any help would be greatly appreciated.
>

You'll have to clarify something: under what conditions should line 14 be
executed?  In the current program, $file is set to $switching_customers every
time the given line does not begin with $key, so it will be set that way unless
the first line matches.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Mon, 4 Sep 2000 15:30:31 +0200
From: "Lincoln Marr" <lincolnmarr@nospam.europem01.nt.com>
Subject: Re: last/control structure problem
Message-Id: <8p085b$et0$1@qnsgh006.europe.nortel.com>

> You'll have to clarify something: under what conditions should line 14 be
> executed?  In the current program, $file is set to $switching_customers
every
> time the given line does not begin with $key, so it will be set that way
unless
> the first line matches.
>

What I want is this:

If the first field is equal to $key:
1) $file should be $ion_customers
2)break out of loop

Else if you reach the end of the file set $file to $switching_customers.

Clarified??




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

Date: Mon, 04 Sep 2000 10:13:12 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: last/control structure problem
Message-Id: <39B3ADF8.A370B36F@cc.gatech.edu>

Lincoln Marr wrote:

> > You'll have to clarify something: under what conditions should line 14 be
> > executed?  In the current program, $file is set to $switching_customers
> every
> > time the given line does not begin with $key, so it will be set that way
> unless
> > the first line matches.
> >
>
> What I want is this:
>
> If the first field is equal to $key:
> 1) $file should be $ion_customers
> 2)break out of loop
>
> Else if you reach the end of the file set $file to $switching_customers.
>
> Clarified??

Replace lines 11-15 with:

    $file = $switching_customers;
    foreach (@line) {
           @fields = split /\|/;
           next unless ($fields[0] eq $key);
           $file = $ion_customers;
           last;
    } #end of foreach


BTW, do you need to use @line later?  If not, why not use while(<FILE>) instead
of storing the entire file into memory;

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Mon, 04 Sep 2000 14:43:42 GMT
From: Mark Williams <mark@orctel.co.uk>
Subject: Re: Local install of perl modules
Message-Id: <39B3B523.B7B69A20@orctel.co.uk>

Thanks I will try this and copy the files upto my host.
MArk

Alastair wrote:
> 
> Mark Williams <mark@orctel.co.uk> wrote:
> >Is it possible to install perl modules in a local directory?
> >My problem is my cgi host will not install modules that I need. Can I
> >install modules on my local machine in a local directory and copy them
> >up to my host into a local directory?
> >Am I talking rubbish?
> 
> Yes, this seems to be possible and workable. One method is ;
> 
> 1) For install
> 
> give the 'LIB=' argument when making i.e.
> 
> perl Makefile.PL LIB=/<path>/<to>/<module>/<dir>
> make
> make test
> make install
> 
> 2) For use ;
> 
> use lib '/<path>/<to>/<module>/<dir>';
> 
> use <MODULE>;
> 
> --
> Alastair                            |
> alastair@calliope.demon.co.uk       |
> http://www.calliope.demon.co.uk     |            PGP Key : A9DE69F8
> -------------------------------------------------------------------


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

Date: Mon, 04 Sep 2000 10:27:18 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: Looking for Netware NDS Perl Module
Message-Id: <39B3B146.2B9390B8@patriot.net>

have you considered installing Microsoft's ADSI classes and using the NDS
namespace?

Stephane Zanoni wrote:

> I'm looking for a Netware Perl Module, it's listed in the CPAN site as:
>
> Netware::
> ::NDS             cd+O Interface to Novell Directory Services       KTHOMAS
> ::Bindery         cd+O Interface to Novell Bindery mode calls       KTHOMAS
>
> but it's not availlable for download.  I was just wondering if anyone here
> might have it or has seen it somewhere, or can hint me in what direction to
> go and find it.
>
> Thanks,
>     Stephane

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Mon, 04 Sep 2000 13:36:29 +0200
From: Ralf Heydenreich <heydenreich@delta.de>
Subject: Optimization of Perl code
Message-Id: <39B3893D.F6E7A6AD@delta.de>

Hi,
I'm looking for literature / advises for optimizing my Perl scripts. The
reason: I've written a little program which handles a large array (about
10 MB of data) and has to process each row of this array. The memory
consumption is very high - more than 40 MB (I checked this from "top"
output - high means for a computer that has only 64 MB RAM). Which
common advises have you about this fact? (In addition, I have some
hashes and other arrays, but not so large.)

[RH]


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

Date: Mon, 04 Sep 2000 13:52:51 +0200
From: Marco Natoni <foo@bar.va>
Subject: Re: Optimization of Perl code
Message-Id: <39B38D13.6463990D@bar.va>

Ralf,

Ralf Heydenreich wrote:
> I'm looking for literature / advises for optimizing my Perl 
> scripts. The reason: I've written a little program which handles 
> a large array (about 10 MB of data) and has to process each row 
> of this array. The memory consumption is very high - more than 40 
> MB (I checked this from "top" output - high means for a computer 
> that has only 64 MB RAM). 

  A Microsoft NT server usually uses 40 MB of memory for its run-time
image and some auxiliary processes... :)

> Which common advises have you about this fact? (In addition, I 
> have some hashes and other arrays, but not so large.)

  I suggest you to mantain your array on a mass memory device (i.e., the
hard disk) and to load only some parts of it.  You can use many methods
to obtain this result, both developed by yourself or already existing
as, for example, the DB_File module (that allows the programmer to
access data via hash or btree algorithms).

  Obviously, this procedure limited the memory-consumption but not the
time-consumption.

  However, if you show us some pieces of your code, we can carry other
analysis.


	Best regards,
		Marco


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

Date: 4 Sep 2000 13:28:34 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Optimization of Perl code
Message-Id: <8p0822$ufq$1@lublin.zrz.tu-berlin.de>

Ralf Heydenreich  <heydenreich@delta.de> wrote in comp.lang.perl.misc:
>Hi,
>I'm looking for literature / advises for optimizing my Perl scripts. The
>reason: I've written a little program which handles a large array (about
>10 MB of data) and has to process each row of this array. The memory

Pardon me for asking, but can you get away with processing the rows
one by one (without having all other rows in memory)?  If so, you
may be able to use a plain text file to store the array rows, one
per line, and later read and process them, again one by one.

Anno


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

Date: Mon, 04 Sep 2000 16:03:29 +0200
From: Ralf Heydenreich <heydenreich@delta.de>
Subject: Re: Optimization of Perl code
Message-Id: <39B3ABB1.8D5ED786@delta.de>

Anno Siegel schrieb:
> 
> Ralf Heydenreich  <heydenreich@delta.de> wrote in comp.lang.perl.misc:
> >Hi,
> >I'm looking for literature / advises for optimizing my Perl scripts. The
> >reason: I've written a little program which handles a large array (about
> >10 MB of data) and has to process each row of this array. The memory
> 
> Pardon me for asking, but can you get away with processing the rows
> one by one (without having all other rows in memory)?  If so, you
> may be able to use a plain text file to store the array rows, one
> per line, and later read and process them, again one by one.
> 
but if I do so, it could become slower because the permanent disk
accesses, I think. I thought that processing an array is faster than
processing a file line per line. Perhaps I should by a little more
RAM...
[RH]


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

Date: 4 Sep 2000 14:36:04 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Optimization of Perl code
Message-Id: <8p0c0k$ukq$1@lublin.zrz.tu-berlin.de>

Ralf Heydenreich  <heydenreich@delta.de> wrote in comp.lang.perl.misc:
>Anno Siegel schrieb:
>> 
>> Ralf Heydenreich  <heydenreich@delta.de> wrote in comp.lang.perl.misc:
>> >Hi,
>> >I'm looking for literature / advises for optimizing my Perl scripts. The
>> >reason: I've written a little program which handles a large array (about
>> >10 MB of data) and has to process each row of this array. The memory
>> 
>> Pardon me for asking, but can you get away with processing the rows
>> one by one (without having all other rows in memory)?  If so, you
>> may be able to use a plain text file to store the array rows, one
>> per line, and later read and process them, again one by one.
>> 
>but if I do so, it could become slower because the permanent disk
>accesses, I think. I thought that processing an array is faster than
>processing a file line per line. Perhaps I should by a little more
>RAM...

Sure it will become slower.  Asking for optimization is asking for a
trade-off.  Only a benchmark can tell whether the slowdown is acceptable.

Another way to conserve memory may be to put the data into a single string
instead of an array, with appropriate record separators.  Storing a single
scalar saves a lot over storing many.  Assuming "\n" as a separator this
could work like this:

  my $data = "abc\ndef\nghi\njkl";
  while( $data =~ m/\G(.*)\n/g ) {
    my $record = $1;
    # do something with $record
  }

Note how the records are extracted from $data without shuffling $data
around.  There may be prettier ways to do that.

Anno


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

Date: Mon, 04 Sep 2000 14:48:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Optimization of Perl code
Message-Id: <ndd7rs0fb5s2kk72jk2hngdu4j8p969k8u@4ax.com>

Ralf Heydenreich wrote:

>but if I do so, it could become slower because the permanent disk
>accesses, I think. I thought that processing an array is faster than
>processing a file line per line.

You don't know if you dont try. Fact is: reading in ALL the records at
the start of your program takes quite a bit of time, too.

And disk reading is not something that involves your CPU. So, it's not
unimaginable that disk access and record processing can happen almost
entirely in parallel.

Of course, if another porgram is disk intensive too, at the same time,
these two programs will hinder each other more than a bit.

-- 
	Bart.


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

Date: 4 Sep 2000 08:06:43 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Parsing MySQL TEXT field
Message-Id: <8ovhm3$aq4$1@orpheus.gellyfish.com>

On Sun, 03 Sep 2000 15:38:37 +0200 marvin wrote:
> Keith Calvert Ivey wrote:
>> 
>> Marvin <ales.romaniuk@zag.si> wrote:
>> 
>> >When I pull this field into variable, and watch its value in DEBUG, I
>> >can see this:
>> >
>> >Line1\cM\cJLine2\cM\JLine3\cM\cJ
>> 
>> It sounds like you're doing something wrong with translation of
>> line-ending characters, starting with data that's using Windows
>> (or network) line endings and treating it as if it has Unix line
>> endings.
>> 
>> >which seems to be CR/LF fields.
>> >
>> >If I watch line by line made by split "\n",@TEXTFIELD), I can see
>> >
>> >Line1\cM
>> >Line2\cM
>> >Line3\cM
>> >
>> >with no \cJ fields.
>> 
>> No, you don't.  The second argument of split() should be a
>> scalar, not an array.  The result of split("\n", @TEXTFIELD)
>> would be just 3 in your case.
>> 
>> >How can I strip TEXT fields and put them into an ARRAY with the split
>> >command ?
>> 
>> You may want something like this:
>> 
>>     my @lines = split /\cM\cJ/, $TEXTFIELD;
>> 
>> if you have a scalar, or
>> 
>>     s/\cM\cJ$// for @TEXTFIELD;
>> 
>> if you really have an array.
>> 
>> But it might be better to get your data right in the first
>> place.
>> 
>> >(Also split("\c",@TEXTFIELD) won't work)
>> 
>> What do you expect it to do?  It's a syntax error, though
>> strangely it isn't if you change the quotes to slashes (which is
>> a good idea, since the first argument to split() is a regex, not
>> a string).
>
> Yes, I actually have scalar parameter as a second in split. I only
> put wrong in example. But if I use split "\c",$FIELD, I get syntax
> error. I thought that \n is equal to CR/LF which is hex 0x0d 0x0a,
> but seems its not.

It all depends on the platform and the binmode setting.  The syntax error
you are getting is caused by the incomplete '\c' escape sequence which
requires another character.  The \c is 'Control-something' and you
*must* supply the something.  In this case M and J.

I think you want :

   split /\cM\cJ/, $FIELD;

You probably want to read the perlop manpage to find out more about the
escape sequences and the perlfunc manpage to find out more about the
first argument to split().

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 4 Sep 2000 07:53:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Pattern Matching
Message-Id: <8ovgu6$aop$1@orpheus.gellyfish.com>

On Sun, 03 Sep 2000 15:36:08 GMT sfcq2@my-deja.com wrote:
> Hello,
> 
> I am creating a htaccess and htpasswd management system, but have hit a
> bit of a hurdle.
> 
> I can add all names and encrypted passwords to "htpasswd", but I want to
> compare the names from the existing file to those in a new file that
> will update the site. If a name already exists, the user will not be
> sent an email confirming his username and password, because they are
> already there.
> 
> I am creating the user as follows:
> 
> $newline[$a] = $username[$a]. ":" .$newpass[$a];
> 
> and this gives an output like:
> 
> rob.phillips:a1fZxO.8KssXw
> 
> which is added to a temp file. Then, I open htpasswd and search through
> it line by line until a match is found like this:
> 
> open (PASS, "<htpasswd") || die "Can't open htpasswd: $!\n";
> @oldusers = <PASS>;

Unless you have good reason you probably want to remove the line-endings:

 chomp(@oldusers = <PASS>);

> close (PASS);
> 
> for ($a = 1; $a < @oldusers; $a++) {
>      $_ = $oldusers[$a];
>      if (/$newline[$a]/) {
>           DO STUFF
>      }
> }
> 
> A match should be found because I am using the same data source fle each
> time, but it never finds the entry in htpasswd. Have I missed something?
> 

You will have missed the first element in @oldusers by starting your
array index at 1 - the more idiomatic way of doing the loop would be :

  for $index ( 0 .. $#oldusers )
  {
    #etc
  }

Although why you are using this is not clear as it appears to imply that the
existing entry and the new entry are going to be in the same row in the
file.  Surely it would be better to place the existing data in a hash
keyed on the username and check the incoming username against that
upfront before you create your output rows - this is surely going to be more
efficient than looping over the data rows like this.


/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Tue, 5 Sep 2000 00:04:18 +1000
From: "James R" <reevehotNOSPAM@hotmail.com>
Subject: Relative path on NT?
Message-Id: <m3Ns5.8966$cr3.254853@ozemail.com.au>

In Matt's guestbook script there is a variable $guestbookreal that is for
the system location of the guestbook data file.

See
http://www.worldwidemart.com/scripts/cgi-bin/download.cgi?s=guestbook&c=txt&
f=guestbook.pl

The script works wonderfully when I fully define this
("e:/inetpub/svc1/guest/guestbook.html") but the browser keeps jumping to a
download screen if I try to use a relative path (just "guestbook.html" as
they're all in the one directory).

The 'error' occurs when the script gets here...
open (FILE,"$guestbookreal");

My host runs on NT.

I would very much like to use a relative path because I'd like this script
to be portable around my site depending on where I use it.




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

Date: 4 Sep 2000 06:53:47 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Relative to Absolute help?
Message-Id: <8ovddb$aeo$1@orpheus.gellyfish.com>

On Sun, 03 Sep 2000 19:52:53 GMT ptomsic@my-deja.com wrote:
> Does anyone know of anything currently avail that will transform
> relative links to absolute?
> 
> I've got a full directory listing of 2400 html files, and I'm searching
> for something that will allow me to supply the root directory, and the
> URL, and have it transform (inside the HTML files)
> a link such as (href=../../file.html) to
> (http://sitename.com/dir1/dir2/file.html)
> 

Sounds as if this might be something that the URI module might be able
to help you with.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Mon, 04 Sep 2000 11:12:14 GMT
From: reg_exp@my-deja.com
Subject: Re: Sony Versus Microsoft
Message-Id: <8p0028$inn$1@nnrp1.deja.com>

hilarious..... it has a sense of humour... @:)

> Now what does this have to do with Perl?  Well, creating games
> in perl is something that needs to be addresed because perl
> is too text based....

yup, am right away scripting 3d rpg for sony game consoles in perl... ;)

- reg_exp


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 4 Sep 2000 15:50:17 +0200
From: "Mads Orbesen Troest" <Mads@Troest.NEVERMORE.dk>
Subject: Sv: Appending two arrays fast?
Message-Id: <39b3a8ba$1@194.255.58.12>

> > Is there a better (i.e. faster) way?
> perldoc -f push

Of course. Thanks.

/\/\\ads




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

Date: Mon, 04 Sep 2000 12:23:24 GMT
From: dionysus39@hotmail.com (dionysus)
Subject: using the value of a variable for another varible's name?
Message-Id: <39b39307.34270252@nntp.unsw.edu.au>

I have seen s code snippet allowing you to use the contents of a
variable to name another variable - i.e. if you had a lot of code
resulting in a variable $day containing the name of one of the
weekdays, you could use that fact to create a variable named after
that day i.e. $monday or whatever....however unfortuantly I cannot for
the life of me remember where I read it, and as I am hoping to use it
to get a tricky part of my uni assignment working, I was hoping
someone else would be able to help me out here. One guy I was talking
to mentioned using references, but I think the snippet I saw just had
some weird setup of quotes around the variable name....anyhow, I'd
appreciate any help very much....

Thanks in advance,

-dionysus
"One World, one Web, one Program" - Microsoft promotional ad
"Ein Volk, ein Reich, ein Fuhrer" - Adolf Hitler .


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

Date: Mon, 4 Sep 2000 13:42:55 +0200
From: "Lincoln Marr" <lincolnmarr@nospam.europem01.nt.com>
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <8p01rj$bjr$1@qnsgh006.europe.nortel.com>

> I have seen s code snippet allowing you to use the contents of a
> variable to name another variable - i.e. if you had a lot of code
> resulting in a variable $day containing the name of one of the
> weekdays, you could use that fact to create a variable named after
> that day i.e. $monday or whatever....

try this:

$day = "monday";
${$day} = "11 am";    #whatever value you want to assign to $monday
print "$monday\n";

--Lincoln





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

Date: 04 Sep 2000 12:57:43 +0100
From: nobull@mail.com
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <u9d7ikz7wo.fsf@wcl-l.bham.ac.uk>

dionysus39@hotmail.com (dionysus) writes:

> I have seen s code snippet allowing you to use the contents of a
> variable to name another variable

"Symbolic reference".

> One guy I was talking to mentioned using references, but I think the
> snippet I saw just had some weird setup of quotes around the
> variable name....anyhow, I'd appreciate any help very much....

"but"?  What do you mean "but"?  Have you bothered to RTFM on
references?  In paricular if you read the section of perdoc perlref
that deals with symbolic references you'll likely find some rather
familiar looking "weird setup of quotes around the variable name".

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 04 Sep 2000 12:58:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <0s67rssjp2es210001b6nl47b6s9ah8pog@4ax.com>

dionysus wrote:

>I have seen s code snippet allowing you to use the contents of a
>variable to name another variable - i.e. if you had a lot of code
>resulting in a variable $day containing the name of one of the
>weekdays, you could use that fact to create a variable named after
>that day i.e. $monday or whatever....

People here will tell you "don't do it". See the three archived articles
by Mark-Jason Dominus on the why.

	http://www.plover.com/~mjd/perl/varvarname.html
	http://www.plover.com/~mjd/perl/varvarname2.html
	http://www.plover.com/~mjd/perl/varvarname3.html

If at all possible, use a hash, for example

	$day{monday}

instead of

	$monday

It's virtually as fast. It's just as flexible. It's a lot safer.

-- 
	Bart.


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4221
**************************************


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