CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Am I drunk?

 



MediumDave
New User

Dec 23, 2010, 4:18 PM

Post #1 of 4 (709 views)
Am I drunk? Can't Post

OK, what the?? I don't remember drinking this morning, but what is this nonsense:

The code:


Code
printf( "VAL: '%s'\n", $r->{'change'} ); 
if( $r->{'change'} ne "?" ) {
printf( "It is NOT a question mark.\n" );
}
print Dumper( $r->{'change'} );


The output:


Quote
VAL: '?'
It is NOT a question mark.
$VAR1 = '?';


My head is caving in, please help - what am I doing wrong?


FishMonger
Veteran / Moderator

Dec 23, 2010, 6:38 PM

Post #2 of 4 (704 views)
Re: [MediumDave] Am I drunk? [In reply to] Can't Post

I'm not able to duplicate your issue.


Code
D:perl>type dave.pl 
#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my $r = { change => '?' };

printf( "VAL: '%s'\n", $r->{'change'} );
if( $r->{'change'} ne "?" ) {
printf( "It is NOT a question mark.\n" );
}
print Dumper( $r->{'change'} );


Quote
D:\perl>dave.pl
VAL: '?'
$VAR1 = '?';



MediumDave
New User

Dec 23, 2010, 8:45 PM

Post #3 of 4 (701 views)
Re: [FishMonger] Am I drunk? [In reply to] Can't Post

That's what I mean, I must be drunk or my computer is...

Actually, I am suspecting that the '?' isn't really a question mark, it may be a representation of something else....just pursuing this now...


MediumDave
New User

Dec 23, 2010, 8:54 PM

Post #4 of 4 (699 views)
Re: [MediumDave] Am I drunk? [In reply to] Can't Post

Yep, it is a null or rather ASCII zero, so the following code works:


Code
printf( "VAL: '%s'\n", $r->{'change'} );  
if( $r->{'change'} != 0 ) {
printf( "It is NOT a question mark.\n" );
}
print Dumper( $r->{'change'} );


Thanks for considering my plight :-)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives