Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

grantm (164)

  (email not shown publicly)

Just a simple [] guy, hacking Perl for fun and profit since way back in the last millenium. You may find me hanging around in the monestary [].

What am I working on right now? Probably the Sprog project [].

GnuPG key Fingerprint:
6CA8 2022 5006 70E9 2D66
AE3F 1AF1 A20A 4CC0 0851

Journal of grantm (164)

Thursday June 01, 2006
09:40 PM


[ #29783 ]

I just 'tidied up' some code from the form in sub_a (below) to the form in sub_b ...

my $sub = shift or die "must specify 'A' or 'B'\n";

if(uc($sub) eq 'A') {
else {


sub sub_a {
    my $hashref = hashref();
    while(my($k, $v) = each %{ $hashref }) {
        print "$k => $v\n";

sub sub_b {
    while(my($k, $v) = each %{ hashref() }) {
        print "$k => $v\n";

sub hashref {
  return { a => 1, b => 2, c => 3 };

I was surprised when my modified routine behaved in a different way to the original. When I thought about it, I realised what was going on and slapped myself. It's probably obvious to everyone else though.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.