in reply to [Perl 6]: Small discoveries V, True / False / FileNotFound
Scalar::Util has dualvar which returns a scalar with both a numeric value and a string value.
In theory, could do:
# untested sub alsoslick() { if do-stuff { return dualvar 1, "SomeValue"; # or just a non-0 numeric value } else { return dualvar 0, "Some error message"; } } my $result = alsoslick; if 0+$result { process( '' . $result ); # or just $result if non-error result is +numeric } else { log-error( '' . $result ); }
(Not as clean as Perl6.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [Perl 6]: Small discoveries V, True / False / FileNotFound
by b2gills (Novice) on Oct 24, 2017 at 23:19 UTC | |
by holli (Abbot) on Oct 24, 2017 at 23:56 UTC |