On Tue, Oct 21, 2008 at 10:56, David Stiff <[EMAIL PROTECTED]> wrote:
> Hi Chas,
>
> There probably is a better approach.
>
> I am going through a list of Subversion branch names, e.g.
>
> BRANCH_1
> BRANCH_1
> BRANCH_2
> BRANCH_2
> BRANCH_3
> BRANCH_3
> BRANCH_4
> BRANCH_4
>
> and checking to see if $branch eq $lastBranch. Then I do something.
>
> The problem is that the last time through the loop, e.g. BRANCH_4,
> nothing happens because the IF never evaluates to true.

If I understand you correctly then this code should work for you:

#!/usr/bin/perl

use strict;
use warnings;

#open my $fh, "-|", "svn somehing"
#       or die "could not run 'svn something': $!";

my $old_branch = '';
while (my $new_branch = <DATA>) { #use $fh here instead of DATA
        chomp $new_branch;
        if ($old_branch eq $new_branch) {
                print "doing stuff to $new_branch\n";
        }
        $old_branch = $new_branch;
}

__DATA__
BRANCH_1
BRANCH_1
BRANCH_2
BRANCH_2
BRANCH_3
BRANCH_3
BRANCH_4
BRANCH_4



-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to