APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

perl help


© September 2006 anonymous


Author: anonymous
Date: Thu Sep 21 09:30:32 2006
Subject: perl help
Hi.. 
     I am going through following problem. 
Let me explain you.... 
 
 I have to extarct information from the file... 
 
lets file is x.v 
 
   module x; 
 
   pattern:start 
   p1; 
   p2; 
   endpattern 
  
   endmodule 
 
   module y; 
    
   pattern:xyz 
    p3; 
    p4; 
   endpattern 
    
   endmodule 
 
    
I am extracting information from the file and creating a hash map. 
I need to store.. 
 
{module name} = pattern content... 
 
here I will be like this 
 
hashmap{x} = p1 p2 
hashmap{y} = p3 p4 
 
How cam I do that.......... 
I am struggling... 
 

Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> perl help

6 comments


Inexpensive and informative Apple related e-books:

Take control of Apple TV, Second Edition

Take Control of High Sierra

Are Your Bits Flipped?

Take Control of iCloud

Take Control of IOS 11




More Articles by © anonymous






Thu Sep 21 09:35:24 2006: 2476   anonymous


Need a stopping condition...

ex:
module m1;

endmodule

module m2;

endmodule

so like
while<fp_ptr> {

if (/module\s*(\w)\)?.*/) {
my moduleName = $1;
}
parse till encounter endmodule... Then start from the beginning.
This condition I want.

}

The file can contain... n module definition.



Fri Sep 22 13:19:32 2006: 2478   TonyLawrence

gravatar
This smells like a course assignment.


There's nothing hard here.. it's pretty basic parsing.

I doubt anyone here is going to do your homework for you. If you provided code you tried to write that didn't work, we MIGHT help you out if you explain it well and aren't just dumping a bunch of junk.

Otherwise, sorry, but no.



Sun Sep 24 04:12:34 2006: 2480   anonymous


I think I have confused everybody...

Here in short what I want to do...

I want to extract pattern from the file which can come multiple times...

pattern_1 any_thingh

pattern_2:anything /*I want to extract
anything pattern_2 to pattern_3 and store that
anything in a string
pattern_3 */


pattern_4

patten2 - pattern3 can come multiple time inside patten1- pattern2..










Sun Sep 24 11:39:44 2006: 2481   TonyLawrence

gravatar
The only confusion is you thinking that people are going to write programs for you for free.

Perl's (link) "range" operator might help you..





Mon Sep 25 04:43:13 2006: 2482   anonymous


ok taken!! Thanks anyway....I think I will solve it






Mon Sep 25 16:41:58 2006: 2484   anonymous


Try the free sample chapter of the book Pro Perl Parsing. It will teach you what you need to know.

(link)

------------------------


Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





An atheist is just somebody who feels about Yahweh the way any decent Christian feels about Thor or Baal or the golden calf. As has been said before, we are all atheists about most of the gods that humanity has ever believed in. Some of us just go one god further. (Richard Dawkins)




Linux posts

Troubleshooting posts


This post tagged:

Forum



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode