while (<>) { # while reading standard input m|\(A/(.*?)/|; # Match the string which is between 'A/' and the # next '/'. Because there are multiple '/' we need # a '?' to specify minimal matching instead of # greedy. print "$1\n"; }