2

Ordinarily I would invoke Perl and supply required arguments from within a bash script simply using:

perl script.pl arg1

However there are cases when I want to store both the perl script directory and the arguments in bash variables:

PERLDIR = "/example/directory/script.pl"
ARG1 = "40"

When trying to call the perl script using:

perl "$PERLDIR" 

It works, however when trying to provide the argument i'm not sure of the syntax to utilise. If I use:

perl "$PERLDIR $ARG1" it'll attempt to open the directory:

/example/directory/script.pl 40

And throw an error.

Is there a way to do this and if so, how?

1 Answer 1

4

You should use:

 perl "$PERLDIR" "$ARG1"

When you use many variables in one string enclosed with " it becomes one argument.

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

2 Comments

@Borodin Will do - and will also remove my comment.
@AnnaSchumann: I realise that you're getting to know the ropes. Thank you for understanding

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.