-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails with pragma #3
Comments
(I assume you meant The
Therefore, start $ perli -Mbigint
perli> 255->as_hex
'0xff' Alternatively, for a single input line: # pragma bigint is only in effect for the line at hand.
perli> use bigint; 255->as_hex
'0xff' |
no, i mean https://metacpan.org/pod/Math::BigInt#to_hex() as to the rest of the response, hm, thats not ideal. as python handles it: >>> import datetime
>>> datetime.date.today()
datetime.date(2019, 1, 26) and Ruby: irb(main):001:0> require 'date'
=> true
irb(main):002:0> Date.today
=> #<Date: 2019-01-26 ((2458510j,0s,0n),+0s,2299161j)> |
Yes, it's not ideal - I wish it worked the way you expected and the way Python and Ruby do it, but at least with the current implementation I couldn't make that happen (it's been quite a while since I've looked at it, though). |
It looks like this works as expected with Devel::REPL: $ re.pl
$ use bigint
$ 255->to_hex
ff and Reply: $ reply
0> use bigint
1> 255->to_hex
$res[0] = 'ff' |
Thanks, @cup. I'll reopen this and label it as an enhancement. I've never looked at these other REPLs (as you can probably tell, I'm not really much of a Perl guy) - have you used them enough to know their relative strengths and how they compare to this project? |
well maybe i am "doing it wrong" - but my primary use case is working from python3 -i -q <<eof
import datetime
datetime.date.today()
eof Result: >>> >>> datetime.date(2019, 1, 26)
>>> "Reply" can sort of do this: reply /dev/stdin <<eof
2 + 3
eof but it prints a lot of extra garbage, plus it doesnt exit at EOF, notice
and Devel::REPL cant do standard input at all, and it doesnt exit either:
|
Yeah, To get what you want with Perl, however, can't you just do the following? perl # invoke Perl and make it wait for stdin input. Then type your multi-line code and submit it with Ctrl-d |
i have another workaround. using #!/bin/perl
require $ARGV[0];
print "$ae\n"; You can use it with any input, as long as the input defines REPL.pl /dev/stdin <<'eof'
use bigint;
$ae = 255->to_hex;
eof Result:
|
works as expected:
$ perl -e 'use bigint; print 255->to_hex' ff
failure:
The text was updated successfully, but these errors were encountered: