$c is standard shorthand for the application context in Catalyst. As AnomalousMonk said, the actual variable name is arbitrary, just as $self is but it's also a convention. In the case of your sample code, $self is the Controller object.

During a regular request cycle, in which all controllers participate, $c will have $c->request loaded and you can start writing a $c->response if you like (they both have shorthand too, $c->req and $c->res). In cases where the request has not been processed, like the base class of any Catalyst application or in pre-request configuration code, this convention is often used to disambiguate from the request cycle context: $ctx.

And I think you can start to see why Laurent_R's and my cautions about Catalyst as a first trip to Perlland are good advice. The journey will probably be more torturous than edifying. You have to know HTTP and Perl pretty well, including object oriented Perl, before you can even absorb the answers you'll get to your questions. And you haven't hit Models in Catalyst yet. Almost all the examples in the docs and most real apps use DBIx::Class which also has a steep and dissimilar learning curve.

Don't get me wrong. Catalyst is fantastic; as is DBIC. It's just not starter fare.


In reply to Re: What is the $c variable? by Your Mother
in thread What is the $c variable? by alwynpan

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.