This is the input text:
<title>Company Selection</title>
<link rel="stylesheet" type="text/css" href="../css/style_hbpSA_css.jsp" />
and I want to substitute the CSS reference with two lines:
<%@ include file="../common/cmufx.jsp" %>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/<fmt:message key="application.version"/>/css/style_hbpSA_css.jsp" />
Here's the Perl statement:
while(<>){
s{<link rel="stylesheet" type="text/css" href="../css/style_hbpSA_css.jsp" />}{
--><%@ include file="../common/cmufx.jsp" %>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/<fmt:message key="application.version"/>/css/style_hbpSA_css.jsp" />;};
print;
}
And in output I get:
<title>Company Selection</title>
-->
<link rel="stylesheet" type="text/css" href="<%=basePath%>/<fmt:message key="application.version"/>/css/style_hbpSA_css.jsp" />
- If I remove the '%>' element at the end of the first substituting line, I get the line to be printed.
- If the substituting line ends with '% >', it gets printed.
- If I escape the %, the line does not get printed
The whole source of my script:
#!/usr/bin/perl
use strict;
use warnings;
while(<>){
s{<link rel="stylesheet" type="text/css" href="../css/style_hbpSA_css.jsp" />}{
--><%@ include file="../common/cmufx.jsp" %>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/<fmt:message key="application.version"/>/css/style_hbpSA_css.jsp" />;};
s{<link rel="stylesheet" type="text/css" href="../css/style_hbp_css.jsp" />}{
<link rel="stylesheet" type="text/css" href="<%=basePath%>/<fmt:message key="application.version"/>/css/style_hbp_css.jsp" />};
s{<%@ include file="../common/cmufx.jsp" %>}{};
s{../img/banner.jpg}{<%=basePath%>/<fmt:message key="application.version"/>/img/banner.jpg};
print;
}