- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl question
Operating System - HP-UX
1822000
Members
3764
Online
109639
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
Discussions
Discussions
Discussions
Forums
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
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
тАО11-18-2003 10:03 AM
тАО11-18-2003 10:03 AM
Dear All,
I am trying to search for a string and replace with another in a perl script. The search string can be "clin" or "clin2" and replace string is "clin2".
Here is the example
$repl_str=clin2
$dir=/opt/data/clin/0001/view
# Search for clin? and replace clin with the replace string.
$dir =~ s/clin?/$repl_str/g;
### resulting value of $dir is /opt/data/clin2/0001/view which is O.K.
But it fails for scenario 2.
$repl_str=clin2
$dir=/opt/data/clin2/0001/view
# Search for clin? and replace clin with the replace string.
$dir =~ s/clin?/$repl_str/g;
### resulting value is $dir=/opt/data/clin22/0001/view,
but I expected the value as
/opt/data/clin2/0001/view.
Could some body help in modifying the search command. TIA
Kris
I am trying to search for a string and replace with another in a perl script. The search string can be "clin" or "clin2" and replace string is "clin2".
Here is the example
$repl_str=clin2
$dir=/opt/data/clin/0001/view
# Search for clin? and replace clin with the replace string.
$dir =~ s/clin?/$repl_str/g;
### resulting value of $dir is /opt/data/clin2/0001/view which is O.K.
But it fails for scenario 2.
$repl_str=clin2
$dir=/opt/data/clin2/0001/view
# Search for clin? and replace clin with the replace string.
$dir =~ s/clin?/$repl_str/g;
### resulting value is $dir=/opt/data/clin22/0001/view,
but I expected the value as
/opt/data/clin2/0001/view.
Could some body help in modifying the search command. TIA
Kris
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 11:38 AM
тАО11-18-2003 11:38 AM
Re: Perl question
the n? in clin? will match zero or 1 n.
that means it will match cli and clin.
your pattern should be clin.?
that means it will match cli and clin.
your pattern should be clin.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2003 07:58 PM
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
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP