use String::Iota qw(trim strim dismantle); my $str = 'Just another perl hacker'; print trim($str, 4); # 'Just' print strim($str, 'p'); # 'Just another ' @info = dismantle($str); print join q{, }, @info; # '24, J, u, s, t, , a, n, o, t, h, e, r, , p, e, r, l, , h, a, c, k, e, r' { open my $fh, '<', 'test.txt'; while (<$fh>) { trim($_, 40); # Trim every line of test.txt to 40 characters strim($_, q{#}); # Get rid of comments } }