in reply to Using grep on windows
You've got a number of major problems.
You never execute snvlook, for starters.
@log will even only contain one string, but I suspect you want it to contain a number of strings.
grep returns the number of matches in scalar context, not the list of matched items.
If you did evaluate grep in list context, it would return the whole item that matched (the whole line, I presume), not just the CNR part.
It's very hard to match a quote (") before the start of the string (^).
You say your local variables are global. Expanding the scope of your variables is backwards. You want to take steps to limit the scope of your variable (by postponing declaring them until you need them, for starters).
Fix:
use strict; use warnings; my ($repo_path, $txn_name) = @ARGV; my $svnlook = "D:\\Subversion\\bin\\svnlook.exe"; my $committer = `$svnlook author $txn_name $repo_path` or die("Unable to get committer with svnlook.\n"); chomp($committer); my $commitlog = `$svnlook log $txn_name $repo_path` or die("Unable to get log message with svnlook.\n"); my ($cnr_number) = $commitlog =~ /^(CNR[0-9]+)/m or die("You must enter a valid CNR\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using grep on windows
by rogermills (Initiate) on Oct 27, 2009 at 20:56 UTC | |
by ikegami (Patriarch) on Oct 27, 2009 at 20:58 UTC | |
by rogermills (Initiate) on Oct 27, 2009 at 21:05 UTC | |
by rogermills (Initiate) on Oct 27, 2009 at 21:10 UTC | |
by ikegami (Patriarch) on Oct 27, 2009 at 21:20 UTC |