Before I have not used hash but I can see below as a two files. How to put its contents in such a way that it is easy to use the PIO_M_U_PIO55_1, PIO_M_U_PIO55_2 keys and 896, 895 as its values and in other files. . Similarly, the second file should be in the form of the value of UART_10, UART_13, etc. and the value of PIO_M_U_PIO55_1 etc. so that I 896 directly UART_10 < / Code>. Also welcome any other way ...
#define PIO_M_U_PIO55_1 896 #define PIO_M_U_PIO55_2 895 #define PIO_M_U_PIO57_3 894 #define PIO_M_U_PIO55_4 893 and so on ..... huge file similar file # UART_10 PIO_M_U_PIO55_1 #define UART_13 PIO_M_U_PIO55_2 #define UART_11 PIO_M_U_PIO57_3 and so on ...
< P> Define two things that you are trying to parse the file, and insert it into a hash. At a basic level, it is as follows:
Use strict; Use warnings; Use data: Dumper; Defines my%; Open (my $ input_fh, "& lt;" "input-file-name") or die $!! While (& lt; $ input_fh & gt;) {my ($ key, $ value) = (m / ^ \ s * # \ s * define \ s + (\ w +) \ s + (\ w +) / ); $ Define {$ key} = $ value; } Defines a print dumper; That's all there really a hash in a (Anarded) set of key-value pairs
No comments:
Post a Comment