`use English;' bizzaro behavior 
Author Message
 `use English;' bizzaro behavior

Short form of the long story:  there is a difference in the behavior of
regexp processing in Perl 4 vs. Perl 5 and it appears to be related to
the use of `use English;'.

Given this Perl 5 code:

#!/usr/local/bin/perl5 -w

#use English;
$_= "left 4switch right";
/(\bswitch\b)/;
($list, $type, $_)=($`, $1, $');
print "\$list=$list, \$type=$type, \$_=$_!\n";

Running this program produces this (correct, I believe) result:

Use of uninitialized value at ./t2.pl line 7.
Use of uninitialized value at ./t2.pl line 7.
Use of uninitialized value at ./t2.pl line 7.
$list=, $type=, $_=!

The 3 variables $list, $type and $_ are all undefined, consistent with
the Perl 4 behavior, since the regexp fails.

Now simply enable the `use English;' statement by uncommenting it and
you get this result:

Identifier "main::ARG" used only once: possible typo.
Use of uninitialized value at ./t2.pl line 7.
Use of uninitialized value at ./t2.pl line 7.
$list=, $type=$, $_=!

Notice that $type is now defined and has a value of "$"!  Also notice
the new warning message concerning $main::ARG ...

I hacked on this quit a bit and can't figure it out... BUG?

Take care,
Steve
--

Lehigh University Computing Center, USA



Mon, 28 Apr 1997 08:28:59 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Strange behavior using Perl's system() function to query SQL Server with osql

2. substituting english alphabets with english and accented characters

3. substituting english alphabets with english and accented characters

4. Perl module -- English - Japanese, Japanese - English

5. Perl module -- English - Japanese, Japanese - English

6. check if it's an English word

7. Odd 'print @array' behavior with 4.035

8. Nasty 'do' behavior

9. Strange behavior with 'use'

10. Different browser behavior on '302 Redirect'

11. Strnage behavior when using Expect in perl script

12. Inconsistent behavior when using diagnostics

 

 
Powered by phpBB® Forum Software