The question is simple, but I haven't found the answer on Google.
How do I run in perl something like this?
[$] VARIABLE=foo ./script.sh
I have a perl script (Nvidia Cuda installer, for example) with hardcoded variables in the script, but I want to set that variables when I run the script instead of editing the script.
In bash it's like posted above, but I don't know how make this work on perl.
Is it possible to do this?
Greetings.
EDIT: For clarification: this is a sniplet of the install-linux.pl script:
sub can_add_for_all_users()
{
my $filename = "/usr/share/applications/.nvidiatoolkitinstall";
system("touch $filename 2>/dev/null");
if (-f $filename)
{
system("rm $filename");
return 1;
} else {
return 0;
}
}
I want to run something like this:
[$] filename="/tmp/.nvidiatoolkitinstall" perl install-linux.pl -destdir="${pkgdir}" -prefix="/opt/cuda" -noprompt -nosymlink
But this not works
I can do edit the script with sed:
[$] sed 's|/usr/share/applications/.nvidiatoolkitinstall|/tmp/.nvidiatoolkitinstall|g' -i install-linux.pl
but i want parser the variable to perl instead, like bash can do