Thanks Anon, I had warnings on, the $line I mentioned is actually being pulled in from a file, so no quotes are actually around it. The debug thing is a great help though!
Aha. That is why its important (as How (Not) To Ask A Question would say) to clean your room, which is also part of How do I post a question effectively?
#!/usr/bin/perl --
use strict;
use warnings;
use Test::More qw' no_plan ';
Main( @ARGV );
exit( 0 );
sub Main {
my $line = q[F:\MF\BR\PreparedSources\acdv\test_dev\BeanName\Sessi
+onBean.RMWAppException.java];
my $olin = q[JAVAFILE "test_dev\BeanName\SessionBean.RMWAppExcepti
+on.java" "acdv" "##All"];
is( $line, $line, '$line is $line, duh ');
#~ http://perlmonks.com/?abspart=1;displaytype=displaycode;node_id=913
+631;part=1
{
use re 'debug';
$line=~ s/^(f:\\MF\\BR\\PreparedSources\\)([a-z]+\\)([a-z]+_de
+v)(\\)([a-z]+)(.java)$/JAVAFILE "$4$5$6" "$2" "##All"/;
}
is( $line, $olin, '$line is $olin');
$line=~ s~
^ # anchor start of line
( # $1 # f:\MF\BR\PreparedSources\
[^\\\/]+[\\\/] # f:\
[^\\\/]+[\\\/] # MF\
[^\\\/]+[\\\/] # BR\
[^\\\/]+[\\\/] # PreparedSources\
)
( # $2 # acdv
[^\\\/]+
)
[\\\/]
( # $3 # test_dev
[^\\\/]+?_dev
)
( # $4 # \BeanName\SessionBean.RMWAppException.java
[\\\/]
.+
(?i-xsm:\.java)
)
$ ## anchor end of line
~JAVAFILE "$3$4" "$2" "##All"~x;
# //x means whitespace is insignificant
is( $line, $olin, '$line is $olin for real');
}
__END__
Compiling REx "^(f:\\MF\\BR\\PreparedSources\\)([a-z]+\\)([a-z]+_dev)(
+\\)(["...
Final program:
1: BOL (2)
2: OPEN1 (4)
4: EXACT <f:\\MF\\BR\\PreparedSources\\> (12)
12: CLOSE1 (14)
14: OPEN2 (16)
16: PLUS (28)
17: ANYOF[a-z][] (0)
28: EXACT <\\> (30)
30: CLOSE2 (32)
32: OPEN3 (34)
34: PLUS (46)
35: ANYOF[a-z][] (0)
46: EXACT <_dev> (48)
48: CLOSE3 (50)
50: OPEN4 (52)
52: EXACT <\\> (54)
54: CLOSE4 (56)
56: OPEN5 (58)
58: PLUS (70)
59: ANYOF[a-z][] (0)
70: CLOSE5 (72)
72: OPEN6 (74)
74: REG_ANY (75)
75: EXACT <java> (77)
77: CLOSE6 (79)
79: EOL (80)
80: END (0)
anchored "f:\MF\BR\PreparedSources\" at 0 floating "_dev\" at 28..2147
+483647 (checking anchored) anchored(BOL) minlen 39
ok 1 - $line is $line, duh
Guessing start of match in sv for REx "^(f:\\MF\\BR\\PreparedSources\\
+)([a-z]+\\)([a-z]+_dev)(\\)(["... against "F:\MF\BR\PreparedSources\a
+cdv\test_dev\BeanName\SessionBean."...
String not equal...
Match rejected by optimizer
not ok 2 - $line is $olin
# Failed test '$line is $olin'
# at D:\dev\misc\pm.913631.pl line 25.
# got: 'F:\MF\BR\PreparedSources\acdv\test_dev\BeanName\Sessi
+onBean.RMWAppException.java'
# expected: 'JAVAFILE "test_dev\BeanName\SessionBean.RMWAppExcepti
+on.java" "acdv" "##All"'
ok 3 - $line is $olin for real
1..3
# Looks like you failed 1 test of 3.
|