Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Single digit Roman numeral

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...

posted 6mo ago by jhnc‭  ·  edited 6mo ago by jhnc‭

Answer
#2: Post edited by user avatar jhnc‭ · 2026-03-12T06:31:02Z (6 months ago)
  • # [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 by user avatar jhnc‭ · 2026-03-12T06:30:46Z (6 months ago)
# [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"