in reply to Re^2: look for a word
in thread look for a word

Hi again, I am a beginner in perl and am not able to work this out. In the following string "05/27/05 03:03:30 ANS1802E The dir is '/usr' and there are 23 files" I want to be able to push the /usr to an array. I am not sure how to use the search pattern in perl.

Replies are listed 'Best First'.
Re^4: look for a word
by reneeb (Chaplain) on Jun 09, 2005 at 10:50 UTC
    look at the first answer in this thread (Re: look for a word). There you can find the solution...
Re^4: look for a word
by tchatzi (Acolyte) on Jun 09, 2005 at 11:10 UTC
    Your regex can small like this(be sure the string you need is inside ' ' as you shown us).......but all of them do the same job.....so its your choise.
    #!/usr/bin/perl -w use strict; my @match; while(<>){ push (@match,$1) if /'(.*)'/; }


    ``The wise man doesn't give the right answers, he poses the right questions.'' TIMTOWTDI