|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Perl file
Hi,
Can someone please tell me how to run a perl file in unix. for instance, I have one file or perl script saved as perl.pl and i have one text file and i want to run .pl file on .txt file.what should i do? Thanks |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
Quote:
Code:
perl myfile.pl where myfile.pl is your text file that contains Perl code. Alternatively, if your Perl script has the shebang in the first line - Code:
#!<path_to_perl_on_your_system> and you have executable permission on your script, then you can simply invoke your script as - Code:
myfile.pl or ./myfile.pl depending on whether or not you have the current directory (".") in your PATH variable. Quote:
Quite simply, you'd code something like this - Code:
open (IN, "myfile.txt") or die "Can't open myfile.txt: $!";
while (<IN>) {
# do whatever you want to do with the current record
# the "while" loop iterates through one record at a time
}
# good practice to clean up after you're done
close (IN) or die "Can't close myfile.txt: $!";HTH, tyler_durden |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
You can also run perl's one liner script using perl command with -e option Example: Code:
perl -e 'print "hello world\n"' |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extract string from a file & write to a new file (Perl) | LuckyGuy | Shell Programming and Scripting | 3 | 11-18-2009 09:43 AM |
| Perl : Process a file in perl | deo_kaustubh | Shell Programming and Scripting | 4 | 09-29-2009 08:44 AM |
| perl -write values in a file to @array in perl | meghana | Shell Programming and Scripting | 27 | 06-07-2009 05:05 PM |
| PERL:How to convert numeric values txt file to PACKED DECIMAL File? | aloktiwary | Shell Programming and Scripting | 1 | 05-20-2009 09:55 AM |
| Convert XML file into TEXT file using PERL seript | Rudro | Shell Programming and Scripting | 0 | 06-11-2008 10:03 AM |
|
|