FoxtrotUniform has asked for the wisdom of the Perl Monks concerning the following question:
So I'm writing some code to perfect-shuffle two lists, and I want it to complain when it doesn't get lists of equal length. Which style is preferred?
Opinions?# .. or warn is homomorphic to the .. or die idiom, and is # phrased like an assert. @foo == @bar or warn "perfect_shuffle: lists must have equal length\n"; # explicit if makes adding cleanup easier, and is phrased # like an error check. if(@foo != @bar) { warn "perfect_shuffle: lists must have equal length\n": }
Edit: s/scalar \@/\@/g;; thanks adrianh!
--
F
o
x
t
r
o
t
U
n
i
f
o
r
m
Found a typo in this node? /msg me
% man 3 strfry
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Style: expr or warn vs. if..warn?
by hossman (Prior) on Jul 09, 2004 at 23:19 UTC | |
|
Re: Style: expr or warn vs. if..warn?
by blokhead (Monsignor) on Jul 09, 2004 at 23:52 UTC | |
|
Re: Style: expr or warn vs. if..warn?
by adrianh (Chancellor) on Jul 09, 2004 at 22:51 UTC | |
|
Re: Style: expr or warn vs. if..warn?
by Old_Gray_Bear (Bishop) on Jul 09, 2004 at 23:19 UTC |