Hi Chas Owens, Thanks for your reply.
I am getting the following error when running the code given in the mail. Can't locate XML/Twig.pm in @INC (@INC contains: /opt/perl_32/lib/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/5.8.3 /opt/perl_32/lib/site_perl/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/site_perl/5.8.3 /opt/perl_32/lib/site_perl /opt/perl_32/lib/vendor_perl/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/vendor_perl/5.8.3 /opt/perl_32/lib/vendor_perl .) at test.pl line 5. BEGIN failed--compilation aborted at test.pl line 5. Any thoghts on this? -----Original Message----- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: Thursday, January 17, 2008 9:38 PM To: Allam Reddy, Thomas Cc: beginners@perl.org Subject: Re: help me in reading the xml file On Jan 17, 2008 5:53 AM, Allam Reddy, Thomas <[EMAIL PROTECTED]> wrote: snip > I have got an xml like this below. I want to read this file in Perl > and want to retrieve the text which end with .xml. > > For example , I want to print the text "jms/hppjmsmodules-jms.xml", > since it ends with .xml snip > <descriptor-file-name>jms/hppjmsmodules-jms.xml</descriptor-file-name> snip There is a quick and dirty way and a right way. The quick and dirty way (which is prone to errors) is perl -ne 'print "$1\n" if m{([-/.\w]+[.]xml)}' file.xml The right way is to use an XML parser and look for the contents of the descriptor-file-name tag. #!/usr/bin/perl use strict; use warnings; use XML::Twig; my $t = XML::Twig->new( twig_handlers => { 'descriptor-file-name' => sub { print $_->text, "\n"; } } ); $t->parsefile($_) for @ARGV; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/