Sub filemessage ($arg1) {
open(fh, '>', $message_file);
print fh "$arg1/n";
close fh;
}
You were very close.
In Perl, subroutines are created with the sub keyword (note the lowercase 's').
The newline escape sequence is \n, not /n.
These days, we like to use lexical variables as filehandles (this, among other advantages, will automatically close the file as the variable goes out of scope).
Using > as the file mode will create a new, empty file each time you open the file. So it will only ever contain the last message added. Switching to >> will append the messages.
You should check the return value from your call to open() and take appropriate action if it fails (usually killing the program is the best option).
You should declare and define $message_file somewhere. As it's a bad idea for a subroutine to access external variables, you probably want to do that inside the subroutine.
But your biggest problem is the line:
sub filemessage ($arg1)
Traditionally Perl's subroutine parameters are passed in an array called @_ and you need to extract them yourself.
my ($arg1) = @_;
But since Perl 5.20, there is an experimental signatures feature that works how you expect it to.
Putting all that together, we end up with this:
# turn on signatures (put this with the other "use"
# statements at the top of your file).
use experimental 'signatures';
sub filemessage ($arg1) {
my $message_file = 'log.txt';
open(my $fh, '>>', $message_file)
or die "Can't open [$message_file]: $!\n";
print $fh "$arg1\n";
}