in reply to How to create variables for each hash key that has a value.

Let me guess: Probably what you really want is to generate a class on-the-fly where the attributes of the class are the keys of your hash which have defined values. If i guessed right you may take a look at Re^2: Building Perl classes dynamically based on an input schema/template. I think the example ibidem can be relatively easy customized for your needs. If this technique is useful in your case or at all is another question. But it works like a charm. See also Class::Tiny. Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help