in reply to passing @ to sub and getting back hash

Can you describe what you want to do in English? Looping over @_ but checking $_[0] in your loop makes not a lot of sense. Did you mean $_ instead?

"Return a hash" seems to mean different things to different people. Maybe you want return %enc;, which actually returns a list of alternating keys and values, not a hash at all, or maybe you want to return \%enc;, which returns a hashref. In either case, the caller needs to know what is going to come back and be doing the right thing with it. Your caller example is expecting a list, not a hashref.

Replies are listed 'Best First'.
Re^2: passing @ to sub and getting back hash
by convenientstore (Pilgrim) on Dec 31, 2007 at 21:17 UTC
    $_ was the problem, let me fix it in and get back to you guys.
    You guys are the best!! thanks.