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}; }; }; #### use strict; # Read from standard input while (<>) { # Remove the newline at the end of $_ chomp; # Split the input line on ":" or ";": my @pages = split /[:;]/; 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}; }; };