0

I'm newbie in perl and I got some problem with one thing.

I have code:

$original_file = "y:\\Users\\XXX\\perlScript\\test1.xml";
$new_file = "y:\\Users\\XXX\\perlScript\\summary_test1.xml";
copy($original_file, $new_file) or die "File cannot be copied";

I need read path from cmd command line (I use batch file). For Example:

>summary.bat c>\path\file_name.xml

After copy I'd like create summary_file_name.xml to same folder

Thanks

1
  • 2
    Did you really type in c>\path\file_name.xml or did you mean to type a colon instead? Commented Apr 24, 2012 at 10:19

2 Answers 2

1

Are you asking how a Perl program gets its command line arguments? You'll find them in the @ARGV array.

Sign up to request clarification or add additional context in comments.

Comments

0

You want to use File::Basename. This is a standard library in Perl, at least as early as 5.14, so you do not need to install anything new.

use File::Basename;
my($filename, $directories, $suffix) = fileparse($original_file);
my $new_file = $directories . "/summary.xml";

For more information, see the Perl Docs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.