What Am I Doing Wrong?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Healey

    What Am I Doing Wrong?

    Here is an edited fragment of the problem code.

    bunch of code...
    ..
    ..
    ..
    $Falbum="Sleep in Safety";
    $Talbum="45 Grave - Sleep in Safety";

    #I'm not actually assigning these strings in the code but prints show
    #that these are the values causing troubles.

    ..
    ..
    if ($Falbum ne $Talbum)
    {
    do stuff;
    }
    else
    {
    do other stuff
    }
    ..
    ..
    ..

    For some reason stuff isn't done and other stuff is but $Talbum is cleared.

    --
    Mark Healey
    marknews(at)hea leyonline(dot)c om

  • Joe Smith

    #2
    Re: What Am I Doing Wrong?

    Mark Healey wrote:
    [color=blue]
    > For some reason stuff isn't done and other stuff is but $Talbum is cleared.[/color]

    Works for me.

    linux% cat temp
    $Falbum="Sleep in Safety";
    $Talbum="45 Grave - Sleep in Safety";
    if ($Falbum ne $Talbum) {
    warn "Different: The two variables are not equal\n";
    } else {
    warn "They are equal\n";
    }
    linux% perl -w temp
    Different: The two variables are not equal

    You must have a typographical error somewhere.
    You need to come up with some real code to demonstrate
    the problem, and post that to comp.lang.perl. misc (not comp.lang.perl) .
    -Joe

    Comment

    • octoberdan
      New Member
      • Sep 2005
      • 18

      #3
      Somthing could have gone out of scope... I recomend you read this:

      It's a superb article and you would learn alot of usefull things.

      mine:
      Code:
      #!/usr/bin/perl
      
      use strict;
      use warnings;
      
      my $falbum;
      my $talbum;
      
      $falbum = "Sleep in Safety";
      $talbum = "45 Grave - Sleep in Safety";
      
      print "\$falbum = '$falbum'\n";
      print "\$talbum = '$talbum'\n";
      
      print "Therefor, ";
      
      if ($falbum ne $talbum) {
          print "they aren't equal!\n";
      } else {
          print "they are equal!\n";
      }

      Comment

      Working...