Y
Yakov
Is there a function that tests whether $_[0] is bound to modifiable
variable (like in foo($var)) or to non-modifiable variable (like in
foo("str")) ?
The context of my question is like this:
sub chompit { # chomp + returns the result + modify the arg if
possible
if(modifiable($_[0])) {
# is there any modifiable() function ?
chomp($_[0]);
return $_[0];
} else {
# we can't apply chomp() to the arg, it's constant
my ($copy) = shift;
chomp($copy);
return $copy;
}
}
$result = chompit(`date`); #arg is constant
$result = chompit($_); # arg is not constant
Thanks
Yakov
variable (like in foo($var)) or to non-modifiable variable (like in
foo("str")) ?
The context of my question is like this:
sub chompit { # chomp + returns the result + modify the arg if
possible
if(modifiable($_[0])) {
# is there any modifiable() function ?
chomp($_[0]);
return $_[0];
} else {
# we can't apply chomp() to the arg, it's constant
my ($copy) = shift;
chomp($copy);
return $copy;
}
}
$result = chompit(`date`); #arg is constant
$result = chompit($_); # arg is not constant
Thanks
Yakov