R
Rocco Melzian
Hello,
I am using regular expressions to filter words and numbers from $_ and
assign them to $1 and $2 for further use
$_ =~ m/(.*?)(-{0,1}\d+)$/;
How can I assign an alternative value to $1 and $2 if the regular
expression failed? (sometimes no there is no input, so I want to record
a failure message)
Problem is: the digit "0" is a possible value in $1 or $2
I was trying
if(!$1){
$var="alternativ values";
}
else{
$var=$1;
}
or
if($1 eq undef){
$var="alternativ values";
}
....
How cann I check whether a $scalar exists or not? Is there something
like the "hash exists-function"? Thanks for helping me.
Rocco
I am using regular expressions to filter words and numbers from $_ and
assign them to $1 and $2 for further use
$_ =~ m/(.*?)(-{0,1}\d+)$/;
How can I assign an alternative value to $1 and $2 if the regular
expression failed? (sometimes no there is no input, so I want to record
a failure message)
Problem is: the digit "0" is a possible value in $1 or $2
I was trying
if(!$1){
$var="alternativ values";
}
else{
$var=$1;
}
or
if($1 eq undef){
$var="alternativ values";
}
....
How cann I check whether a $scalar exists or not? Is there something
like the "hash exists-function"? Thanks for helping me.
Rocco