On Fri, Oct 29, 2010 at 12:57 AM, John W. Krahn <jwkr...@shaw.ca> wrote:
> That is usually written as:
>
> use File::Copy qw/ cp mv /;
>
> use takes a list after the module name.

I thought it was up to the module to interpret the list and the
documentation that I was reading online wasn't very clear so I played
it safe just to get it to work. >_< Thank you for showing me the
preferred way. :) That was how I wanted to put it, but was in the
middle of other things at the time and didn't want to spend any more
time than was necessary to get my code working.

> No newline at the end of the string?

There should have been. ;) Obviously, I didn't test very thoroughly.
:) Thanks for point it out.

> If this is run on DOS/Windows then Perl will automatically translate "^J^M"
> to newline.

On Windows, shouldn't "\cM\cJ" be equal to "\n"? :-/ I'm making some
assumptions here. Of course, I'm also ignoring encoding issues as I
haven't really tackled those just yet. I just tried testing it out a
little bit and in Linux it worked so that was good enough for a taste.
I can't say for sure which Perl is installed on my Windows 7 machine
(I can't remember), but I tried testing it out there as well and the
results surprised me...

use strict;
use warnings;

print "crlf" if "\cM\cJ" eq "\n";
print "lf" if "\cJ" eq "\n";
print "cr" if "\cM" eq "\n";

__END__

That prints "lf" for me in Windows. :\ I use Cygwin, but I'm running
this from the Windows Command Prompt and the --version and -V output
suggests it's not Cygwin. Then again, I don't see C:\MSYS or C:\MinGW
so I must have installed one of the native Windows ports and forgot
about it... It appears to be running from C:\Perl64. Either way, I was
surprised to see "lf" output.

> Did you know that Perl has built-in idioms to handle multiple file
> manipulation:

I am/was aware that there was a shorthand for processing files passed
on the command line, but I assumed I would be unable to determine the
file name of the given handle, and without knowing about how to safely
write in-place I figured that I would need to write to a temporary
file and move for reliable results. Evidently Perl can handle that bit
for you. Thanks for showing me. :) Something I'll have to read up on
when I have a moment. I've been learning Perl in pieces here on the
beginners list and from what I've read of the FAQ and perldocs. :)
Practice makes perfect and I only get so much of it. :P

Thanks again. I appreciate the critique.

-- 
Brandon McCaig <bamcc...@gmail.com>
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software <http://www.castopulence.org/> <bamcc...@castopulence.org>

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to