regular expressions - math on backreferences

From: Chris Nolte (cgn3089_at_earthlink.net)
Date: 05/20/04

  • Next message: Joe Smith: "Re: regular expressions - math on backreferences"
    Date: 20 May 2004 08:57:38 -0700
    
    

    I want to write a Perl script to modify a bunch of my programming run
    scripts, where each script will have a number of lines that need to be
    incremented.

    Here is what I have tried:
    #!/usr/bin/perl -w
    use strict;

     foreach my $in (glob "run.cctm*") {
            chomp($in);
            open IN, "<$in" or die "can't open $in for input\n";
            my $out = "$in.new";
            open OUT, ">$out" or die "can't open $out for output\n";
            while (<IN>) {
                    s,NEXTDAY\s*=\s*jul(\d+),NEXTDAY = jul$1+1,;
                    print OUT;
            }
            close IN;
            close OUT;
    }

    original: set NEXTDAY = jul22
    desired : set NEXTDAY = jul23
    result : set NEXTDAY = jul22+1

    Thanks for any help on how to do this.

    Chris


  • Next message: Joe Smith: "Re: regular expressions - math on backreferences"

    Relevant Pages

    • Re: regular expressions - math on backreferences
      ... >> I want to write a Perl script to modify a bunch of my programming run ... >> scripts, where each script will have a number of lines that need to be ...
      (comp.lang.perl)
    • Re: GoTo in Java
      ... smaller, decomposed, functionality. ... maintaining script, ... > It used a component programming model and provided a visual development ... > package graphs as macros for use in other graphs. ...
      (comp.lang.cobol)
    • Re: Problem with a script
      ... I don't mean to offend you or discourage you from working with PHP, ... Reworking your huge script into something concise, ... that I have no understanding of loops is completely asinine. ... throw that in while I am on the subject of programming. ...
      (comp.lang.php)
    • Re: [regexp] Speaking of the /s modifier...
      ... should be sanitizes before, and to be on the secure side, the ... transformation script should do that too... ... I'm relatively new to programming in general (perl is my first ...
      (perl.beginners)
    • Re: Where does programming begin?
      ... If it is, then you're programming. ... But if you *are* generating your own control ... consider a script like this: ... programming, but per your explicit-decision-making criterion, none ...
      (comp.programming)