Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Perl
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Perl section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old September 13th, 2007, 02:21 AM
Registered User
 
Join Date: Sep 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ghara
Default

Hi!
ive used this code...
#!/usr/bin/perl -w

use strict;
use warnings;

print "First Argument: $ARGV[0]";
print "\n********************\n";
print "Second Argument: $ARGV[1]";

and the output is....
First Argument: C:\First Folder\test
********************
Second Argument: C:Second Folder



Reply With Quote
  #12 (permalink)  
Old September 15th, 2007, 11:16 AM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by ghara
 Hi!
ive used this code...
#!/usr/bin/perl -w

use strict;
use warnings;

print "First Argument: $ARGV[0]";
print "\n********************\n";
print "Second Argument: $ARGV[1]";

and the output is....
First Argument: C:\First Folder\test
********************
Second Argument: C:Second Folder



it works.thank you very much..

-----------------------------------------------------------------------------------------------------------------------------------------------------------------
http://coco4info.com
http://alwaysdirectory.com
Reply With Quote
  #13 (permalink)  
Old February 16th, 2010, 04:20 AM
Registered User
 
Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hii,
I copied and pasted the code of yours and executed in my env. its working perfectly well. wat i have notices is that, i was in bash. in your terminal type "csh" which will set up the c shell env. its works perfectly well in this env.


[bala@DEV13 ~/Desktop]$ cat example.pl
#!/usr/bin/perl

use strict;
use warnings;

print "First Argument: $ARGV[0]";
print "\n********************\n";
print "Second Argument: $ARGV[1] \n";
[bala@DEV13 ~/Desktop]$ perl example.pl "D:\First Folder\test\" "D:\Second\ Folder"
First Argument: D:\First Folder\test\
********************
Second Argument: D:\Second\ Folder
[bala@DEV13 ~/Desktop]$


regards
Bala
Reply With Quote
  #14 (permalink)  
Old May 27th, 2010, 12:46 AM
Registered User
 
Join Date: May 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Solution!!!

use strict;
use warnings;

print "First Argument: $ARGV[0]";
print "\n********************\n";
print "Second Argument: $ARGV[1]";

and i save the code in a file test.pl

Try & execute this with quotes(") & slash(\) seperated with a space to get the desired output. Use as below:-
perl test.pl "D:\First Folder\test\ " "D:\Second Folder"

Last edited by anuragamodi; May 27th, 2010 at 12:47 AM. Reason: Solution!!!
Reply With Quote
  #15 (permalink)  
Old May 28th, 2010, 12:25 AM
Registered User
 
Join Date: Mar 2010
Location: India
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anishkumar_k Send a message via Skype™ to anishkumar_k
Default

Try giving the arguments inside single quotes.
Reply With Quote
  #16 (permalink)  
Old January 6th, 2012, 08:31 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default solution!

Hi

execute the script from command line as follows


perl test.pl "D:\First Folder\test\\" "D:\Second Folder"

i hope,this will work..
Reply With Quote
  #17 (permalink)  
Old April 19th, 2012, 08:22 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Cool

Quote:
Originally Posted by Freedolen View Post
Hi All,

 I am new to this Forum.

Below is my perl script:

use strict;
use warnings;

print "First Argument: $ARGV[0]";
print "\n********************\n";
print "Second Argument: $ARGV[1]";

and i save the code in a file test.pl

When I execute this with arguments
perl test.pl "D:\First Folder\test\" "D:\Second Folder"

The Output shown was:
First Argument: D:\First Folder\test" D:\Second
********************
Second Argument: Folder

The Output what I expect is:
First Argument: D:\First Folder\test
********************
Second Argument: D:\Second Folder

Is there any idea to get the output what i expect, without changing Backward slashes to Forward slashes or Deleting the Final slash in First argument

Thanks in Advance
Freedolen
hi....
just place \n after $ARGV[0].
THATS IT..
HAVE FUN
Reply With Quote
  #18 (permalink)  
Old September 14th, 2012, 10:44 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
you have used "\" which is an escape character. try to use \\ instead
Reply With Quote
  #19 (permalink)  
Old October 18th, 2012, 06:36 PM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

The following is redundant:

#!/usr/bin/perl -w
...
use warnings;

-w /means/ use warnings.

The previous poster means that when you use a \ character befor another it escapes that character. perl will read:

"D:\First Folder\test\" "D:\Second Folder"

As
"D:First Foldertest" "

So, place a \ before your \s and all will be well.
"D:\\First Folder\\test\\" "D:\\Second Folder"

Cheers
__________________
--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl help ZORCH Perl 3 April 25th, 2007 12:09 PM
char* argv in main() - counting and termination proslambano BOOK: Ivor Horton's Beginning Visual C++ 2005 1 March 14th, 2007 04:33 PM
char* argv to main - counting and termination proslambano C++ Programming 1 March 4th, 2007 12:22 AM
perl vidura Perl 6 December 7th, 2006 05:50 AM
perl jeet Perl 1 March 6th, 2006 04:06 PM



All times are GMT -4. The time now is 12:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.