perl -e and bash

R

Rob Beattie

hi,
i'm just starting out with perl and have come across the well known
dos problem when running the following
perl -e 'print "hi \n";'

I've tried to read up on a solution for this and have seen suggestions
regarding using a bash shell. Where can I download this(cygwin.com?)
and how much space will it take up on my hard drive. I've checked at
cygwin and read that it will require 800MB of storage. This seems to
be a bit excessive to me.
So are there any windows users out there who has gone through this
route?
 
S

Sisyphus

Rob said:
hi,
i'm just starting out with perl and have come across the well known
dos problem when running the following
perl -e 'print "hi \n";'

There's also the well known solution to this problem:
perl -e "print \"hi \n\";"

(Just in case you were unaware of it :)

Cheers,
Rob
 
J

Joe Smith

Rob said:
hi,
i'm just starting out with perl and have come across the well known
dos problem when running the following
perl -e 'print "hi \n";'

I've tried to read up on a solution for this and have seen suggestions
regarding using a bash shell. Where can I download this(cygwin.com?)

Yes, http://www.cygwin.com/ is where you'll find the installer.
and how much space will it take up on my hard drive. I've checked at
cygwin and read that it will require 800MB of storage.

Cygwin's setup.exe does not install _everything_ by default.
I've got more than just the default and 'du -k' on my C:\cygwin shows this:

57920 bin
1821 etc
19315 home
75738 lib
22 tmp
4961 usr/doc
7467 usr/include
16517 usr/info
397 usr/local
2762 usr/man
987 usr/sbin
72015 usr/share
3392 usr/src
442 usr/ssl
256 var
264 megabytes total

It's a full-fledged Unix-like universe inside your Win32 box.
-Joe
 
J

John Bokma

Sisyphus said:
There's also the well known solution to this problem:
perl -e "print \"hi \n\";"

(Just in case you were unaware of it :)

or

perl -e "print qw(hi \n);"
 
R

Rob Beattie

I did not know about this one
^^
^^ you meant qq() instead of qw()

but I have heard of perl -e "print qq(hi \n);"
it is just that I can't understand the explanantion behind it.
If I applied the following rules:-

replace ' with "
use whatever the original two " enclosed as an argument for qq()

would that be the case here?
 
T

Tad McClellan

Rob Beattie said:
but I have heard of perl -e "print qq(hi \n);"
it is just that I can't understand the explanantion behind it.


What explanation was that?

Was it the one in the "Quote and Quote-like Operators" in perlop.pod?

If I applied the following rules:-

replace ' with "


That's DOS stuff. No Perl there.

use whatever the original two " enclosed as an argument for qq()

would that be the case here?


If you don't want to have to backslash double quotes, then write
your Perl code without any double quotes in it.


Instead of starting a string with

"

start it with

qq( # or: qq/ qq{ qq. qq| ...

instead of ending the string with

"

end it with

) # or: / { . | ...
 
S

Sisyphus

Rob said:
If I applied the following rules:-

replace ' with "
use whatever the original two " enclosed as an argument for qq()

would that be the case here?

That's right.

Cheers,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top