RosettaCodeData/Task/Strip-comments-from-a-string/Perl/strip-comments-from-a-strin...

8 lines
157 B
Perl

while (<>)
{
s/[#;].*$//s; # remove comment
s/^\s+//; # remove leading whitespace
s/\s+$//; # remove trailing whitespace
print
}