in reply to Re^2: writing a pragma
in thread writing a pragma

thanks for the answer. helped a lot. is there a way to write a module to work like strict. so that does something at compile time?

Replies are listed 'Best First'.
Re^4: writing a pragma
by karthikasasanka (Acolyte) on Apr 26, 2014 at 03:33 UTC
    is there a way to write a module to work like strict. so that does something at compile time?
      In Perl it is easy to do things at compile time. You have BEGIN for that.

      A different mater is changing how the program is compiled. perl provides some hooks for doing it, but AFAIK, it must be done at the C level and requires a pretty good knowledge of the internals. See perlguts.

      That really depends on exactly what you want to do at compile time, doesn't it? Some things are easier than others.

      use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

        I want to write a pragma, which reads the contents of file where it is imported.

        1. use mypragma;

        2. use Data::Dumper;

        3. my $hash = {1,2,3,4,5,6}

        4. print Dumper $hash;

        I want to get the lines from 2,3,4 into the mypragma which was loaded into memory for this program.

        I am not sure that this is possible, I just want to try.