Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Re: Perl on a Mac - again

Reply
Thread Tools

Re: Perl on a Mac - again

 
 
Peter Makholm
Guest
Posts: n/a
 
      04-22-2012
Hacker <(E-Mail Removed)> writes:

> When I write 'perl test' on the command line it works fine and comes out with
> 'Hello World' just as it should, but when I write 'test' on the command line
> there is no output.


You current working directory is not in $PATH and you end up with
calling /bin/test.

//Makholm
 
Reply With Quote
 
 
 
 
Tim McDaniel
Guest
Posts: n/a
 
      04-22-2012
In article <(E-Mail Removed)>,
Peter Makholm <(E-Mail Removed)> wrote:
>Hacker <(E-Mail Removed)> writes:
>
>> When I write 'perl test' on the command line it works fine and
>> comes out with 'Hello World' just as it should, but when I write
>> 'test' on the command line there is no output.

>
>You current working directory is not in $PATH and you end up with
>calling /bin/test.


"test" is a builtin command in bash and probably in other shells.
It doesn't matter what PATH is set to: it always checks for builtins
before checking anything in PATH.

In bash, you can run
type test
and it will tell you what it will run for that command.
In this case, the output is
test is a shell builtin

You could run your program as "./test", if it has the execute bit set,
but if you ever forgot, it would silently run the shell builtin
again. Bastically, naming a test program "test' is a classic UNIX
error.

If you want to run it as a command, then
- rename the file. Do not rename it to one of the reserved builtin
commands or such. No builtin has "." in the middle fo text, so
that's always safe, like "test.pl".

Suppose below you rename it test1

- make sure it has the execute bit set, via
chmod u+x test1
- run it via
./test1
You may already have "." as an item in $PATH, in which case you can
run it as "test1", but if you are explicit about the path to the
file, like "./test1", then there's no question about confusing it
with a builtin.


Builtin commands and such:
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      04-22-2012
Hacker <(E-Mail Removed)> wrote:
>> You current working directory is not in $PATH and you end up with
>> calling /bin/test.

>
>Would a ~/.bashrc something with path help.


Don't! There is a very good reason why the CWD is not included in your
search path. And least of all at the beginning.

This has been a very frequent Unix beginners complain for the past 2
decades and I suggest you consult the archives or Unix FAQs for an
explanation why it is the way it is. Once you understand the reason
behind it then you can make your own decision if you want to change the
behaviour for yourself.

And no, it doesn't have anything to do with Perl.

>I can not remember how you append $PATH, yuk.


You should first understand why the CWD is not included in the path.
Only then can you make a concious and educated decision if for you it
makes sense to add the CWD or not.

jue
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Perl on a Mac - again Martijn Lievaart Perl Misc 6 04-25-2012 06:28 AM
Re: Perl on a Mac - again Jürgen Exner Perl Misc 0 04-22-2012 11:34 AM
Re: Perl on a Mac - again Dr.Ruud Perl Misc 1 04-22-2012 08:52 AM
Activestate Perl and original Perl both on Mac OS Tiger Jake Wiley Perl Misc 14 06-16-2005 10:47 PM
jserve booting again and again amit Java 0 10-02-2003 04:26 PM



Advertisments