Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by afoken (Chancellor)
on Mar 29, 2022 at 11:19 UTC ( [id://11142496]=note: print w/replies, xml ) Need Help??


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 (Bishop) 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.


    🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11142496]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-24 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found