Re: Variable/multi-line substitution



droman@xxxxxxxxxxxxxxxxx wrote:

<snip: description of objective>


I try to substitute as follows:

s/$dateIRIG_CHT 6/$dateIRIG_CHT 6\n$dateMBET_CHT 6\n.../i;

$dateIRIG_CHT is a valid variable name and , in your case, is likely to have no value set for it. You can use curly brackets to clarify what you want thus: ${date}IRIG_CHT


Try
 use strict;
 use warnings;
as I believe is suggested in the posting guidelines for this newsgroup.
This ought to catch this sort of error for you.


Obviously, I'm a Perl newbie and am getting the syntax wrong or using
substitution for too difficult of a task, because I can't get it to
work.

I suspect you could simplify your code by making better use of regular expressions in substitutions - you may not need a separate $date variable at all.
.




Relevant Pages

  • iterating with a substitution
    ... How can I combine the substitution and matching in the example below? ... use strict; ... use warnings; ...
    (comp.lang.perl.misc)
  • Re: iterating with a substitution
    ... How can I combine the substitution and matching in ... use strict; ... use warnings; ...
    (comp.lang.perl.misc)
  • runs but cant detect the error
    ... Can anyone clarify as to why this is not working, it compiles and runs, but ... use strict; ... use warnings; ...
    (comp.lang.perl.misc)
  • eval()ing a pattern substitution under use strict and lexical scope
    ... I have two perl progs, both expected to do the same, evaling a ... pattern substitution expression using variables for the substitution ... The first prog uses 'use strict' and lexical variables and looks like ...
    (comp.lang.perl.misc)
  • Combinatory logic
    ... Logics that replace variables with functions in order to clarify ... intuitive operations on variables such as substitution. ... arithmetic built from combinatory logic can contain all partial ...
    (sci.logic)