This works for me under WIN32 and linux, perl 5.6.0. C:\>type test.pl #!/usr/bin/perl use strict; use warnings; use diagnostics; open (OUTPUTFILE, ">./file.txt") || die "Oops $!"; my $tmp_dir = "foo"; my $dir = "bar"; if ($tmp_dir ne $dir) { print OUTPUTFILE "\n" . $tmp_dir . "\n"; $dir = $tmp_dir; } close OUTPUTFILE; C:\>perl test.pl C:\>type file.txt foo C:\> The only way I could reproduce the error you describe is to do this (ie put in a != in place of ne): C:\>type test.pl #!/usr/bin/perl use strict; use warnings; use diagnostics; open (OUTPUTFILE, ">./file.txt") || die "Oops $!"; my $tmp_dir = "foo"; my $dir = "bar"; if ($tmp_dir != $dir) { print OUTPUTFILE "\n" . $tmp_dir . "\n"; $dir = $tmp_dir; } close OUTPUTFILE; C:\>perl test.pl Argument "foo" isn't numeric in numeric ne (!=) at test.pl line 11 (#1 +) (W numeric) The indicated string was fed as an argument to an oper +ator that expected a numeric value instead. If you're fortunate the message will identify which operator was so unfortunate. C:\> If you genuinely have ne I suspect your perl may be broken!! If you have ne in the above code perl is quite happy even if both the vars *are actually numeric* vis: C:\>type test.pl #!/usr/bin/perl use strict; use warnings; use diagnostics; open (OUTPUTFILE, ">./file.txt") || die "Oops $!"; my $tmp_dir = 2; my $dir = 1; if ($tmp_dir ne $dir) { print OUTPUTFILE "\n" . $tmp_dir . "\n"; $dir = $tmp_dir; } close OUTPUTFILE; C:\>perl test.pl C:\> Note that this runs quite happily. Perl stringifies the numeric values in $tmp_dir and $dir for ne to use. Because the behavior you describe is not repeatable, and should not logically occur as perl should be automatically stringifying the values in $tmp_dir and $dir if required I suggest you may have a corrupt perl binary. It does happen. I agree that use strict; use warnings; and use diagnostics; may help. Unfortunately if you have a big script that was not written under use strict you will have a lot of tweaking to do yo get it to run (mostly declaring your variables with my), but other stuff too. Good luck Suggest testing on another box to test dud perl hypothesis tachyon

In reply to Re: Really dumb question... ('ne' not working) by tachyon
in thread Really dumb question... ('ne' not working) by Apathy

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.