platbr has asked for the wisdom of the Perl Monks concerning the following question:

It is the second time that i come to you guys, the 1st one the answer came like from the Gods of Perl, not just from Monks =).

This question still concerned about Amanda Backup and bugs about weird caracters from my language (portuguese).

/usr/libexec/amanda/application/amsamba act like a filter for smbclient (app for backup windows shares) output, parsing lines to find errors and other usefull information.

The problem that still happening is:

Unmatched ( in regex; marked by <-- HERE in m/NT_STATUS_OK opening remote file design_grafico_17a_legislatura - deputadosdep_carlosantonioÅ3CT VISITADOSmosaico.ai ( <-- HERE design_grafico_17a_legislatura - deputadosdep_carlosantonioÅ3CT VISITADOS)/ at /usr/libexec/amanda/application/amsamba line 743, <GEN1> line 4.]

Line 743: return if $line =~$line =~ /Server not using user level security and no password supplied./;

Full code: https://github.com/zmanda/amanda/blob/master/application-src/amsamba.pl

How can i avoid this error guys?

Im not a programer =), so i realy need you.

After fix this i will submit a patch =).

UPDATE:

I UNDERTOOD THE PROBLEM

A folder with name "2013" is transformed in "Å3" because of "\2013"

I need to be sure that $line values wont be transformed like this.

UPDATE 2:

Im trying to solve this with:

return if m/\Q$line\E/ =~ m/\Q$line\E/ =~ /Server not using user level security and no password supplied/;

Tomorrow i will know if this fix the Amanda Backup.

SOLVED

To use m/\Q$line\E/ solved Amanda Backup problem.

=) Posted patch for amanda issues at https://github.com/zmanda/amanda/issues/48

Replies are listed 'Best First'.
Re: Perl Unmatched Errors
by McA (Priest) on Aug 16, 2013 at 14:48 UTC

    I'm not sure, but I think it's a simple editor bug (probably hitting . in vi after insert). Test whether this is ok:

    return if $line =~ /Server not using user level security and no passwo +rd supplied./;

    McA

Re: Perl Unmatched Errors
by Laurent_R (Canon) on Aug 16, 2013 at 17:16 UTC
    return if $line =~$line =~ /Server not using user level security and no password supplied./;

    Just one quick comment: the dot at the end of this regex is not doing what you probably think, it is a meta-character that will match any character (except new lines, unless you are in single-line mode). If you want to match a dot, you have to escape it, i.e. write \. This probably does not help you much on your problem, but it is still better to know it.

      i know that is a wild card, but the original code of amanda backup just used it, but for that propose it is useless, so i just removed it.
        "so i just removed it."
        That's probably a poor approach, if I understand you correctly (though very likely I don't).

        Why can't you escape it, instead, or use a quotemeta approach.

        If I've misconstrued your question, my apologies to all those electrons which were inconvenienced by the creation of this post.
Re: Perl Unmatched Errors
by ww (Archbishop) on Aug 16, 2013 at 20:17 UTC
    Based on what you've shown us, I'm of two minds:
    1. There appears to be a space (or some other char which didn't get rendered here) in the location before the head of the second arrow -- the one actually pointing out whatever it is that the regex engine thinks is "unmatched" in which case, diagnosing the problem will likely require a verbatim rendition of the error message (wrap error messages in code tags for our ease of reading).
    2. Alternately, the message says your regex is missing a parenthesis: I can't see that as accurate yet, because you show us an open paren as the second "word" in the error message, and another open at the second arrow, closed after the second "VISITADOS" ...
    If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.
      I GOT IT

      A folder with name "2013" is transformed in "Å3" because of "\2013"

      I need to be sure that $line values will be literal.

      do u know how can i do it ?

        Here are some tips:

        1. Read about Perl regular expressions to know better how to use the feature: see perlre.
        2. Understand your environment: Windows folders/files name usually get "weird" in Linux since the later usually uses Unicode for names and Windows not.
        3. Check the documentation about using Unicode with Perl in perluniintro.
        4. Read Markup in the Monastery. If your node looks better, you get a better change to get help.
        Alceu Rodrigues de Freitas Junior
        ---------------------------------
        "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
      I guess u are right about the parentheses, but this parentheses is part of $line value, it need to be literal, not part of a regex.

      So i guess i need be sure whatever value of $line it will not be "interpreted" by perl.

      Did i understand rightly?

      How can i do this? =D