Hello, Following the suggestion of one of you (sorry, don't remember who's...), I am skimming through my old Perl scripts and trying to improve them. Now I have a problem with one of them, after inserting "use strict;" - would be great, if you could help me:
The script is being started with a parameter $stp (among others) that can be one of mvb/pkv/av/be/vvw. This parameter is used as a key for a master hash the values of which are names of other hashes themselves. # Master-Hash my %stp_dirs = ( "mvb" => "mvb_dirs", "pkv" => "pkv_dirs", "av" => "av_dirs", "be" => "be_dirs", "vvw" => "vvw_dirs" ); # AV my %av_dirs=( "dir11" => "dir12" "dir13" => "dir14" ); # BE my %be_dirs=( "dir21" => "dir22" "dir23" => "dir24" ); # MVB my %mvb_dirs= ("dir31" => "dir32" "dir33" => "dir34" ); # PKV my %pkv_dirs=( "dir41" => "dir42" "dir43" => "dir44" ); # VVW my %vvw_dirs=( "dir51" => "dir52" "dir53" => "dir54" ); Before "use strict;" the replacement of $stp in the hash name below worked fine my ($sdir, $tdir); while (($sdir,$tdir) = each %{$stp_dirs{$stp}}) { DEBUG("SourceDir: $sdir\t\tTargetDir: $tdir\n"); } now I get an error: Can't use string ("mvb_dirs") as a HASH ref while "strict refs" in use at -e line 148. Can somebody please point me into the right direction? Also, I'd like to know whether this is "good practice" - I found something in the infinite depths of the www that using a variable in a name is a bad idea, but in this case I do not have any other idea how to accomplish that (at least, perlcritic.org didn't complain about that). Thanks in advance, Nora