473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

need help on perl reqex

4
Hi,

I'm new to perl. Can someone help me on the perl regex please!
Scenario:

I have a log file read in a variable $error which looks like:

<request type="update" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PortalConfig_1.2.xs d">
<status element="[url-mapping-context _C_0G3UNU10SD0GHOSD_TFR]" result="failed">
<message>com.ibm.wps.command.xml.XmlCommandExcepti on: XMLC0025E: The Resource was not found in the portal, either because it does not exist or because you have not specified an identifying attribute in the XML input. [url-mapping-context _C_0G3UNU10SD0GHOSD_TFR]</message>
</status>
</request>

XMLACCESS failed for importing /nas/app/PortalServer/teamsite/xml/wps/url_Mapping/deleted/C_0G3UNU10SD0GHOSD_TFR_makhtar_page1/C_0G3UNU10SD0GHOSD_TFS_urlmapping_makhtar_page2.xm l';

I want to do pattern matching based on the following:
1) if (<status element="[url-mapping-context) && ( /deleted/ i.e, path has deleted folder)
then return 0;
Nov 16 '06 #1
6 1293
GunnarH
83
Can someone help me on the perl regex please!
<data example snipped>

I want to do pattern matching based on the following:
1) if (<status element="[url-mapping-context) && ( /deleted/ i.e, path has deleted folder)
then return 0;
Can you please show us what you have tried?

Btw, why do you want a regex? Have you considered to use the index() function?
Nov 16 '06 #2
akhtar
4
I have so far tried, my first match works but second one doesn't:

if (($error_log_text =~ m/<status element=\"\[url-mapping-context/) && ($error_log_text =~ m/url_Mapping\/\deleted/)){
print "match found \n";
}else {
print "match not found\n";
}
Nov 16 '06 #3
GunnarH
83
Try without that backslash:
Expand|Select|Wrap|Line Numbers
  1. && ($error_log_text =~ m/url_Mapping\/\deleted/)
  2. --------------------------------------^
Nov 16 '06 #4
akhtar
4
cool! thanks! it works!
Nov 16 '06 #5
akhtar
4
What if I have to match
url-mapping-context
ignore the rest of next chars but match
result="failed"
Nov 16 '06 #6
GunnarH
83
Want to learn about regular expressions in Perl? Then read about regular expressions in Perl.

http://perldoc.perl.org/perlretut.html
Nov 16 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Roy Smith | last post by:
I'm working on a prototype of a new application in Python. At some point, if this ever turns into a product, the powers that be will almost certainly demand that it be done in Perl. My job will...
2
by: Paul Porcelli | last post by:
Hi folks, I have a perl one-liner embedded in a ksh script. perl -pi.bak -e "s/val/otherval/" inputfile I'd like to check the return code to know if the substitution was successful. If I...
1
by: Spamtrap | last post by:
I only do occasional Perl programming and most things I write are short processes. I have something I'm working on that is scanning a text file with about 15 million lines and trying to extract...
7
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a...
6
by: prieditis | last post by:
I need some very basic advice. Let's suppose I need to do some mysql queries and updates to a database. I also need to dynamically update parts of a web page that the user is looking at based on...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
2
by: MK | last post by:
Hello, I am new to XML and PERL and I have a few questions the answers to which I need to complete a project. All your time and effort would be highly appreciated. I have to make a small HTML page...
4
by: Freedolen | last post by:
Hi I found a website "http://www.gahooyoogle.com" which is a search engine and fetches result from both yahoo and Google. tried to develop a similar one but with more simpler and i...
1
by: vikjohn | last post by:
I have a new perl script sent to me which is a revision of the one I am currently running. The permissions are the same on each, the paths are correct but I am getting the infamous : The specified...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.