Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I may be misreading the code, but it looks like you're trying to access the formats as if they were variables declared in your imported package, when they're actually being defined within a sub.

You have two choices, depending on how you want to define your formats:

  1. Define the format(s) outside of the sub
  2. Have the sub return the two formats

I'd probably go with '1' since there's nothing really happening that seems to require a sub.

package Formatting::Admin::Usage; format top = ... format data = ... package main; $^ = Formatting::Admin::Usage::top; $~ = Formatting::Admin::Usage::data;

I haven't tried compiling this and it's been a long time since I've worked with formats, so you might need to do some tweaks (I notice that in your code the last two lines use double-quotes to make the assignment, for instance), but this gives you a fairly flexible structure... have more Admin reports? Define a new package Formatting::Admin::Other::top. Want to have user reports? Formatting::User::Usage::top. And so on.

HTH


In reply to Re: Formats and Variable Scope by jreades
in thread Formats and Variable Scope by Tanalis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-25 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found