in reply to way of declare an integer variable instead use /^\d+$/
I have to guess...
You could use Tie::Scalar to make sure that a var $x will always stay an integer, by declaring STORE. But that will slow down every operation on $x.
And you can define an attribute :Int for that° as syntactic sugar.
my $x :Int = VALUE
Compare https://perldoc.perl.org/Attribute::Handlers#Attributes-as-tie-interfaces
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
°) that Tie::Scalar class you define
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: way of declare an integer variable instead use /^\d+$/
by vincentaxhe (Scribe) on May 25, 2024 at 09:25 UTC | |
by LanX (Saint) on May 25, 2024 at 22:14 UTC | |
by vincentaxhe (Scribe) on May 26, 2024 at 00:57 UTC | |
by LanX (Saint) on May 26, 2024 at 11:15 UTC | |
by BillKSmith (Monsignor) on May 26, 2024 at 19:49 UTC |