![]() |
|
We don't bite newbies here... much | |
PerlMonks |
Re: problem in mkdirby quester (Vicar) |
on Dec 02, 2011 at 09:36 UTC ( [id://941277]=note: print w/replies, xml ) | Need Help?? |
I can see a few things that seem odd:
If you check your web server logs, or if you check your script with "perl -c scriptname.pl" you will see a warning "my" variable @a masks earlier declaration in same scopeThe second push declares a second array @folder_name which hides the first array of that name; that makes $temp2 undefined later. Once that is fixed, if you read the definitions of the push and pop functions carefully, you will notice that $temp1 gets the contents of the last line in file TWO if file TWO is not empty, otherwise it gets the last line in file ONE. $temp2 gets the contents of the next to last line in file TWO if there if there are two lines in file TWO, the last line in file ONE if there is one line in file TWO, and the next to last line in file ONE if file TWO is empty. In the simple case where both files are one line long, $temp1 gets the file TWO contents and $temp2 get file ONE's. Somehow I doubt that is what you had intended. If you wanted a single line in $temp1 from file ONE, and wanted a single line in $temp2 from file TWO, you could remove the unnecessary array @folder_name and just: You should also check the value returned from mkdir, since it may indicate an error. The easiest way is with the "... or die" idiom:
In Section
Seekers of Perl Wisdom
|
|