incorrect output

2006-09-27 Thread Geetha Weerasooriya
Hi,
 
I am extremely grateful to all those who answered my question and I am
happy to say that I was able to get a solution to my problem from the
suggestions and explanations given by you. I understood my mistakes and
learned a lot from you. 
 
Thanks again.
 
Best wishes,
 
Geetha
 


Re: regex help needed

2006-09-27 Thread Owen
On Wed, 27 Sep 2006 13:11:17 -0600
"Gerald Wheeler" <[EMAIL PROTECTED]> wrote:

> I am looking for: ab1in line1
> and looking for: ab2 in line 2
> 
> actually ab1 and ab2 immediately follow the last "/" (there are
> numerous "/" on the line (w/o quotes))
> 
> These are not working.  can some explain what these say and what they
> should say (syntax) to return the results I'm looking for: if ab1/ab2
> are in the line, return true.
> 
> /^[^\#]*ab1/,@lines
> 
> /^[^\#]*ab2/,@lines


Presumeably you want a match against '/ab1'

In which case you might just get by with /\/ab1/

But you may need to provide a few more specifications and example data

Owen

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




interpoliation within regexp

2006-09-27 Thread Derek B. Smith
I need to substitute a conversion using chr, but have
failed on multiple attempts.  Basically if the first
element contains a # then convert it. Will anyone
advise?

thank you
derek

#if first char is a-z then print it else warn
#chop string into individual characters

my @chars  = unpack
("A1" x length($password),$password);

if ($chars[0] =~ /^\D/) {
  print "Your new string is:\t",@chars,"\n";
}
else {
  print "string starts with number, now converting\n",
@chars, "\n";
  substr($chars[0],0,1) =~
s/\Q{$chars[0]}/{chr($chars[0]}\E/;
  print @chars;
}

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




regex help needed

2006-09-27 Thread Gerald Wheeler
I am looking for: ab1in line1
and looking for: ab2 in line 2

actually ab1 and ab2 immediately follow the last "/" (there are
numerous "/" on the line (w/o quotes))

These are not working.  can some explain what these say and what they
should say (syntax) to return the results I'm looking for: if ab1/ab2
are in the line, return true.

/^[^\#]*ab1/,@lines

/^[^\#]*ab2/,@lines

Thanks


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




perl question

2006-09-27 Thread elite elite

Does anyone know what tools come with perl 5.8.8?

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Dr. Camles Brain De-Age Game

2006-09-27 Thread Angerstein
Hi,
I had some spare time and write a perl version of dr. kamigawas brain
age / Big Brain Academy.
There are 6 Memory and Calculation tests. You need the Moduls
Heap-Simple and Time::HiRes.
If somebody adds further tests/games etc. please mail back.

Have Fun!


#!/usr/local/bin/perl
use Heap::Simple;
use Time::HiRes;




my @abc = (a .. z);
my $chars1 = 0;
my $chars2 = 0;
my $chars3 = 0;
my $chars4 = 0;
my $chars5 = 0;
my $string = undef;
$right = 0;
$wrong = 0;
$turns = 0;
# start timer
$start = time();

while ($turns <= 10){
  $chars1 = int(rand(26));
  $chars2 = int(rand(26));
  $chars3 = int(rand(26));
  $chars4 = int(rand(26));
  $chars5 = int(rand(26));
  $string = $abc[$chars1] . $abc[$chars2] . $abc[$chars3] .
$abc[$chars4] . $abc[$chars5];
  print "Keep the letters in mind!\n $string\n";
  sleep(1.5);
  for ( my $i = 1; $i <= 30; $i++) {
   print "\n\n\n\n\n\n\n\n\n\n";
  }
  print "Enter:\n";
  $input = ;
  chomp($input);
  if ( $input eq $string ) {
print "Very Good. $input is right! Feel Happy!\n";
$right++;
  } else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
  }
  $turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right  Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-0.2');
print "Your Score is $score!\n";






my $chars1 = 0;
my $chars2 = 0;
$right = 0;
$wrong = 0;
$turns = 0;
# start timer
$start = time();

while ($turns <= 10){
  $chars1 = int(rand(100));
  $chars2 = int(rand(100));
  print "Please Calculate: $chars1 + $chars2\n";
  print "Enter result:\n";
  $input = ;
  chomp($input);
  if ($input == ($chars1 + $chars2)) {
print "Very Good. $input is right!\n";
$right++;
  } else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
  }
  $turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right  Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-0.5');
print "Your Score is $score!\n";




my @abc = (a .. z);
my $chars1 = 0;
my $chars2 = 0;
$right = 0;
$wrong = 0;
$turns = 0;
# start timer
$start = time();

while ($turns <= 10){
  $chars1 = int(rand(26));
  $chars2 = int(rand(26));
  print "Which letter comes first?\n 1. $abc[$chars1] 2.
$abc[$chars2]\n";
  print "Enter:\n";
  $input = ;
  chomp($input);
  if ( ($input == 1) && ($chars1 < $chars2)) {
print "Very Good. $input is right!\n";
$right++;
  } elsif ( ($input == 2) && ($chars2 < $chars1)) {
print "Very Good. $input is right!\n";
$right++;
  } elsif ( ($input == 0) && ($chars1 == $chars2)) {
print "Very Good. $input is right!\n";
$right++;
  } else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
  }
  $turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right  Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-0.5');
print "Your Score is $score!\n";




my @list = ();
my $right = 0;
my $wrong = 0;
my $turns = 0;

# start timer
my $start = time();

while ($turns < 10) {
  $list[1] = int(rand(10));
  $list[2] = int(rand(10));
  print "Tell me which number is the largest (1. or 2.):\n";
  print "1. $list[1]2.  $list[2]\n";
  my $input = ;
  chomp($input);

  my $heap =  Heap::Simple->new(order => ">");
  $heap->insert($list[1], $list[2]);
  $count = $heap->count;
  my $larg = $heap->top;
  print "$larg $count\n";
  if ( $larg == $list[$input] ) {
print "Very Good. $input is right!\n";
$right++;
  } else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
  }
  $turns++;
}
# end timer
my $end = time();
my $tsum = ($end - $start);
print "Right: $right  Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-5');
print "Your Score is $score!\n";



$right = 0;
$wrong = 0;
# start timer
$start = time();
$turns = 0;
while ($turns < 10) {
  print "How many charakters do you see?\n";
  $chars = int(rand(16))+1;
  $lb =  int(rand(8));
  for ( my $i = 1; $i <= $chars; $i++) {
print "*";
if ($i == $lb ) {
  print "\n";
  $lb = int(rand(8));
}
  }
  print "\nEnter:\n";
  my $input = ;
  chomp($input);
  if ( $chars == $input) {
print "Very Good. $input is right!\n";
$right++;
  } else {
print "$input is wrong!!! Bad! Stupid!\n";
$wrong++;
  }
  $turns++;
}
# end timer
$end = time();
$tsum = ($end - $start);
print "Right: $right  Wrong: $wrong\nIn $tsum seconds!";
$score += &score($right, $wrong, $tsum, '-0.5');
print "Your Score is $score!\n";

##