HACKER Nora <nora.hac...@stgkk.at> asked:
> > Try:
> >
> > my %stp_dirs = (    'mvb' => \%mvb_dirs,
> >                     'pkv' => \%pkv_dirs,
> >                     'av' => \%av_dirs,
> >                     'be' => \%be_dirs,
> >                     'vvw' => \%vvw_dirs );
> >
> > while ( my($sdir,$tdir) = each %{$stp_dirs{'mvb'}}) {
> >     print("SourceDir: $sdir\t\tTargetDir: $tdir\n");
> > }
> 
> Is that 'mvb' intentional? Also, I don't understand why to put '\%' in
> front of the values from the master hash. Nevertheless, I tried the
> alterations as suggested but the error remains:
> 
> Can't use string ("%mvb_dirs") as a HASH ref while "strict refs" in use
> at /opt/data/magna/wartung/tools/get_lieferung.pl line 145.

If you "use strict;" you may not use symbolic references, i.e. (mis)use a 
variable's name to create a reference to it. That's why I fixed your code 
by replacing the variable names with references to the variable I assumed you'd 
wish to address.

Maybe you should take a look at the perlref manpage (e.g. 
http://perldoc.perl.org/perlref.html) for a better explanation.

As for putting in a literal 'mvb' that was just to demonstrate the usage. Of 
course you can replace that with any expression evaluating to any key of 
%stp_dirs or whatever.

HTH,
Thomas


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to