a few notes on soft references:

1. they are generally concidered evil
2. they will not work under use strict
3. they are rarely what you really need/want

I'm not saying they are bad in your case, but let me just elaborate on the
above.

you'll have to say 'no strict refs' for a certain block to have soft refs
work under use strict.
assuming you *are* in fact running under strict.. which imo one always
should.

furthermore, you'd need to 'my' those variables as well, to make strict
happy.

now, for another fix:

### old code ###
> my @array = qw( first second third );
> my $cnt = 1;
> foreach (@array) {
>     ${$_} = $cnt++
> }

### new code ###
my @array = qw( first second third );
my qw(%hash $cnt);

for (@array) { $hash{$_} = ++$cnt }

this sticks all those variables in one tidy hash, without upsetting strict
or polluting your namespace with tons of global variables...

just fyi,

Jos

> I am not sure if this will help but you might be talking about using soft
> references ... you would have to turn off strict to use it ...
>
> I could not get my head aroun your description of the problem but I had
many
> experinces when I had discussions with people at work who felt soft
references
> were the only way to get to the solution and then after discussing the
problem
> in the open realised that a data structure is actually an easy answer to
the
> problem ...
>
> example of soft reference ...
>
> my @array = qw( first second third );
> my $cnt = 1;
> foreach (@array) {
>     ${$_} = $cnt++
> }
> foreach (@array) {
>     print ${$_},"\n";
> }
> print "\$first is $first\n";
> print "\$second is $second\n";
> print "\$third is $third\n";
>
> do what you must ...
> On Tue, Jul 31, 2001 at 11:32:47PM -0400, Ron Woodall shaped the electrons
to read:
> > Hi Brett:
> >
> >          Thanks for the reply.
> >
> > At 12:08 PM 7/31/01 -0400, you wrote:
> > >On Tue, 31 Jul 2001, Ron Woodall wrote:
> > >
> > > >       I'm trying to take a word from a file and naming a scalar with
> > > > that word.  i.e. I find the word "target" in a file. I then need to
> > > > create $target = "xxx" and various other variables related to
target.
> > > > Any suggestions?
> > >
> > >Create a hash containing the keywords in the file:
> > >
> > >$akey = 'target';
> > >
> > >$file_data{$akey} = 'xxx';
> > >
> > >Or even a more complex data structure:
> > >
> > >$file_data{$akey} = { xxx => 'stuff',
> > >                         yyy => [1, 2, 3]
> > >                     };
> >
> >          Hmmmmm, I don't think this is going to work.
> >
> > >How exactly is the data in the file organized?
> >
> >          Here's the problem. Go to the Compendium of HTML Elements,
> > www.htmlcompendium.org --> Main Menu --> HTML --> Attribute Pages and
click
> > on one of the tag names.
> >
> >          The right frame will open up into a list of the tag and all
> > attributes/arguments documented to work with that tag. I'm in the
process
> > of completely restructuring the site and using a perl script. This is,
in
> > part a learning exercise for me.
> >
> >          Here's the problem. One tag will have 166 attributes plus
> > additional arguments for each attribute. The next tag will potentially
have
> > none. No two tags share all of the same attributes. I need to create a
> > series of scalars for each attribute such that each variable can be
> > directly addressed and decisions drawn from them and the new structure
> > constructed.
> >
> >          The process is to bring up a tag page, gradually work my way
down
> > the page parsing all of the pertinent information and storing it in
> > variables. The attributes are then sorted and the new structure is then
> > constructed using these variables.
> >
> >          When this program is complete, it will provide the shell for
the
> > next program which will do the same thing but will add new tags,
> > attributes, arguments, properties, values, methods and parameters.
> >
> >          Your help is much appreciated.
> >
> >          Ron Woodall
> >
> > ---------------------------------------
> > Ron Woodall
> > [EMAIL PROTECTED]
> >
> > The Compendium of HTML Elements
> > "your essential web publishing resource"
> >
> > - available at/disponible ?:
> > http://au.htmlcompendium.org/index.htm (Australia)
> > http://www.htmlcompendium.org/index.htm (Europe and North America)
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to