#!/usr/bin/perl -w use strict; my $text =""; while () { s/\n/ /; #not graceful way of \n $text = $text.$_; #not either, but not main point... } #main point is to use match global (/g) #think about /m and /s options also #this is just an example of an idea.... # my @quotes = $text =~ m/["'](.*?)["']/g; print join("\n",@quotes),"\n"; __DATA__ "Mary and a little lamb", she said. She thought 'Hang on a tick'. this 'is a line spanning quote' and course not! I really do not know about the really stange things, "But this is another line span quote" Nobody loves me "Mary and a large lamb" this is just nonsense the PM said 'something' __END__ OUTPUT: Mary and a little lamb Hang on a tick is a line spanning quote But this is another line span quote Mary and a large lamb something