regex - perl script for reading data with in angular brackets < and > not working -


my task read data within angule brackets , write file. have developed script not working. if there modifications required please correct me.

the sample data want read this

textbooks written author1 `{ <sam>,<january>,<2015>},{<rga>,<feb>,<2005>},` 

this perl program

#!usr/bin/local/perl use warnings; use strict; @c_result;  @c_result_array; %hash; $file = 'c_template.c'; open cfile, $file or die "could not open $file: $!"; @content; $fileoutput="output_c.c"; open outfile,"> $fileoutput" or die $!; $i; while(<cfile>) { $i  (@content)     {         $_ = $i;         if(/<[\w*_*]+>/)         {             @c_result = /<[\w*_*]+>/g;             $i (@c_result)             {                  $key=substr($i,1,length($i)-2);                 $i=$key;                 push @c_result_array,$i;                 print outfile $i ."=>@c_result_array";                 print outfile "\n";             }         }        }    } close outfile; close cfile; 

for starters, never populate @content attempt iterate it.

in regular expressions: [] used define character classes, () used define capture groups.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -