stevensw has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: for loop ?
by philipbailey (Curate) on Aug 10, 2011 at 19:43 UTC | |
|
Re: for loop ?
by cdarke (Prior) on Aug 10, 2011 at 19:46 UTC | |
by DrHyde (Prior) on Aug 11, 2011 at 10:15 UTC | |
by cdarke (Prior) on Aug 12, 2011 at 08:24 UTC | |
|
Re: for loop ?
by ikegami (Patriarch) on Aug 10, 2011 at 19:47 UTC | |
|
Re: for loop ?
by DrHyde (Prior) on Aug 11, 2011 at 10:18 UTC | |
by Tanktalus (Canon) on Aug 11, 2011 at 21:13 UTC | |
|
Re: for loop ?
by kcott (Archbishop) on Aug 11, 2011 at 10:46 UTC |