#!/usr/bin/perl -w use strict; while ( my $line = <> ) { if ( $line =~ m/(\(amazing.+?\))/) { my $string="$1"; @allstrings = ($string); } }