- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: if loop
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2008 12:07 AM
02-12-2008 12:07 AM
if (m!\[(\d+)\]!)
Thanks,
Allan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2008 12:21 AM
02-12-2008 12:21 AM
Re: if loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2008 12:51 AM
02-12-2008 12:51 AM
Re: if loop
the if-condition ('if' is not loop) is true when matching a number in square brackets, like [12].
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2008 01:14 AM
02-12-2008 01:14 AM
Re: if loop
Thanks.
Allan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2008 04:58 AM
02-12-2008 04:58 AM
Re: if loop
I suspect this scripts tries to hack a website.
Is that really your idea?
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2008 05:03 AM
02-12-2008 05:03 AM
SolutionThis is a test for a match using a regular expression.
The 'm' means match. Perl allows many different delimiters to bracket the match and in this case the '!' character was chosen.
The opening ('[') and closing (']') bracket characters are escaped with a backslash so that they represent themselves in the match and not a character class.
The '\d+' stands for a digit that occurs one or more times but at least once.
The parentheses () surrounding the '\d+' tell the regular expression engine to capture any match it finds therein. The outer parentheses are syntax for the 'if' condition.
In all, the condition is true (a match) if the variable ($_) --- often a line read --- looks like:
[123]
If you do:
# perl -nle 'print $1 if (m!\[(\d+)\]!)'
...then you will see the digits that are surrounded by the square brackets echoed for every input that matches.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2008 11:18 AM
02-12-2008 11:18 AM