<?xml version="1.0" encoding="windows-1252"?>
<node id="780400" title="Re: STDIN help for a new Perl coder" created="2009-07-15 12:59:18" updated="2009-07-15 12:59:18">
<type id="11">
note</type>
<author id="590906">
linuxer</author>
<data>
<field name="doctext">
&lt;p&gt;Welcome here and to Perl.
&lt;p&gt;If you read User input like that, you must know, that the linebreak will also be stored in your variable. So you must remove it; see [doc://chomp] for details.

&lt;p&gt;&lt;c&gt;chomp( my $dir = &lt;STDIN&gt; );&lt;/c&gt;

&lt;p&gt;Each statement should be completed with a ';', your &lt;c&gt;chdir&lt;/c&gt; misses one.
&lt;p&gt;You should check if &lt;c&gt;chdir&lt;/c&gt; was successful and do something if it wasn't (&lt;c&gt;$!&lt;/c&gt; contains the system's error message).

&lt;p&gt;&lt;c&gt;chdir( $dir ) or die "$dir: $!\n";&lt;/c&gt;

&lt;p&gt;If you already changed into &lt;c&gt;$dir&lt;/c&gt;, you must not specify it again in the glob pattern.

&lt;p&gt;As you are using [doc://strict], you need to declare each new variable. You did it right with &lt;c&gt;$dir&lt;/c&gt;, but not with &lt;c&gt;@files&lt;/c&gt;.
</field>
<field name="root_node">
780393</field>
<field name="parent_node">
780393</field>
</data>
</node>
