•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 397,851 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,330 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser:
Views: 2913 | Replies: 13
![]() |
•
•
Join Date: Jul 2007
Posts: 19
Reputation:
Rep Power: 2
Solved Threads: 0
hi,
I am new to perl. actually, i'm using perl with SOAP::Lite to access a web server. I wrote some code in a notepad and saved it in c:/perl/eg.
by typing 'perl filename.txt' after changing the directory into c/perl/eg> in command prompt, i am getting the result what i want. it is accessing the web server what i specified in the code and it's giving the output what i need. but i am unable to run pure perl script in command prompt. i typed a simple perl programme to print the elements of an array in a text file and saved it in the same location like earlier. and tried to compile it via command prompt just like earlier. but i can't get any result. and it's saying can't open perl script and there is no such file or directory. i don't understand what the problem is. could u please help with it as early as possible. actually, i have to add some perl code within the earlier code to read a text file and take the elements of that text file and to save them in an array. later those elements should be used one by one in a foreach loop in the code what i've written already. i hope u will solve my doubt as soon as possible.
thank you.
chandra
I am new to perl. actually, i'm using perl with SOAP::Lite to access a web server. I wrote some code in a notepad and saved it in c:/perl/eg.
by typing 'perl filename.txt' after changing the directory into c/perl/eg> in command prompt, i am getting the result what i want. it is accessing the web server what i specified in the code and it's giving the output what i need. but i am unable to run pure perl script in command prompt. i typed a simple perl programme to print the elements of an array in a text file and saved it in the same location like earlier. and tried to compile it via command prompt just like earlier. but i can't get any result. and it's saying can't open perl script and there is no such file or directory. i don't understand what the problem is. could u please help with it as early as possible. actually, i have to add some perl code within the earlier code to read a text file and take the elements of that text file and to save them in an array. later those elements should be used one by one in a foreach loop in the code what i've written already. i hope u will solve my doubt as soon as possible.
thank you.
chandra
Hi,
Depends,
1. you can write perl code and save it as .pl (for eg. program1.pl) and run.
2. make it executable by inluding shebang* line(in case of UNIX). To run on windows make sure you have set the path to perl interpreter correctly. Then you can run your program like,
The shebang* line, nothing but path to interpreter in your machine, for eg:
in windows( the path may be different on your machine. Depends on where you have installed Perl.
You can save the file with .pl extension.
Note: You can use -e option/switch only when you want to work under interpreter mode. i.e, when you want to check some piece of code,
eg. You can check above, KevinADC's post for that... how it goes... or check or check the piece of code.
For big programs you can write it in any editor(for eg. notepad or any suitable editor) and follow the instructions mentioned above.
kath.
•
•
•
•
so, u want me to write the code and save it in a text file and type perl -e and the file name on command line?
Depends,
1. you can write perl code and save it as .pl (for eg. program1.pl) and run.
2. make it executable by inluding shebang* line(in case of UNIX). To run on windows make sure you have set the path to perl interpreter correctly. Then you can run your program like,
>perl program1.plThe shebang* line, nothing but path to interpreter in your machine, for eg:
in windows( the path may be different on your machine. Depends on where you have installed Perl.
Perl Syntax (Toggle Plain Text)
#!C:\Perl\bin\perl.exe #shebang line # some code follows ...
You can save the file with .pl extension.
Note: You can use -e option/switch only when you want to work under interpreter mode. i.e, when you want to check some piece of code,
eg. You can check above, KevinADC's post for that... how it goes... or check or check the piece of code.
For big programs you can write it in any editor(for eg. notepad or any suitable editor) and follow the instructions mentioned above.
kath.
Last edited by katharnakh : Jul 18th, 2007 at 9:54 am.
challenge the limits
•
•
•
•
i typed a simple perl programme to print the elements of an array in a text file and saved it in the same location like earlier. and tried to compile it via command prompt just like earlier. but i can't get any result. and it's saying can't open perl script and there is no such file or directory.
lets see the code you typed and the commands you typed on the command line
Last edited by KevinADC : Jul 18th, 2007 at 1:52 pm.
•
•
Join Date: Jul 2007
Posts: 19
Reputation:
Rep Power: 2
Solved Threads: 0
#!/usr/bin/perl
print "content-type: text/html \n\n"; #HTTP HEADER
# DEFINE AN ARRAY
@coins = ("Quarter","Dime","Nickel");
# PRINT THE ARRAY
print "@coins";
print "<br />";
print @coins;
and i saved it as ex.txt in eg folder in perl folder. and then i opened the command prompt and changed the path to C:/Perl/eg> and then typed perl ex.txt. but its showing it can't open it as there is no such file or directory. but when i saved the same file as "ex.pl" and tried to execute it, the result is
content-type: text/html
Quarter Dime Nickel<br />QuarterDimeNickel
print "content-type: text/html \n\n"; #HTTP HEADER
# DEFINE AN ARRAY
@coins = ("Quarter","Dime","Nickel");
# PRINT THE ARRAY
print "@coins";
print "<br />";
print @coins;
and i saved it as ex.txt in eg folder in perl folder. and then i opened the command prompt and changed the path to C:/Perl/eg> and then typed perl ex.txt. but its showing it can't open it as there is no such file or directory. but when i saved the same file as "ex.pl" and tried to execute it, the result is
content-type: text/html
Quarter Dime Nickel<br />QuarterDimeNickel
Last edited by chandrag : Jul 19th, 2007 at 7:42 am.
•
•
•
•
#!/usr/bin/perl
print "content-type: text/html \n\n"; #HTTP HEADER
# DEFINE AN ARRAY
@coins = ("Quarter","Dime","Nickel");
# PRINT THE ARRAY
print "@coins";
print "<br />";
print @coins;
and i saved it as ex.txt in eg folder in perl folder. and then i opened the command prompt and changed the path to C:/Perl/eg> and then typed perl ex.txt. but its showing it can't open it as there is no such file or directory. but when i saved the same file as "ex.pl" and tried to execute it, the result is
content-type: text/html
Quarter Dime Nickel<br />QuarterDimeNickel
Hi,
Could you please post what message you got when you tried with
perl ex.txt . Because i am using perl 5.6.1 on my WinXP machine, and executed your code saving it as .txt file. I had no problem in executing the same.I even tried in my friend's machine which is Suse Linux, and is running perl, v5.8.8, there also i had no problem in running..
it sounds strange, i doubt you are doing some silly mistake or .....? Please post what you get when you try
perl ex.txt . Also which version of perl you are using.kath.
Last edited by katharnakh : Jul 19th, 2007 at 8:18 am.
challenge the limits
•
•
Join Date: Jul 2007
Posts: 19
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
Hi,
Could you please post what message you got when you tried withperl ex.txt. Because i am using perl 5.6.1 on my WinXP machine, and executed your code saving it as .txt file. I had no problem in executing the same.
I even tried in my friend's machine which is Suse Linux, and is running perl, v5.8.8, there also i had no problem in running..
it sounds strange, i doubt you are doing some silly mistake or .....? Please post what you get when you tryperl ex.txt. Also which version of perl you are using.
kath.
hi
i'm getting the below result when i run it.
content-type: text/html
Quarter Dime Nickel<br />QuarterDimeNickel
but why did it print <br /> as it is?
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Perl Marketplace
Other Threads in the Perl Forum
- Previous Thread: how to open web page using perl
- Next Thread: What Is Perl 6 ?


Linear Mode