in reply to Request to sort out a problem in perl program for getting result as print "@a or $a" of a map function code

The only difference between printing to the STDOUT and print to a file is you provide a handle to say or print. So that means
say $fh length for split $motif, $string;
simply changes to
open(my $fh, '>', $qfn) or die("Can't create \"$qfn\": $!\n"); say $fh length for split $motif, $string;

No need to involve a variable, which would be done as follows:

my @lengths = map length, split $motif, $string;
  • Comment on Re: Request to sort out a problem in perl program for getting result as print "@a or $a" of a map function code
  • Select or Download Code