Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Header file management

by shmem (Chancellor)
on Apr 30, 2018 at 09:49 UTC ( [id://1213808]=note: print w/replies, xml ) Need Help??


in reply to Header file management

There are many ways to to that.

Study Modern::Perl by chromatic for a nice way to import modules as a bundle into your current namespace.

If you use 5.18, then the use feature qw(state say) is redundant afaik.

You could also write a file, say, header.pl containing use statements,and write your MyCommonUses.pm as

package MyCommonUses; use strict; use warnings; my $header = '/path/to/header.pl'; my $content = do {local $/; open my $fh,'<',$header or die; <$fh> } or die "couldn't load common use statements, aborted"; sub import { my $caller = caller; eval "package $caller; $content;"; strict->import; warnings->import; } 1;

so you have to edit only the common header file to add or remove packages.

A bonus would be some way to dispense with the inelegant one-semicolon.

Easy. Skip 1;, write

"sigh."

at the end.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: Header file management
by QM (Parson) on Apr 30, 2018 at 13:21 UTC
    The link to Modern::Perl doesn't resolve as you expect.

    The node resolves that to http://perldoc.perl.org/Modern/Perl.html, while swl's link resolves to https://metacpan.org/pod/Modern%3A%3APerl.

    I can't see the original node shortcuts, so I've investigated a bit here:

    mod://Modern::Perl: http://search.cpan.org/perldoc?Modern%3A%3APerl

    metamod://Modern::Perl: https://metacpan.org/pod/Modern%3A%3APerl

    You probably tried this:

    doc://Modern::Perl: http://perldoc.perl.org/Modern/Perl.html

    According to Link Shortcuts, that "links directly to a specific document by name: [doc://name]". In this case, '::' is translated to '/', or [doc://Some::Doc::Name] should point to http://perdoc.perl.org/Some/Doc/Name.html. Let's see: Some::Doc::Name: http://perdoc.perl.org/Some/Doc/Name.html. Yes!

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      The link to Modern::Perl doesn't resolve as you expect.

      Corrected, thank you. s/doc/mod/

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re^2: Header file management
by smaines (Novice) on Apr 30, 2018 at 16:00 UTC
    I've gone with Syntax::Collector, but studying Modern::Perl was very informative, thanks!
Re^2: Header file management
by smaines (Novice) on Apr 30, 2018 at 15:36 UTC

    LOL, "sigh",

    -SM

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1213808]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-23 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found