Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Perl
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 13th, 2007, 02:21 AM
Registered User
 
Join Date: Sep 2007
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



 
Old September 15th, 2007, 11:16 AM
Authorized User
 
Join Date: Jul 2007
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
 
Old February 16th, 2010, 05: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
 
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!!!
 
Old May 28th, 2010, 12:25 AM
Registered User
 
Join Date: Mar 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anishkumar_k
Default

Try giving the arguments inside single quotes.
 
Old January 6th, 2012, 09:31 AM
Registered User
 
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..
 
Old April 19th, 2012, 08:22 AM
Registered User
 
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
 
Old September 14th, 2012, 10:44 AM
Registered User
 
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
 
Old October 18th, 2012, 06:36 PM
Friend of Wrox
 
Join Date: Dec 2003
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





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 01:22 AM
perl vidura Perl 6 December 7th, 2006 06:50 AM
perl jeet Perl 1 March 6th, 2006 05:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.