Tuesday, May 29, 2012

how to run simple perl code on linux

Platform
Red Hat Enterprise Linux 5 (RHEL 5)

@Locate where the perl is installed.you can try where and which commands


[yeniceri@localhost ~]$ whereis perl
perl: /usr/bin/perl     /usr/share/man/man1/perl.1.gz


[yeniceri@localhost ~]$ which perl
/usr/bin/perl


@create a new file and type the following code

[yeniceri@localhost ~]$ vi test.pl 

#!/usr/bin/perl
print "hello world \n";

@execute test.pl

[yeniceri@localhost ~]$ perl test.pl 
hello world 

there's another way but you should grant access first


[yeniceri@localhost ~]$ ls -l test.pl
-rw-rw-r-- 1 yeniceri yeniceri 71 May 29 04:31 test.pl
[yeniceri@localhost ~]$ chmod u+x test.pl
[yeniceri@localhost ~]$ ls -l test.pl
-rwxrw-r-- 1 yeniceri yeniceri 71 May 29 04:31 test.pl
[yeniceri@localhost ~]$ ./test.pl
hello world


Reference;
http://www.tizag.com/perlT/perlvariables.php




No comments:

Post a Comment