Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'coolstuffAdmin@64.202.163.2' (Using password: YES) in /home/content/c/o/o/coolstuffAdmin/html/cool/myinterests/Perl/perl-221005.php on line 5

Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) in /home/content/c/o/o/coolstuffAdmin/html/cool/myinterests/Perl/perl-221005.php on line 6

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/content/c/o/o/coolstuffAdmin/html/cool/myinterests/Perl/perl-221005.php on line 6

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/content/c/o/o/coolstuffAdmin/html/cool/myinterests/Perl/perl-221005.php on line 13

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/c/o/o/coolstuffAdmin/html/cool/myinterests/Perl/perl-221005.php on line 15
error, please contact webmaster
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/content/c/o/o/coolstuffAdmin/html/cool/myinterests/Perl/perl-221005.php on line 42

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/c/o/o/coolstuffAdmin/html/cool/myinterests/Perl/perl-221005.php on line 44
error, please contact webmaster Run Perl in One-line and Script files (My Interests) --- Coolman's Home

Run Perl in One-liner and Script files

Previously, we talk about the basics of Perl and you know how to run it in different Operating Systems.

However, if your program is short and you do not need to save the program. Is there any other choices?

Sure, in Perl you have two ways of running it. You can run Perl in script files as well as running it in One-liner.

Running Perl in script files

Running in script files, means you are running the ".pl" files. You should know how to do it.

If you are still new to Perl, know more from "What's Perl and why you should learn it?"

Running Perl in One-liner

Running Perl in One-liner means you are just typing one command to run the Perl script rather than saving the scripts in a ".pl" file.

Open console or in command mode, type the following command to try:

In Unix:

In Windows:
%perl -w -e 'print "Hello, World!\n";'

C:\Perl\bin\perl -w -e "Print \"Hello, World!\n\";"

Explanation:

In the above One-liners, "-w" means warnings on, "-e" means execute the scripts.

print "Hello, World!\n"; is the actual script to run.

Conclusion:

Running Perl programs in Script files is the common way to do it, however, you have another choice when you want to use Perl scripts to do some jobs in a faster way without opening text editor to create a new file.

Try One-liner and it is sometimes quite convenient and save your time.

Enjoy Perl, keep an eye on this section.

 

 

[加到最愛]  [回到首頁]  [我有話說...]

Copyright 2005 Coolman's Home. All rights Reserved
Contact me|Drop me a message|RSS 2.0

printerbottom
view more view more view more view more