Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No output in Commmand prompt from the code. 3

Status
Not open for further replies.

DaSe

Programmer
Feb 14, 2008
149
GB
Hi all ,

My question is regarding the code below.When I try to execute it there's no output in command prompt or other intrpreters ( it leaves a blank space ).I'm using ActivePerl and get "Hello World" correctly.I notice that the interpreter has problmes with Reg. expression operators =~ or maybe there's a unicode problems ? Thanks .


$myStr = "men";

if($myStr =~ m/ e{1}/)
{
print("e is found in $myStr");

} else {print("not ok") ; }

 
works just fine on activestate 5.8.8 (your code gets the not ok, removing the leading space before the e gets you is found message). I "think" that {1} format is only valid on 5.8 and above.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Hi Travs69.Thank you but I'm using the latest version of ActivePerl.I have been tryingy DzSoft Perl interpreter and the same thing - no output.Quite confused 'cuz it looks like the interpreter has only problems with binding operators.
 
Run this, then
Code:
use strict;
use warnings;

my $tilde = '~';

print ord($tilde), "\n";
Mine gives 126. If yours is anything else, looks like you have a character mapping problem.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Thanks Stevexff.Yep I ran it and indeed got 126 - what is even more confusing.Nonetheless , I agree with you that it might or is a character mapping problem.When I run 'edit' command in cmd - I cannot get tilde or hash symbol from the button on which they appear but get them from other buttons - the script however doesn't execute properly either.
 
DaSe

What are you using to edit the your Perl scripts? Not a word processor I hope...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Hi Steve.Yes, the truth is ( a brutal programming truth for you I guess ) is that I use notepad BUT I have tried to use DzSoft Perl and I also got no output...I have tried to save the files in Unicode / Utf-8 and it didn't solve a problem.However on one occasion I was getting the correct output from a file in another folder - what made be max confused - I replaced this file with the same of course extension and - no output still.
 
I need to add that I got no virues / trojans etc. and have spanking clean registry if that matters with no suspensions from the programs.
 
I "think" that {1} format is only valid on 5.8 and above.

The {n,n} {n} {,n} {n,} quantifier has been around for a long long time.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I wish I had a vista box to test with :) Have you asked on activestates forums?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Hi guys , yep I'm about to post it on Active State Vista forums.
 
DaSe,

is this all the code?

Code:
$myStr = "men";

 if($myStr =~ m/ e{1}/)
{
 print("e is found in $myStr");

} else {print("not ok") ; }

You are not loading any modules or pragmas?



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Hi Kevin.This is all.A basic code from a bigger one that I just noticed that it's not working.No modules , no pragmas.
When it has 'else' command - I get 'not ok' when I skip else command - I get a blank space.
 
I said I "think", I just never remember seeing it in the 5.6 documentation. But I do believe you [blues]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Hi Kevin.This is all.A basic code from a bigger one that I just noticed that it's not working.No modules , no pragmas.
When it has 'else' command - I get 'not ok' when I skip else command - I get a blank space.

Then the code is working. Your regexp will not match the string, Travis already explained why.

Travis said:
works just fine on activestate 5.8.8 (your code gets the not ok, removing the leading space before the e gets you is found message). I "think" that {1} format is only valid on 5.8 and above.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I said I "think", I just never remember seeing it in the 5.6 documentation. But I do believe you

Yes, just letting you know so it's no longer something you are unsure of. :)

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Hi Kevin.Look one more time at the code. If the match operator finds 'e' 1 time in the string 'men' then the output is 'e is found' when it doesn't then you get 'not ok'.But there is e in the string that appears 1 time and the output must be 'e is found' instead I get 'not ok' and if I don't use 'else' command I get a blank space . I'm a beginner but you confused me ? Or I'm completely wrong in this case ? Regards.
 
I got Kevin - I apologise.Yes I have removed the leading space and got this lovely output 'ok' . Thank you all guys for answers - you are much more than necessary with your great knowledge.Thanks to all.
 
You're welcome

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top