Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

running Perl's script on mac, and error messages returned

by Anonymous Monk
on Sep 30, 2011 at 03:26 UTC ( #928698=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:


I have a friend, he's using mac, and i asked him to run my Perl script on his Mac,

I am not sure how to doing things in Mac, but as far as i know not much different with linux Fedora (mine)

First try:

perl ./ --ed 10-31-2011 -d Can't open perl script "./ --ed": No such file or directory

I asked him to remove ./ from, so second tried:

root@dom:/home/fre/bin# perl /home/fre/bin/ --ed 10-31-2011 - +d Can't open perl script "/home/free/bin/ --ed": No such file o +r directory

Then, i asked him to run with:

root@dom:/home/fre/bin# ./ --ed 10-31-2011 -d -bash: ./ --ed: No such file or directory

Last i asked him to run with:

./ Usage: ./ --ed end_date --sales-table /path/to/sales/file Use -d or -debug for debugging

Its weird

Here's the code (simplified):
#!/usr/bin/perl use 5.10; use strict; use warnings; use Getopt::Long; my ($enddate, $csv_file) = (0, 0); my $DEBUG = 0; GetOptions( 'enddate|ed=s' => \$enddate, 'sales-table|s=s' => \$csv_file, 'debug|d' => \$DEBUG, ) or die_usage(); die_usage() unless ($enddate && $csv_file); sub die_usage{ say "Usage: $0 --ed end_date --sales-table /path/to/sales/file"; say "Use -d or -debug for debugging"; exit; }

Its weird enough for me, did i miss something ?

Script is working fine on my linux fedora

Replies are listed 'Best First'.
Re: running Perl's script on mac, and error messages returned
by graff (Chancellor) on Sep 30, 2011 at 05:15 UTC
    The error message makes it look as though the space between the script name and the "--ed" option is not being recognized in the mac's bash shell as a space.

    I wonder... did the command line get pasted into the shell terminal window from a web page (or HTML-formatted email display)? If so, there might have been a "wide-character" space (e.g. U+00A0, NON-BREAK SPACE). The mac's native "Terminal" application has no trouble rendering wide characters so that they look "normal", but the bash shell will see this apparent "space" as a two-byte sequence "0xC0 0xA0", which the shell will interpret as a continuation of the name of the perl script (and the "--ed" will also be included, since there's no real space character in front of it).

    (UPDATE: forgot to mention: if the command line was pasted in from an HTML display of some sort, the solution is to just type the command line manually -- being sure to use the space bar between command line args -- rather than pasting it in.)

Re: running Perl's script on mac, and error messages returned
by raybies (Chaplain) on Sep 30, 2011 at 12:42 UTC
    Two things come to mind...

    On the mac is Perl installed in /usr/bin?

    When I write a script in DOS and port it to linux, I often have to run "dos2unix" on it, because the end of line characters DOS uses fuddle up my linux box. So I don't know Mac, but could there be something similar?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://928698]
Approved by lidden
[1nickt]: (also skips . and .. automatically, and follows subdirs if you set <c\>recurse => 1</c>
[1nickt]: $it = path("/foo")-> iterator(recurse => 1 );

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (16)
As of 2017-03-28 18:52 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (340 votes). Check out past polls.