use strict; # Read from standard input while (<>) { s/;/\n/g; # this is just like sed s/:/\n/g; # this is just like sed # Now, split the input line on newlines, like awk will do: my @pages = split /\n/; for my $page (@pages) { # I'm using qq{...} instead of double quotes (") # so I don't have to escape the stuff in ugly ways print qq{$page\n}; }; };