I removed the \b from the processing.  On $one you never assign anything. 
Since you are really just finding a particular field and saving, why not use paras and 
if found then assign what is found.  I used __DATA__ to hold the data. Also the ? with 
regards to a regular expression needs to be
slashed since you want it.

Here is the output:

has been working very hard. What kind of computer is this? Since then,

Script:

#!perl -w
 while(<DATA>) {
         if (/(has been working very hard.)/){
            $one= $1;
          }elsif (/(What kind of computer is this\?)/){ 
            $two=$1;
          }elsif (/(Since then,)/){ # If it finds etc/etc then assign var.
            $three=$1;
          }
  }
  
$inputs = "$one $two $three";
print "$inputs \n";


__DATA__

        This is a test. has been working very hard.
junk adfadf afdafdafdasfas
asfdafda

asfdafdas
asfdafdas                 What kind of computer is this?
asfdadfasd
        
Since then, adfadf asfdasfd asfdasfdasf

-----Original Message-----
From: AMORE,JUAN (HP-Roseville,ex1) [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 30, 2001 12:59
To: Beginners@Perl. Org (E-mail)
Cc: AMORE,JUAN (HP-Roseville,ex1); John Amore (E-mail)
Subject: QUestion regarding this search script:


Hello Perl Experts,
Can anyone show me why the following script will only search and print "What
kind of computer is this?"
but not the rest of other two items; ie "has been working very hard." &
"Since then,"
These are sentences within a text paragraph file which I'm trying to capture
and display
to standard out.
Many Thanks:)

 while(<>) {
         if (/\bhas been working very hard.\b/){
         $one=;
}
        if (/\bWhat kind of computer is this?\b/){ # If it finds "people"
then assign var.
         $two="What kind of computer is this?";
}
        if (/\bSince then,\b/){ # If it finds etc/etc then assign var.
        $three="Since then,";
  }
}
$inputs = "$one $two $three";
print "$inputs \n";



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to