return $ENV{'PWD'};
}
-my($oldw) = $^W;
-$^W = 0; # assignments trigger 'subroutine redefined' warning
-if ($^O eq 'VMS') {
-
- *cwd = \&_vms_cwd;
- *getcwd = \&_vms_cwd;
- *fastcwd = \&_vms_cwd;
- *fastgetcwd = \&_vms_cwd;
-}
-elsif ($^O eq 'NT' or $^O eq 'MSWin32') {
+{
+ local $^W = 0; # assignments trigger 'subroutine redefined' warning
- # We assume that &_NT_cwd is defined as an XSUB or in the core.
- *getcwd = \&_NT_cwd;
- *fastcwd = \&_NT_cwd;
- *fastgetcwd = \&_NT_cwd;
-}
-elsif ($^O eq 'os2') {
- # sys_cwd may keep the builtin command
- *cwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd;
- *getcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd;
- *fastgetcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd;
- *fastcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd;
-}
-elsif ($^O eq 'msdos') {
- *cwd = \&_msdos_cwd;
- *getcwd = \&_msdos_cwd;
- *fastgetcwd = \&_msdos_cwd;
- *fastcwd = \&_msdos_cwd;
+ if ($^O eq 'VMS') {
+ *cwd = \&_vms_cwd;
+ *getcwd = \&_vms_cwd;
+ *fastcwd = \&_vms_cwd;
+ *fastgetcwd = \&_vms_cwd;
+ }
+ elsif ($^O eq 'NT' or $^O eq 'MSWin32') {
+ # We assume that &_NT_cwd is defined as an XSUB or in the core.
+ *getcwd = \&_NT_cwd;
+ *fastcwd = \&_NT_cwd;
+ *fastgetcwd = \&_NT_cwd;
+ }
+ elsif ($^O eq 'os2') {
+ # sys_cwd may keep the builtin command
+ *cwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd;
+ *getcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd;
+ *fastgetcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd;
+ *fastcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd;
+ }
+ elsif ($^O eq 'msdos') {
+ *cwd = \&_msdos_cwd;
+ *getcwd = \&_msdos_cwd;
+ *fastgetcwd = \&_msdos_cwd;
+ *fastcwd = \&_msdos_cwd;
+ }
}
-$^W = $oldw;
# package main; eval join('',<DATA>) || die $@; # quick test
-#!./perl
+#!./perl -w
#
# Contributed by Graham Barr <Graham.Barr@tiuk.ti.com>
BEGIN {
- $^W = 1;
$warn = "";
$SIG{__WARN__} = sub { $warn .= join("",@_) }
}
ok(4, $dbh->{lorder} == 0) ;
ok(5, $dbh->{minkeypage} == 0) ;
ok(6, $dbh->{maxkeypage} == 0) ;
-$^W = 0 ;
-ok(7, $dbh->{compare} == undef) ;
-ok(8, $dbh->{prefix} == undef) ;
-$^W = 1 ;
+{
+ local $^W = 0 ;
+ ok(7, $dbh->{compare} == undef) ;
+ ok(8, $dbh->{prefix} == undef) ;
+}
$dbh->{flags} = 3000 ;
ok(9, $dbh->{flags} == 3000) ;
ok(42, $status == 0 );
# Make sure that the key deleted, cannot be retrieved
-$^W = 0 ;
-ok(43, $h{'q'} eq undef) ;
-ok(44, $h{''} eq undef) ;
-$^W = 1 ;
+ok(43, ! defined $h{'q'}) ;
+ok(44, ! defined $h{''}) ;
undef $X ;
untie %h ;
$Dfile3 = "btree3" ;
$dbh1 = new DB_File::BTREEINFO ;
-$dbh1->{compare} = sub { $_[0] <=> $_[1] } ;
+{ local $^W = 0 ;
+ $dbh1->{compare} = sub { $_[0] <=> $_[1] } ; }
$dbh2 = new DB_File::BTREEINFO ;
$dbh2->{compare} = sub { $_[0] cmp $_[1] } ;
tie(%k, 'DB_File',$Dfile3, O_RDWR|O_CREAT, 0640, $dbh3 ) ;
@Keys = qw( 0123 12 -1234 9 987654321 def ) ;
-$^W = 0 ;
-@srt_1 = sort { $a <=> $b } @Keys ;
-$^W = 1 ;
+{ local $^W = 0 ;
+ @srt_1 = sort { $a <=> $b } @Keys ; }
@srt_2 = sort { $a cmp $b } @Keys ;
@srt_3 = sort { length $a <=> length $b } @Keys ;
foreach (@Keys) {
- $^W = 0 ;
- $h{$_} = 1 ;
- $^W = 1 ;
+ { local $^W = 0 ;
+ $h{$_} = 1 ; }
$g{$_} = 1 ;
$k{$_} = 1 ;
}