<?xml version="1.0" encoding="windows-1252"?>
<node id="261" title="perlfunc:oct" created="1999-08-24 18:42:39" updated="2005-08-14 12:42:00">
<type id="119">
perlfunc</type>
<author id="114">
gods</author>
<data>
<field name="doctext">
</field>
<field name="name">

&lt;P&gt;
oct - convert a string to an octal number

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="synopsis">

&lt;P&gt;
oct 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt;

&lt;P&gt;
oct

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="description">

&lt;P&gt;
Interprets 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt; as an octal string and returns the corresponding value. (If 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt; happens to start off with
 &lt;CODE&gt;0x&lt;/CODE&gt;, interprets it as a hex string instead.) The following will handle decimal, octal, and hex in the standard Perl or 
&lt;FONT SIZE=-1&gt;C&lt;/FONT&gt; notation:

&lt;P&gt;
&lt;PRE&gt;    $val = oct($val) if $val =~ /^0/;
&lt;/PRE&gt;
&lt;P&gt;
If 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt; is omitted, uses &lt;CODE&gt;$_&lt;/CODE&gt;. This function is commonly used when a string such as &lt;CODE&gt;644&lt;/CODE&gt; needs to be converted into a file mode, for example. (Although perl will
automatically convert strings into numbers as needed, this automatic
conversion assumes base 10.)

&lt;HR&gt;
</field>
</data>
</node>
