Perl searching special words in lines

Hi , i am a new with perl, i want to made a script that find in file rows that start with specil words, as an example a line will start with"
.............................................
specialword aaa=2 bbb=5
.............................................

and to put this in a new file called "newfile"this with:
..............................................
aaa is equal with 2;
bbb is equal with 5;
..............................................

any ideea is very appreciated.

Thanx.

Something like this ?

$
$ cat data.txt
specialword aaa=2 bbb=5
blah blah
blah blah blah
specialword ccc=6 ddd=7 eee=8
blah
blah
specialword fff=9
$
$
$ perl -lne 'do {while (/ (\w+)=(\d+)/g){print "$1 is equal to $2"}} if /^specialword/' data.txt
aaa is equal to 2
bbb is equal to 5
ccc is equal to 6
ddd is equal to 7
eee is equal to 8
fff is equal to 9
$
$

tyler_durden

1 Like

Hi, thank you for your response, this is a good solution, like i told you i am very new with this language and i have a problem your solution recongnize only natural values but i want obtain something like this(i read more about perl but i don't find a solution for "."):
specialword aaa=2.2e-12

and solution:

aaa is equal to 2.2e-12

see you

perl -lne 'do {while (/\s(\w+)=(\S+)/g){print "$1 is equal to $2"}} if /^specialword/' inputfile