sub hello { chdir '..'; my $file = __FILE__; warn "My file name is $file. Here is my contents:"; open(my $fh, "<", $file); my @data = <$fh>; warn "@data"; } hello(); 1; #### # works in plain perl, fails with this compilation line: # pp -P -r -v 99 -o packed.pl somefile.pl BEGIN { use File::Spec; for (@INC) { if ( !ref $_ && -d $_ && !File::Spec->file_name_is_absolute($_) ) { $_ = File::Spec->rel2abs($_); } } } sub hello { my $file = __FILE__; warn "My file name is $file. Here is my contents:"; open(my $fh, "<", $file); my @data = <$fh>; warn "@data"; } hello(); 1;