how to insert text between lines of an existing file using perl

Hi ,
I need some inputs on how to open a file (file.txt) and parse the text example aaa of the file and bbb of the file and add the text zzzz once i parse (aaa and bbb) and followed by the remaining of the text as it is in the file using perl programming.

Thanks in advance

open $FH,"<file.txt" or die $!;
$flag=0;
while(<$FH>){
    print;
    $flag=1 if /aaa/;
    if(/bbb/ && $flag) {
        print "zzzz\n";
        $flag=0;
    }
}
close $FH;

Thanks Pludi!.. But this code is printing the changes to screen but not the file.

On the command line, enter

$ perl addline.pl > newfile.txt

All modification will be in newfile.txt