suppose I have a file called sample.sql which I open in a .pl file
the file is something like this when opened in VI (unix editor)
šæselect * from a
where tablename = 'x';<some white space characters>
šæselect * from b
where tablename = 'x';<some white space characters>
šæselect * from c
where tablename = 'x';<some white space characters>
šæselect * from d
where tablename = 'x';<some white space characters>
šæselect * from e
where tablename = 'x';<some white space characters>
šæselect * from f;
where tablename = 'x'<some white space characters>
I want to clean this file.
I want to remove the first two non-word characters.
also each line in the file has a some white space characters after the ';' before the new line starts that I want to remove.
How do I use regular expressions to clean the contents of this and WRITE TO THE SAME FILE.
This file is generated by some other part of the code.
I have tried to use the following to read and write to the same file but doesn't seem to work
open(myfile,"+<$myfile");
also any help with the regular expression will be highly appreciated.
thanks..
bcdixit
the file is something like this when opened in VI (unix editor)
šæselect * from a
where tablename = 'x';<some white space characters>
šæselect * from b
where tablename = 'x';<some white space characters>
šæselect * from c
where tablename = 'x';<some white space characters>
šæselect * from d
where tablename = 'x';<some white space characters>
šæselect * from e
where tablename = 'x';<some white space characters>
šæselect * from f;
where tablename = 'x'<some white space characters>
I want to clean this file.
I want to remove the first two non-word characters.
also each line in the file has a some white space characters after the ';' before the new line starts that I want to remove.
How do I use regular expressions to clean the contents of this and WRITE TO THE SAME FILE.
This file is generated by some other part of the code.
I have tried to use the following to read and write to the same file but doesn't seem to work
open(myfile,"+<$myfile");
also any help with the regular expression will be highly appreciated.
thanks..
bcdixit