in reply to Is it possible to write the results of a subroutine for data formatting to a text file?
$b=print_sequence($a,3);
You assign the $b variable the value of the expression print_sequence($a,3), but there is no return in your sub, so $b gets never assigned. You should return something from your sub if you want to assign it to a variable.sub print_sequence { my($sequence, $length) = @_; for (my $pos = 0; $pos < length($sequence); $pos += $length ) { print substr($sequence, $pos, $length), "\n"; } }
This can be done easier using die: die qq{Cannot open file "$output"\n\n};. You have some problems with your quoting. Perhaps reading Quote and Quote like Operators will help you.print"Cannot open file\"$output\".\n\n"; exit;
|
|---|