Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Help creating a subroutine that parses a text file and adds it back to the subroutine to be printed out

by csmith992 (Initiate)
on Aug 29, 2011 at 02:26 UTC ( [id://922934]=perlquestion: print w/replies, xml ) Need Help??

csmith992 has asked for the wisdom of the Perl Monks concerning the following question:

I am very new to perl and I need to do the following: from a module name.pm file, find a text file, open it, find the string 0xF110000C00 and then on the next line after that I have to parse the string: 0x0402000000000100020003000400060007000800100000000000000000000000000000000000000 0000000000000 This would be version 04.02.00 and then continue to 0001 says slot 1, 0002 says slot 2, and so forth. Create a subroutine and in the perl module fru.pm that will Find the record in discovered information a. Parse the string into bytes b. Decode it into a HASH structure c. {version} {current} {major} {current} {minor} {current} {maintenance} {current}{patch} {current}{aux1} {current}{aux2} {backup} {major} {backup} {minor} {backup} {maintenance} {backup}{patch} {backup}{aux1} {backup}{aux2} {fruid} Return the hash d. If optional param is true, print a nice table of this output e. Usage: $sys->{'1_2'}{slot}7->getFUMIStatusRecord() This is not for a class. This is for my knowledge only. Any help would be appreciated. I am using linux. Thanks, Craig
  • Comment on Help creating a subroutine that parses a text file and adds it back to the subroutine to be printed out

Replies are listed 'Best First'.
Re: Help creating a subroutine that parses a text file and adds it back to the subroutine to be printed out
by GrandFather (Saint) on Aug 29, 2011 at 03:38 UTC

    What does your current code look like and how does it fail?

    Even more so when your avowed intent is learning than with homework it is important to show what you have tried and to show that you have made an effort. You learn almost nothing if we give you an answer (even if we could understand what you are trying to do). But you will learn a great deal, even if you fail to achieve what you set out to do, when you have a good go at solving the problem for yourself first.

    You may find perlretut, substr and (maybe) unpack helpful.

    True laziness is hard work
Re: Help creating a subroutine that parses a text file and adds it back to the subroutine to be printed out
by Anonymous Monk on Aug 29, 2011 at 02:55 UTC
Re: Help creating a subroutine that parses a text file and adds it back to the subroutine to be printed out
by Marshall (Canon) on Aug 29, 2011 at 11:51 UTC
    This looks like a class assignment that is way over your head!
    That is obvious due to the framing of the question like: "from a module .pm file".

    The description of the problem does not describe the desired end result.

    I have no idea what "0xF110000C00" means.
    The second line could mean like this:

    0x040200 0000 0001 0002 0003 0004 0006 0007 0008 0010 0000 0000 0000
    I have no way to help you without more information.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://922934]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2024-04-25 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found