Ah, this was excellent for helping working on my debugging abilities. Here is what I did.

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()

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";
output:

$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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.