catch a particular word from a specific line -perlscript

Hi,

App.log contains the data-

Value of DsRef =null
Recovery File exixts
Recovered readFile 20110509 17:00:00.369019 +0100s
The DsRef Recovered from Recovery.txt file : 20110509 17:00:00.369019 +0100
Recovered from Recovery.txt file

=================================================
And app.pl file contain the code-

=================================================

#! /usr/bin/perl -w
$ARGV[0]||='/home/user01/exercise/app.log';
open FX,shift;
while(<FX>) {
m/Recovered readFile (\w+)/ and do {
Date=$1;
$Date
};

}
close FX;

================================================== =
here my aim is to catch the date 20110509

and want to display Todays date="$Date"

but it gives an ERROR-

Can't modify constant item in scalar assignment at ./app.sh line 8, near "$1;"
Execution of ./app.pl aborted due to compilation errors.

please help me to run the above code and want to print the date.

Thanks in advance....

Regards ,
Priyanka

Missed the $. Also Include a print statement if you want to print whatever has matched.

#! /usr/bin/perl -w
$ARGV[0]||='/home/user01/exercise/app.log';
open FX,shift;
while(<FX>) {
m/Recovered readFile (\w+)/ and do {
$Date=$1;
print $Date;
};
 
}
close FX;

Thanks a lot :slight_smile: