[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Regex which works, but doesn't



 I have the following code and it has been cut down from all the code that is 
being used, but it fails and I don't understand why. I have three data types 
I am searching for and the type C fails and I don't understand.  I am missing 
something, but just don't see it. Aslo provided print output.  I have tried 
this both on Win32 and MacPerl and they both fail on Type C, but don't follow.


[[  ------------------ Code Starts -------------------------------  ]]
#   A)
$_ = '  VALUE "F7......Shop Fiscal Maintenance" .';

printf "Search for type A\n";
::search();

#    B)
$_ = '  05 FILLER AT  5, 4   VALUE "F1.............Employee Master" .';
printf "Search for type B\n";
::search();

#    C)
$_ = '        VALUE';
printf "Search for type C\n";
::search();


sub search {
#
#   A
#
        if ( /^\s+VALUE\s+\"\s*(S*)F(\d+)\.*(.+)\"/ig ) {
            printf "Value 1 find\n";
#
#   B
#
         }elsif 
(/^\s+\d+\s+FILLER\s+AT\s+\d+\,\s+\d+\s+VALUE\s+\"\s*(S*)F(\d+)\.*(.+)\"/ig ) 
{
             printf "Value 2 find\n";
#
#   C
#
         }elsif ( /^\s+VALUE\s*$/ig ) {
             $_ = '     " F3 - CSP415P2 - Salesrep Statistics by Terminal 
-(A) All Accounts".';
             if ( /^\s+\"\s*(S*)F(\d+)\.*(.+)\"/i ) {
                printf "Value 3 find\n";
              }else {
                return;
              }
         }
        if ( defined $1 ) {
            printf " 1: $1\n";
         }
        if ( defined $2 ) {
            printf " 2: $2\n";
         }
        if ( defined $3 ) {
            printf " 3: $3\n";
         }
 }

[[  ------------------ Code Ends -------------------------------  ]]
[[  ------------------ Output Starts -------------------------------  ]]

Search for type A
Value 1 find
 1: 
 2: 7
 3: Shop Fiscal Maintenance
Search for type B
Value 2 find
 1: 
 2: 1
 3: Employee Master
Search for type C
Value 3 find

[[  ------------------ Output Ends -------------------------------  ]]

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org