Post History
Perl, 45 bytes Reads character from stdin. Prints result to stdout. perl -pe'$_=(y/VLD/012/?5:1)*10**y/XCM/123/r' y/// modifies $_ and returns number of substitutions y///r returns new stri...
#2: Post edited
- # [Perl], 45 bytes
- Reads character from stdin. Prints result to stdout.
- ```
- perl -pe'$_=(y/VLD/012/?5:1)*10**y/XCM/123/r'
- ```
- * `y///` modifies `$_` and returns number of substitutions
- * `y///r` returns new string with substutions applied
- * operations apply left to right so VLD is tried before XCM
- * non-number `I` is treated as zero in numeric context so doesn't need to be explicitly converted
- [Try it online!][TIO-mmn2u5eh]
[Perl 5]: https://www.perl.org/- [TIO-mmn2u5eh]: https://tio.run/##K0gtyjH9X1CUmVeSpqCkWqxgq6CkoxJv/V8l3lajUj/Mx0XfwNBI397UylBTy9BAS6tSP8LZV9/QyFi/6P9/T64wrgguHy5nLhcuX65/@QUlmfl5xf91C3IA "Perl 5 – Try It Online"
- # [Perl], 45 bytes
- Reads character from stdin. Prints result to stdout.
- ```
- perl -pe'$_=(y/VLD/012/?5:1)*10**y/XCM/123/r'
- ```
- * `y///` modifies `$_` and returns number of substitutions
- * `y///r` returns new string with substutions applied
- * operations apply left to right so VLD is tried before XCM
- * non-number `I` is treated as zero in numeric context so doesn't need to be explicitly converted
- [Try it online!][TIO-mmn2u5eh]
- [Perl]: https://www.perl.org/
- [TIO-mmn2u5eh]: https://tio.run/##K0gtyjH9X1CUmVeSpqCkWqxgq6CkoxJv/V8l3lajUj/Mx0XfwNBI397UylBTy9BAS6tSP8LZV9/QyFi/6P9/T64wrgguHy5nLhcuX65/@QUlmfl5xf91C3IA "Perl 5 – Try It Online"
#1: Initial revision
# [Perl], 45 bytes Reads character from stdin. Prints result to stdout. ``` perl -pe'$_=(y/VLD/012/?5:1)*10**y/XCM/123/r' ``` * `y///` modifies `$_` and returns number of substitutions * `y///r` returns new string with substutions applied * operations apply left to right so VLD is tried before XCM * non-number `I` is treated as zero in numeric context so doesn't need to be explicitly converted [Try it online!][TIO-mmn2u5eh] [Perl 5]: https://www.perl.org/ [TIO-mmn2u5eh]: https://tio.run/##K0gtyjH9X1CUmVeSpqCkWqxgq6CkoxJv/V8l3lajUj/Mx0XfwNBI397UylBTy9BAS6tSP8LZV9/QyFi/6P9/T64wrgguHy5nLhcuX65/@QUlmfl5xf91C3IA "Perl 5 – Try It Online"
