
Simple question about the print function
Hi,
are you storing that in a file and then trying to run it?
i would do it like this, first store the following code in a text file called
hello.
#!/usr/bin/perl
print "Hello, World!";
then, make the script executable with the command:
chmod +x hello
Then run the program with the command:
./hello
You can also produce exactly the same output with the following program:
#!/usr/bin/perl
print <<HELLO;
Hello, World!
HELLO
I learnt this trick just today ;-)
Also, in the example you gave you did not say whether you included
#!/usr/bin/perl on the first line of your program.
I hope I have been able to help you.
Kind regards,
martin
Quote:
> I'm attempting to learn perl and I don't understand a simple thing
> about the print function.
> If I have a one line program like this:
> print "Hello World!";
> it doesn't work. No errors when I run it with the -w option, it just
> does nothing. But if I also print a newline character it works fine:
> print "Hello World!\n";
> Things that make you go hmmmm...if someone could explain what is
> happening that would be great!
> Thanks,
> Matt
--
Posted from cache-wit-hsi.cableinet.co.uk [62.30.192.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG