in reply to write to file in append mode
Take a look at perldoc -f open for a complete answer to this question. This will do what you want:
open(my $handle,">>","sample.txt") or die("Cannot write to file: $!\n");Note that this uses the three-argument version of open and uses a lexical variable as a filehandle, both are recommended best practices and you should stick to them (see the perldoc for why).
|
|---|