in reply to simple parse question
$data = q` NCLOC Filename -------- ------------------------- 3198 X:/bs/al/src/eilass.pl `; ## Avoid binary: $data =~ s/\r\n?/\n/gs ; ## Split the top and content: my ( $top , $content ) = split(/\n--[-\s]+\n/s , $data) ; $top = "\n$top\n" ; $content = "\n$content\n" ; ## The col names: my ($col_name_1,$col_name_2) = ( $top =~ /\n(\w+)\s+(\w+)/gs ); ## The content by cols: my ($col_1,$col_2) = ( $content =~ /\n([^\s]+)\s+([^\s]+)/gs ) ; print "$col_1,$col_2\n" ; ## Now get your variables: my ($filename) = ( $col_2 =~ /([^\/]+)\/*$/gi ); my $lineOfCode = $col_1 ; print "$filename\n$lineOfCode\n" ; ## Or put inside a while to get all the lines ## of the content: while( $content =~ /\n([^\s]+)\s+([^\s]+)/gs ) { print "$1,$2\n" ; }
|
|---|