in reply to Re^3: In my it is printing in the else i want to get output for the for loop in linux.
in thread In my it is printing in the else i want to get output for the for loop in linux.

I am not sure about that.

It is perfectly allowed to use a character class Perl short-cut within brackets

I get the same results, but I wonder where that is documented ...

(Some doc searching and a short meeting later ...)

It's hidden in perlrecharclass:

You can put any backslash sequence character class (with the exception of \N and \R) inside a bracketed character class, and it will act just as if you had put all characters matched by the backslash sequence inside the character class. For instance, [a-f\d] matches any decimal digit, or any of the lowercase letters between 'a' and 'f' inclusive.

[...]

Examples:

/[\p{Thai}\d]/ # Matches a character that is either a Thai # character, or a digit. /[^\p{Arabic}()]/ # Matches a character that is neither an Arabic # character, nor a parenthesis.

So I stand corrected.


[\d] means the same as [0-9] [\w] would mean same as [a-zA-Z0-9_]

Well, that's only true if you ignore Unicode. perlre points to perlunicode, which has this nice short explaination:

\p{Word}
This is the same as \w, including over 100_000 characters beyond ASCII.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re^4: In my it is printing in the else i want to get output for the for loop in linux.
  • Select or Download Code

Replies are listed 'Best First'.
Re^5: In my it is printing in the else i want to get output for the for loop in linux.
by hippo (Archbishop) on Mar 29, 2022 at 12:14 UTC
    Well, that's only true if you ignore Unicode.

    Indeed. That's why we have the /a and /aa modifiers.


    🦛