HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl multiline search
Operating System - HP-UX
1831929
Members
3762
Online
110031
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
04-26-2010 05:40 AM
04-26-2010 05:40 AM
Hi,
I need a perl script (one-liner could be the best) which would return true when it includes
the word "start" followed by any text other than a word "with". "start" and "with" may be separated by any whitespace characters (space/tab/newline).
It sounds pretty straightforward but I have difficulties to reach the goal.
True examples (omit quotation marks and order numbers):
1. "start foo"
2. "start
foo"
3. "start
foo"
4. "start wi
th"
5. "start without"
False examples:
1."start with"
2."start
with"
3."start
with"
Thanks in advance.
I need a perl script (one-liner could be the best) which would return true when it includes
the word "start" followed by any text other than a word "with". "start" and "with" may be separated by any whitespace characters (space/tab/newline).
It sounds pretty straightforward but I have difficulties to reach the goal.
True examples (omit quotation marks and order numbers):
1. "start foo"
2. "start
foo"
3. "start
foo"
4. "start wi
th"
5. "start without"
False examples:
1."start with"
2."start
with"
3."start
with"
Thanks in advance.
Solved! Go to Solution.
- Tags:
- Perl
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2010 07:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2010 08:19 AM
04-26-2010 08:19 AM
Re: Perl multiline search
As an addition, for one-liners
BEGIN { $/ = undef; $_ = <> }
can ve shorthanded to a command-line option
perl -00
See 'man perlrun':
The special value 00 will cause Perl to slurp files in paragraph
mode. The value 0777 will cause Perl to slurp files whole because
there is no legal byte with that value.
So the above example can be shortened to
perl -00 -le'print m{start\s*.*with\s}s?0:1' file
Enjoy, Have FUN! H.Merijn
BEGIN { $/ = undef; $_ = <> }
can ve shorthanded to a command-line option
perl -00
See 'man perlrun':
The special value 00 will cause Perl to slurp files in paragraph
mode. The value 0777 will cause Perl to slurp files whole because
there is no legal byte with that value.
So the above example can be shortened to
perl -00 -le'print m{start\s*.*with\s}s?0:1' file
Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP