Hi,
I've come several times against the following problem: I want to execute several command in one line, but Perl does not seem happy with this. Eg:
From the following string, I want only have C:/temp :
$dir = "C:/temp/test";
@array = split("/",$dir);
pop @array;
$ans = join("/",@array);
I would prefer to use the follwing syntax to avoid creating to many variables:
$dir = "C:/temp/test";
$ans = join("/",pop(split("/",$dir)));
But Perl refuses this syntax: Type of arg 1 to pop must be array....
Am I doing something wrong or does Perl not support this type of syntax?
I've come several times against the following problem: I want to execute several command in one line, but Perl does not seem happy with this. Eg:
From the following string, I want only have C:/temp :
$dir = "C:/temp/test";
@array = split("/",$dir);
pop @array;
$ans = join("/",@array);
I would prefer to use the follwing syntax to avoid creating to many variables:
$dir = "C:/temp/test";
$ans = join("/",pop(split("/",$dir)));
But Perl refuses this syntax: Type of arg 1 to pop must be array....
Am I doing something wrong or does Perl not support this type of syntax?