I ran a regex on the $gamedir variable to match the first non-character character and replace it with a "*". Sure enough there was an invisible character at the end of the string but I do not think it was a '\r' as I had already used s regex to strip '\r' (admittedly I may have done that part incorrectly though)...code to follow. Anway, I decided to simply chop() the last character (hoping there was only one) and that worked. Here is the code and output:
Finding the problem
my $funcName = (caller(0))[3]; my $player_name = shift; my $mapname = shift; (my $gamedir = &send(1,"sv_gamedir")) =~ s/.*: (.*)[\r\n]+/$1/; (my $testgamedir = $gamedir) =~ s/\W/*/; print STDERR "\$HOME = $HOME\n\$testgamedir = $testgamedir\n\$mapn +ame = $mapname\n";
output:
$HOME = /services/qw $testgamedir = fortress* $mapname = 2fort5 Map doesn't exist! -> /services/qw/fortress/maps/2fort5.bsp
As we can see by the
fortress*that there was at least one white character there.
After chop()
output:my $funcName = (caller(0))[3]; my $player_name = shift; my $mapname = shift; (my $gamedir = &send(1,"sv_gamedir")) =~ s/.*: (.*)[\r\n]+/$1/; chop($gamedir); (my $testgamedir = $gamedir) =~ s/\W/*/; print STDERR "\$HOME = $HOME\n\$testgamedir = $testgamedir\n\$mapn +ame = $mapname\n";
$HOME = /services/qw $testgamedir = fortress $mapname = 2fort5 Map exists! -> /services/qw/fortress/maps/2fort5.bsp
----------
- Jim
In reply to Re: Re: From chat to here :) chdir() and test -f issues.
by snafu
in thread From chat to here :) chdir() and test -f issues.
by snafu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |