in reply to Re^2: Looking to confirm a file against CVS as part of a loop
in thread Looking to confirm a file against CVS as part of a loop

Does that make sense?

It makes perfect sense, and I understood the original question. I didn't want to give you the answer directly, though. I wanted to give you the tools to help get the answer on your own. If you're unsure how to use the tools I gave you, please ask, but I'm not going to do your work for you. :-)

PS: As a hint, you are probably going to want to use one of the mothods I showed you to capture the output, then check if the output looks like a success or a failure. How exactly you do that is up to you.

  • Comment on Re^3: Looking to confirm a file against CVS as part of a loop

Replies are listed 'Best First'.
Re^4: Looking to confirm a file against CVS as part of a loop
by Seventh (Beadle) on Dec 21, 2004 at 15:44 UTC
    I appreciate it. :D

    Here's what I came up with:
    #################################### ## READ LOOP ## #################################### if ($read) { my $fh2 = new IO::File("<ccrConfig.cfg"); return unless($fh2); my @state2 = <$fh2>; my $state2 = join("", @state2); foreach my $f (@state2) { print "File is $f\n"; my $logoutput = qx(cvs log $f); if ($logoutput eq "RCS") { `cvs co $f`; else { print "File $f is not in CVS, skipping\n"; } } }

    Running a cvs log on any of the files in the list always starts with "RCS file: ...", so what I'm trying to do is:

    "If a cvs log of the file returns a string that starts with RCS, then check it out, otherwise print out that it's missing".

    And I'm getting this error currently:
    $ Global symbol "$logoutput" requires explicit package name at ccrutil +.pl line 5 6. Global symbol "$logoutput" requires explicit package name at ccrutil.p +l line 57. syntax error at ccrutil.pl line 59, near "else" syntax error at ccrutil.pl line 63, near "}" Execution of ccrutil.pl aborted due to compilation errors.
    I must be screwing up the syntax, but from what I can tell, isn't "$string = "text" the proper syntax for "contains"?

    Thank you very much once again.

      I am not sure what's causing the "Global symbol" error, but it's not in the code you've shown. The syntax error is because you forgot a curly bracket to end the if block.

      There is also a logic error, though. You are using eq to check for string equality, but this checks if one string matches another string exactly. So "hi" and "hi " would not match with eq.

      You probably want a pattern match, instead. This is covered nicely in perlretut, but here's a very quick example:

      foreach my $str ("one", "two", "three") { if ($str =~ /^t/) { print "'$str' starts with 't'\n"; } else { print "'$str' does not start with 't'\n"; } }
Re^4: Looking to confirm a file against CVS as part of a loop
by Seventh (Beadle) on Dec 22, 2004 at 17:58 UTC
    Got it working - Thank you all very, very much for taking the time to help me out! =)