blob: 6b39a9c09ee6edc4ef061b384c795595bca4ee37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/usr/bin/env perl
#
# ch-1.pl - Remove leading zeroes from positive numbers
#
# Ryan Thompson <rjt@cpan.org>
use 5.010;
use warnings;
use strict;
no warnings 'uninitialized';
# Accept filenames or standard input
# The spec was a bit vague, so I'm choosing to only modify numbers that start
# at the beginning of a line. Change the ^ to a \b to work on any number
print s/^0+(?=[1-9])//r while (<<>>);
# Another cheeky way about it, if you are certain you only have +ve ints:
# say 0+$_ while (<<>>);
|