logo
down
shadow

(How) can I re-create a package after having called Symbol::delete_package on it?


(How) can I re-create a package after having called Symbol::delete_package on it?

Content Index :

(How) can I re-create a package after having called Symbol::delete_package on it?
Tag : perl , By : Vijayant Singh
Date : January 12 2021, 08:33 AM

I think the issue was by ths following , The problem is that %P:: is resolved at compile-time, so it refers to the glob delete_package cleared and caused the symbol table to disown.
You'll get the expected output if you force the lookup to occur at runtime by replacing
keys %P::;
keys %{ no strict qw( refs ); \%{"P::"} };
keys %{ $::{"P::"} };
use strict;
use warnings;
use Symbol qw( delete_package );

use FindBin qw( $RealBin );
use lib $RealBin;

sub mod_path {
   my ($mod_name) = @_;
   return ( $mod_name =~ s{::}{/}gr ) . ".pm";
}

sub load_module {
   my ($mod_name) = @_;
   my $mod_path = mod_path($mod_name);
   require $mod_path;
}

sub unload_module {
   my ($mod_name) = @_;
   my $mod_path = mod_path($mod_name);
   delete_package($mod_name);
   delete($INC{$mod_path});
}

sub get_package {
   my ($pkg_name) = @_;
   $pkg_name .= '::' if $pkg_name !~ /::\z/;
   my $pkg = \%::;
   $pkg = $pkg->{$_} for split /(?<=::)/, $pkg_name;
   return $pkg;
}

sub dump_info {
   my ($mod_name) = @_;
   my $mod_path = mod_path($mod_name);
   my $pkg = get_package($mod_name);

   my $is_in_inc = grep { $_ eq $mod_path } keys %INC;
   printf("Included: %s\n", $is_in_inc ? "yes" : "no");

   my $num_syms = keys(%$pkg);
   print("Number of symbols: $num_syms\n");

   print("\n");
}

for $mod_name ('P', 'P') {
   load_module($mod_name);    dump_info($mod_name);
   # $mod_name->run();
   unload_module($mod_name);  dump_info($mod_name);
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Why does Perl say Global symbol "SYMBOL" requires explicit package name at PROGRAM.pl line X?


Tag : perl , By : Julian Ivanov
Date : March 29 2020, 07:55 AM
may help you . use strict; forces you to declare your variables before using them. If you don't (as in your code sample), you'll get that error.
To declare your variable, change this line:
$animal = "camell";
my $animal = "camell";

Create a facebook notification with Django package facepy : [15] (#15) This method must be called with an app access_tok


Tag : python , By : robinator
Date : March 29 2020, 07:55 AM
To fix the issue you can do I'm trying to create a facebook notifications with facepy & fandjango but I'm constantly get the same Error, , Finally I found where was the issues. when I was trying with
@facebook_authorization_required
@csrf_exempt     
def notify_self(request):

   token = request.facebook.user.oauth_token.token #user token
   token_app=facepy.utils.get_application_access_token('APP_ID','APP_SECRET_ID') 
   graph = GraphAPI(token)
   graph.post(
      path = 'me/notifications',
      template = '#Text of the notification',
      href = 'URL',
      access_token= token_app
   ) 

   return HttpResponse('<script type=\'text/javascript\'>top.location.href = \'URL\'</script>')

cannot find symbol symbol: class NestableRuntimeException location: package org.hibernate.exception


Tag : java , By : General Mills
Date : March 29 2020, 07:55 AM
I hope this helps . The NestableRuntimeException was available in Hibernate 3.2 but it got removed since Hibernate 3.3.
You need to refactor your code to use HibernateException instead.

create oracle package encountered PLS-00103: Encountered the symbol "CREATE"


Tag : oracle , By : mgz
Date : March 29 2020, 07:55 AM

Is It Better Practice To Use package-name:symbol In Code Or :use :package-name In A DEFPACKAGE?


Tag : lisp , By : user161380
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to get unicode code points in perl v5.24?
  • using an array as a reference is deprecated in perl
  • Using Perl's File::Basename to rename a file extension
  • Unable to get page via HTTPS with LWP::Simple in Perl
  • Perl DBI case insensitive methods
  • How to resolve @INC related issue in Perl
  • How to do unary and/reduction of bus to a bit in Perl?
  • What does perl -pe "s|$PASSWORD|<PASSWORD>|g"?
  • I want to replace last / by ,
  • Strange regular expression
  • What does "!" mean before a variable in perl
  • Getting the inner hash in Perl
  • perl : can't require $value from other perl file and use it in 3rd perl file
  • perl assign reference to subroutine
  • Troubleshooting Perl CGI app - Can't locate object method "new" via package
  • How can I write a Template.pm filter to generate PNG output from LaTeX source code?
  • Error: Cannot parse function definition from ' hello()' in Mytest.xs, line 9
  • What's the proper way to fork() in FastCGI?
  • How can I use Math::Business::EMA with DBI to calculate exponential moving averages in Perl?
  • How can I print the calling program/module inside a method in Perl?
  • Which module should I use to parse mediawiki text into a Perl data structure?
  • How can I efficiently group a large list of URLs by their host name in Perl?
  • How can I restore STDOUT after redirecting it to a file in a Perl script?
  • How can I parse this configuration file format (allowing comments) in Perl?
  • How To Avoid a Perl script calling an Another Perl Script
  • Perl - Internal File (create and execute)
  • How can I call a PL/Perl function from another PL/Perl function?
  • How can I terminate a system command with alarm in Perl?
  • When should I use a factory to wrap a constructor in Perl?
  • How can I extract sentences with a particular phrase, in Perl?
  • Dequeue an array in perl with thread::queue
  • How do I tell perl to execute a piece of generated Perl code?
  • Why does a positive lookahead lead to captures in my Perl regex?
  • In a digital photo, how can I detect if a mountain is obscured by clouds?
  • How can I pass a hash to a Perl subroutine?
  • Why do I get 'use: command not found' when I run my Perl script?
  • How can I take a reference to specific hash value in Perl?
  • How do I find the sum of all values from two different arrays in Perl?
  • How can I determine which package my constructor was called from?
  • How do I install Perl's Lingua::Lid?
  • How can I copy a directory but ignore some files in Perl?
  • How can I build something like Amazon S3 in Perl?
  • What does Perl's -p command-line switch do?
  • How can I get the high-res mtime for a symbolic link in Perl?
  • How can I get the ultimate URL without fetching the pages using Perl and LWP?
  • How can I create a new file using a variable value as the name in Perl?
  • Why does my Perl CGI program fail with "Software error: ..."?
  • How can I handle -r=<pattern> with Perl's Getopt::Long?
  • Is there a way that I can force mod_perl to re-use buffer memory?
  • How do I issue an HTTP redirect with Perl's CGI.pm?
  • Can I pass a regex to isa() with Moose-based objects?
  • How can I tell Perl's IO::Socket::INET which interface to use?
  • How do I print a hash structure in Perl?
  • What reasons could there be for converting Perl to Java?
  • Command executed in SSH terminal displays extra line contents
  • Documentation on Serving static files
  • Is Perl cpan's 2.4 Spreadsheet::WriteExcel entirely compatible running code written for its preceding 2.2 version?
  • Command line arguments only work for first element of array
  • Enable a user option to override a value for a variable
  • Assign number to variable in perl subroutine [assign returned list to variables]
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com