
gevni
Novice
May 21, 2013, 4:35 PM
Post #1 of 14
(4484 views)
|
Problem in regular expression!!
|
Can't Post
|
|
Hi i have csv file and i want to print the lines that have .java string in first column. I try to make some regular expression but it shows me some error. Can you plz check what I am doing wrong with regular expression. Thanks My csv file is
AST.java,1,1,1,1,7,0,6,0,1,7,7,134 AST.swt,1,1,1,1,7,0,9,0,0,7,7,138 AST.java,1,1,1,1,7,0,6,0,1,7,6,174 AST.swt,1,1,1,1,7,0,6,0,1,7,5,123 My code is
#!/usr/bin/perl use warnings; use strict; open (EXEC, "+<my_file.csv")or die("Could not open file."); open (FILE, ">>new.csv")or die("Could not open file."); while(<EXEC>) { chomp; if(/(\S+)\.\(\java\)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)\,\(\d+)/) { printf FILE "$_"; } } close(EXEC); close(FILE); exit;
|