Running script and defining object value in terminal window

user1500158

When I run Perl scripts, I open up the Terminal window on my Mac and write "perl test1.pl" after moving to the folder containing the Perl script.

Often I find myself wanting to run the same Perl many times, usually at the same time, but with very minor changes.

For example say this Perl script "test1.pl" looks like this:

$year = 2001;
<rest of code that uses $year>

I want to execute "test1.pl" where $year = 2001, where $year = 2002, etc. To do this I usually run the script where $year = 2001, then adjust the script so $year = 2002, save, open new terminal window, run again, repeat.

Is there a way to submit the Perl script by designating in the terminal window the value for $year?

私は次のようなことを考えています:

perl test1.pl, $year = 2001
工具

これを行う1つの方法(多くの方法のうち)は次のとおりです。

my $year = (@ARGV) ? shift : 2001;

次に、次のように実行します。

perl test1.pl 2002

コマンドラインで年を指定しない場合、2001年はデフォルトになります。参照:perldoc -v @ARGV

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Script running from terminal but not in crontab

分類Dev

Running the script to invoke command in terminal

分類Dev

Open terminal window and execute Python script on startup

分類Dev

Running a command in a new terminal instance in a bash script

分類Dev

Printing the result of the script(running in background) on the terminal

分類Dev

JQuery: Defining a variable is stopping my script from running

分類Dev

getting value from foo into bar when defining object?

分類Dev

How to run Python script in a terminal window by double clicking it?

分類Dev

Pass R object to Python after running R Script

分類Dev

Handle terminal window closing

分類Dev

Pressing esc in a terminal window

分類Dev

Pressing esc in a terminal window

分類Dev

Running Python File in Terminal

分類Dev

Undefined object after defining a class

分類Dev

Javascript - Defining a Object with Array Properties

分類Dev

Defining time window in Esper CEP pattern

分類Dev

Script not connected to the terminal

分類Dev

require js defining modules in html script tags

分類Dev

Scroll in terminal while Vim is running

分類Dev

Extracting a value of an object key from inside the script element in the HTML

分類Dev

Using Compare-Object in a script: where is my return value?

分類Dev

Defining a Union Type from object values in Flow

分類Dev

Print the value of a Point to the terminal

分類Dev

Defining styles by value from a map function

分類Dev

Script not running at startup

分類Dev

Script running only once

分類Dev

Helping with this jquery script that is not running

分類Dev

How to check if GLFW window is running?

分類Dev

Running multiple executables in one window

Related 関連記事

ホットタグ

アーカイブ