Krishnan Hariharan wrote:
Hi all,
Hello,
I am trying a one-liner substitution for a content in
a file.
original file content
---------
signal TCLK_IN : std_logic;
signal TPOS_IN : std_logic;
---------
I want to change it as:
---------
signal TCLK_IN : std_logic;
signal TPOS_IN : std_logic := '0';
-------
I wrote this one liner,
perl -pi -e 's/signal TPOS_IN \: std_logic;/signal
TPOS_IN \: std_logic \:= \'0\';/' <file_name>
But here i get an error saying, "Unmatched single
quote".
Can you please give me an idea what is wrong and how
to overcome this?
You are using the (') single quote character to delimit the perl code so you
can't very easily use one inside the perl code.
One way to do it (it may not work depending on your shell.):
$ perl -le'print "one '\''two'\'' three"'
one 'two' three
A better way, we find from an ASCII table (man ascii) that the single quote is
character number 39 (047 octal or 27 hexidecimal):
$ perl -le'print "one \047two\047 three"'
one 'two' three
So that gives you:
perl -i -pe's/^(signal\s+TPOS_IN\s+:\s+std_logic)(?=;)/$1 := \0470\047/'
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/