tag:blogger.com,1999:blog-4066189435941690951.post7720748840917045349..comments2024-03-06T00:09:47.160-08:00Comments on Perl Gems: How Many Times Did that Word Appear?cfrenzhttp://www.blogger.com/profile/15399048188784702551noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-4066189435941690951.post-48987416811128577262013-05-22T03:16:59.521-07:002013-05-22T03:16:59.521-07:00Solved it, thanks for your help, i got it parsing ...Solved it, thanks for your help, i got it parsing everything between '<' and '>'.<br /><br />Any idea on how to make it recursive?<br />http://stackoverflow.com/questions/16689082/recursive-open-files-in-perlnhttps://www.blogger.com/profile/16259555817959400210noreply@blogger.comtag:blogger.com,1999:blog-4066189435941690951.post-4515465796950132752013-05-21T08:10:41.793-07:002013-05-21T08:10:41.793-07:00Could you give me an example on how to do this wit...Could you give me an example on how to do this with xml parser?nhttps://www.blogger.com/profile/16259555817959400210noreply@blogger.comtag:blogger.com,1999:blog-4066189435941690951.post-8449618458526316452013-05-21T04:39:56.216-07:002013-05-21T04:39:56.216-07:00No luckNo lucknhttps://www.blogger.com/profile/16259555817959400210noreply@blogger.comtag:blogger.com,1999:blog-4066189435941690951.post-57156325880427879212013-05-21T01:41:11.927-07:002013-05-21T01:41:11.927-07:00I'm new to perl and programming in general so ...I'm new to perl and programming in general so i have no idea how to use that. But anyway i'll try your code. In case it doesn't work i'll try a xml parser. Thank you very much againnhttps://www.blogger.com/profile/16259555817959400210noreply@blogger.comtag:blogger.com,1999:blog-4066189435941690951.post-79573780221485658562013-05-20T19:02:04.978-07:002013-05-20T19:02:04.978-07:00You could theoretically use a modification such as...You could theoretically use a modification such as the following to perform this:<br /><br />#usr/bin/perl<br /><br />my $XML='<tag1><tag2></tag2><tag2></tag2></tag1>';<br /><br />while($XML=~/<(.*?)>/g){<br /> $count{$1}++;<br />}<br /><br />while( my ($key,$value)=each(%count)){<br /> print "$key => $value\n";<br />}<br /><br />However, this is the type of situation that you would probably be better served making use of an XML parsing module rather than regular expressions. An example of an XML parser would be XML::LibXML.cfrenzhttps://www.blogger.com/profile/15399048188784702551noreply@blogger.comtag:blogger.com,1999:blog-4066189435941690951.post-6665110461247014262013-05-20T04:13:03.315-07:002013-05-20T04:13:03.315-07:00Thank you so much, this was really useful. Is ther...Thank you so much, this was really useful. Is there anyway i can use wildcards with this? I need to count .xml tags in a file and need to know how many times each one apears, so the $bucket variable would be something like "<* *>" but it's only counting how many times the "<" appears. Is there any way to make it list count the expressions between <>?nhttps://www.blogger.com/profile/16259555817959400210noreply@blogger.com