$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;
In reply to Re: Is it possible to write the results of a subroutine for data formatting to a text file?
by aitap
in thread Is it possible to write the results of a subroutine for data formatting to a text file?
by supriyoch_2008
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |