On Oct 21, 11:06 am, [EMAIL PROTECTED] (Chas. Owens) wrote: > 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.
This works if there are 2 of each branch (as in the example). If there are more then the IF condition is true more times than I want. I only want a condition to be true for the transition to a new branch. Then I email the branch owner with the list. Right now I am just pushing a dummy entry onto the end of the list so my IF condition (if $branch ne $lastBranch) is true at the transition. Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/