Hello, I am absolutely perplexed by the following subroutine:
sub getPlatform { my $os = `uname`; chomp($os); for ($os) { /HP-UX/ and do { return('HP'); }; /Linux/ and do { my $hardware = `uname -m`; chomp($hardware); for ($hardware) { /ppc/ and return('PPC'); /ppc64/ and return('PPC'); /i686/ and return('INTEL'); /x86_64/ and return('INTEL'); errorMsg("Could not determine platform type for '$hard +ware'"); } }; } }
I think I know what the overall function of the subroutine is, it returns the platform. But we programmers are taught that 'for' is universally a looping construct, whereas here its intended use appears to resemble that of a switch statement, but I am not sure. Can a monk enlighten this newbie? Thanks
In reply to for loop ? by stevensw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |