Perl Style: Switch Using for and do{} Even More Creatively

  • Sometimes, aesthetics counts. :-)

        for ($^O) {
            *struct_flock =                do                           {
    
                                    /bsd/  &&  \&bsd_flock
                                           ||
                                /linux/    &&    \&linux_flock
                                           ||
                              /sunos/      &&      \&sunos_flock
                                           ||
                      die "unknown operating system $^O, bailing out";
            };
        }
    

Forward to The Care and Feeding of Modules
Back to Switch with for via && and ||
Up to index

Copyright © 1998, Tom Christiansen All rights reserved.

Tags

Feedback

Something wrong with this article? Help us out by opening an issue or pull request on GitHub