ParamVal.pm.html   [plain text]


<HTML>
<HEAD>
  <TITLE>MIME::Field::ParamVal</TITLE>
</HEAD>
<BODY 
       bgcolor="#FFFFFF" link="#CC3366" vlink="#993366" alink="#FF6666">
<FONT FACE="sans-serif" SIZE=-1><A HREF="http://www.zeegee.com" TARGET="_top"><IMG SRC="icons/zeegee.gif" ALT="ZeeGee Software" ALIGN="RIGHT" BORDER="0"></A><A NAME="__TOP__"><H1>MIME::Field::ParamVal</H1>
</A>
<P><B>This module is <FONT COLOR="#990000">BETA</FONT> code, which means that the interfaces are fairly stable BUT it has not been out in the community long enough to guarantee much testing. Use with caution! Please report any errors back to <A HREF="mailto:eryq@zeegee.com">eryq@zeegee.com</A> as soon as you can.</B><UL>
<LI> <A HREF="#NAME">NAME</A>
<LI> <A HREF="#SYNOPSIS">SYNOPSIS</A>
<LI> <A HREF="#DESCRIPTION">DESCRIPTION</A>
<LI> <A HREF="#PUBLIC_INTERFACE">PUBLIC INTERFACE</A>
</UL>
</A>

<P><HR>
<A NAME="NAME"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> NAME</H2></A>


<P>MIME::Field::ParamVal - subclass of Mail::Field, for structured MIME fields



<P><HR>
<A NAME="SYNOPSIS"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> SYNOPSIS</H2></A>

<FONT SIZE=3 FACE="courier"><PRE>
    # Create an object for a content-type field:
    $field = new Mail::Field 'Content-type'; 
     
    # Set some attributes:
    $field-&gt;param('_'        =&gt; 'text/html');
    $field-&gt;param('charset'  =&gt; 'us-ascii');
    $field-&gt;param('boundary' =&gt; '---ABC---');
     
    # Same:
    $field-&gt;set('_'        =&gt; 'text/html',
		'charset'  =&gt; 'us-ascii',
		'boundary' =&gt; '---ABC---');
      
    # Get an attribute, or undefined if not present:
    print &quot;no id!&quot;  if defined($field-&gt;param('id'));
     
    # Same, but use empty string for missing values:
    print &quot;no id!&quot;  if ($field-&gt;paramstr('id') eq '');
                    
    # Output as string:
    print $field-&gt;stringify, &quot;\n&quot;;
</PRE></FONT>


<P><HR>
<A NAME="DESCRIPTION"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> DESCRIPTION</H2></A>


<P>This is an abstract superclass of most MIME fields.  It handles 
fields with a general syntax like this:

<FONT SIZE=3 FACE="courier"><PRE>
    Content-Type: Message/Partial;
        number=2; total=3;
        id=&quot;oc=jpbe0M2Yt4s@thumper.bellcore.com&quot;
</PRE></FONT>

<P>Comments are supported <I>between</I> items, like this:

<FONT SIZE=3 FACE="courier"><PRE>
    Content-Type: Message/Partial; (a comment)
        number=2  (another comment) ; (yet another comment) total=3;
        id=&quot;oc=jpbe0M2Yt4s@thumper.bellcore.com&quot;
</PRE></FONT>


<P><HR>
<A NAME="PUBLIC_INTERFACE"><H2><A HREF="#__TOP__"><IMG SRC="icons/h1bullet.gif" ALT="Top" BORDER="0"></A> PUBLIC INTERFACE</H2></A>



<DL>
<P><DT><B><A NAME="item:set">set [\%PARAMHASH | KEY=&gt;VAL,...,KEY=&gt;VAL]</A></B></DT>
<DD>
<I>Instance method.</I>  Set this field.
The paramhash should contain parameter names
in <I>all lowercase</I>, with the special <CODE>&quot;_&quot;</CODE> parameter name
signifying the &quot;default&quot; (unnamed) parameter for the field:

<FONT SIZE=3 FACE="courier"><PRE>
   # Set up to be...
   #
   #     Content-type: Message/Partial; number=2; total=3; id=&quot;ocj=pbe0M2&quot;
   #
   $conttype-&gt;set('_'       =&gt; 'Message/Partial',
		  'number'  =&gt; 2,
		  'total'   =&gt; 3,
		  'id'      =&gt; &quot;ocj=pbe0M2&quot;);
</PRE></FONT>

<P>Note that a single argument is taken to be a <I>reference</I> to 
a paramhash, while multiple args are taken to be the elements
of the paramhash themselves.


<P>Supplying undef for a hashref, or an empty set of values, effectively
clears the object.


<P>The self object is returned.

<P><DT><B><A NAME="item:parse_params">parse_params STRING</A></B></DT>
<DD>
<I>Class/instance utility method.</I>
Extract parameter info from a structured field, and return
it as a hash reference.  For example, here is a field with parameters:

<FONT SIZE=3 FACE="courier"><PRE>
    Content-Type: Message/Partial;
        number=2; total=3;
        id=&quot;oc=jpbe0M2Yt4s@thumper.bellcore.com&quot;
</PRE></FONT>

<P>Here is how you'd extract them:

<FONT SIZE=3 FACE="courier"><PRE>
    $params = $class-&gt;parse_params('content-type');
    if ($$params{'_'} eq 'message/partial') {
        $number = $$params{'number'};
        $total  = $$params{'total'};
        $id     = $$params{'id'};
    }
</PRE></FONT>

<P>Like field names, parameter names are coerced to lowercase.
The special '_' parameter means the default parameter for the
field.


<P><B>NOTE:</B> This has been provided as a public method to support backwards
compatibility, but you probably shouldn't use it.

<P><DT><B><A NAME="item:parse">parse STRING</A></B></DT>
<DD>
<I>Class/instance method.</I>
Parse the string into the instance.  Any previous information is wiped.
The self object is returned.


<P>May also be used as a constructor.

<P><DT><B><A NAME="item:param">param PARAMNAME,[VALUE]</A></B></DT>
<DD>
<I>Instance method.</I>
Return the given parameter, or undef if it isn't there.
With argument, set the parameter to that VALUE.
The PARAMNAME is case-insensitive.  A &quot;_&quot; refers to the &quot;default&quot; parameter.

<P><DT><B><A NAME="item:paramstr">paramstr PARAMNAME,[VALUE]</A></B></DT>
<DD>
<I>Instance method.</I>
Like param(): return the given parameter, or <I>empty</I> if it isn't there.
With argument, set the parameter to that VALUE.
The PARAMNAME is case-insensitive.  A &quot;_&quot; refers to the &quot;default&quot; parameter.

<P><DT><B><A NAME="item:stringify">stringify</A></B></DT>
<DD>
<I>Instance method.</I>
Convert the field to a string, and return it.

<P><DT><B><A NAME="item:tag">tag</A></B></DT>
<DD>
<I>Instance method, abstract.</I>
Return the tag for this field.

</DL>

<P><HR>
<ADDRESS><FONT SIZE=-1>
Generated Wed Jan 17 01:58:18 2001 by cvu_pod2html
</FONT></ADDRESS>
</FONT></BODY>
</HTML>