push @powers, 2**$_ for 0..7;

sub bases {
 for (@_) {
     sprintf ("%08b", $_).
     sprintf ("%4d", $_).
     sprintf ("%4o", $_).
     sprintf ("%4X", $_).
     "\n";
 }
}

print bases @powers;
--------------------------------------------------------------------------------------
I'm learning about Networking and wrote this to display ways numbers can be represented.

My question is:
How can the 'for' loop within bases() output a list for 'print' as invoked in the last line of code? I've tried to using return() in the for loop, but that exits the bases() too soon. Some solutions: (1) put the print within the bases(). (2) push() into an array and then iterate over for printing. --- These work but I am wondering if there is a way to return() a list from the for-loop?

TIA,
Alex Gill

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to