Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Just like that one text editor...

    I often use an idiom that I try to fetch an item, and if successful I want to do something with it; if not successful, the code returns undef (false). Typically, the code goes something like this:

    if(my $item = get_item(@params)) {
        # do something with $item
        print $item->{text};

    but this text editor complains about it, stating, in a dialog box:

    a single = in a conditional is usually a typo, use == or eq to compare.
    Do you want to continue?


    • It is a bug. You could report it (or at least ask on the Padre channels if this is a bug or a feature).

      We could tell you where to turn off the message until we fix the bug. By the way the the feature that is causing that error message is specifically designed to catch mistakes of beginners.

      The idea is to catch bugs that can be caused by code like this:

      if ($x = /boo/) {

      which is valid perl but it is unlikely a beginner would know what it actually does. The example you gave probably should not trigger

      • Oh and just to make a useful post as well, - after having dinner and being less grumpy - you can turn on/off the Perl beginner mode in "Edit/Preferences/Behaviour/Perl beginner mode" or "Tools/Preferences/Behaviour/Perl beginner mode" in newer versions of Padre.

        Also I think I have partially fixed that specific bug in 0.59 as it was also causing test failures in Padre where we also use similar constructs here and there.

        I think it is still buggy and eventually it should be implemented as a plugin for Perl::Critic to make it more roboust but that is waiting for someone to have the necessary tuits.