If 0, 1, 2, 100 in the examples above were used more than once in your program, would you create a symbolic name for them?
Not for the uses in your examples.
I do use enums for 0 and 1 where they are indexes in multi-dimensional arrays with the 0th element being an X coordinate and 1 the Y coordinate; and similar examples.
This is the results of a grep for "enum" in *.pl files in my junk directory:
1031775.pl:use enum qw[ NAME FREQ LEFT RIGHT ]; 1161363.pl:use enum qw[ IN DBI ]; 1161647.pl:use enum qw[ IN DBI_ENUM ]; 1177385.pl:use enum qw[ IN DBI_ENUM ]; 904729-2.pl:use enum qw[ CODE GRAPH START PATH SEEN ]; 904729-3.pl: use enum qw[ CODE GRAPH START PATH SEEN ]; CIDR.pl:use enum qw[ CIDR NETWORK SIZE RANGE ]; CIDR.pl:use enum qw[ FIRST LAST ]; dumpTree.pl:use enum qw[ LEFT RIGHT ]; dumpTree.pl:use enum qw[ WIDTH DEPTH NAME ]; FPstuff.pl:use enum qw[ X Y ]; GraphBench.pl: use enum qw[ CODE GRAPH START END PATH ]; GraphBench.pl: use enum qw[ CODE GRAPH START END PATH ]; hFP.pl: use enum 'KEY', 'VAL'; lazyTree.pl:use enum qw[ LEFT RIGHT ]; philo3.pl:use enum qw[LEFT RIGHT ALL]; plotTSP.pl:use enum qw[ X Y ]; plotTSP2.pl:use enum qw[ X Y ]; plotTSP3.pl:use enum qw[ X Y ]; SameFringe.pl:use enum qw[ LEFT RIGHT ];
In reply to Re^6: Perl vs Python revisited
by BrowserUk
in thread Perl vs Python revisited
by QuillMeantTen
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |