So, I know this shouldn't be as hard as I'm making it,
but I've having trouble using $_ in a sub {} in a foreach loop.
My $_ ends up being a "" when I push the button. I know there's a way to do this, and, in fact, I know I've done it before but for the life of me I can't figure it out.
xhonzi
but I've having trouble using $_ in a sub {} in a foreach loop.
Code:
@names=qw\Matt Todd Justin\;
foreach (@names) {
$mw->Button(-title=>"$_",-command=>sub{print "My name is $_!\b"})->pack;
}
My $_ ends up being a "" when I push the button. I know there's a way to do this, and, in fact, I know I've done it before but for the life of me I can't figure it out.
xhonzi