[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [off-topic] Best way to replace quotes with angle brackets



I think that a s/^#include "(\w+\.h)"/#include <$1>/ is close to what
you want.  The (foo) (1) notation means find this chunk nad store it. 
Then it is accessed as 1.  More could be used and they would be 2, 3,
etc.  The above regex is Perl notation.  It should move to any other
regex style fairly easy.

#!/usr/bin/perl

$infile = pop(@ARGV);

open(infile, INFILE) or die("Could not open $infile\n");
@FILE = <INFILE>;
close(INFILE);
open(infile, OFILE) or die("Could not open $infile for writing\n");

foreach $line (@FILE) {
	$line =~ s/^#include "(\w+\.h)"/#include <$1>/;
	print OFILE $line;
}
close(OFILE);

Not tested, but close.
-- 
=====
Linux, because I'd like to *get there* today


Reply to: