scusate ma vi sbagliate.
di lavorare in perl con variabili di shell, la sintassi corretta è: $ ENV {variabile}
esempio con una colorata funzione di uscita GCC:
n=$(tput setaf 0)
r=$(tput setaf 1)
g=$(tput setaf 2)
y=$(tput setaf 3)
b=$(tput setaf 4)
m=$(tput setaf 5)
c=$(tput setaf 6)
w=$(tput setaf 7)
N=$(tput setaf 8)
R=$(tput setaf 9)
G=$(tput setaf 10)
Y=$(tput setaf 11)
B=$(tput setaf 12)
M=$(tput setaf 13)
C=$(tput setaf 14)
W=$(tput setaf 15)
END=$(tput sgr0)
colorgcc()
{
perl -wln -M'Term::ANSIColor' -e '
m/not found$/ and print "$ENV{N}$`$ENV{END}", "$&", "$ENV{END}"
or
m/found$/ and print "$ENV{N}$`${g}", "$&", "$ENV{END}"
or
m/yes$/ and print "$ENV{N}$`${g}", "$&", "$ENV{END}"
or
m/no$/ and print "$ENV{N}$`$ENV{END}", "$&", "$ENV{END}"
or
m/undefined reference to/i and print "$ENV{r}", "$_", "$ENV{END}"
or
m/ Error |error:/i and print "$ENV{r}", "$_", "$ENV{END}"
or
m/ Warning |warning:/i and print "$ENV{y}", "$_", "$ENV{END}"
or
m/nsinstall/and print "$ENV{c}", "$_", "$ENV{END}"
or
m/Linking |\.a\b/ and print "$ENV{C}", "$_", "$ENV{END}"
or
m/Building|gcc|g\+\+|\bCC\b|\bcc\b/ and print "$ENV{N}", "$_", "$ENV{END}"
or
print; '
}
si desidera davvero utilizzare un 3 arg aperto qui per evitare una vulnerabilità di sicurezza. – xenoterracide
Potrebbe anche fornire collegamenti: http://stackoverflow.com/questions/318789/whats-the-best-way-to-open-and-read-a-file-in-perl http://stackoverflow.com/ questions/1479741/why-is-three-argument-open-calls-with-lexical-filehandles-a-perl-best-practice – daxim