in reply to Re^3: perl can't find my script on ubuntu
in thread perl can't find my script on ubuntu

Roboticus, thank you for your help my friend. You were right, your suggestion helped. You see, when I typed in perl begperl/new and hit tab, the terminal filled in the rest as perl begperl/newline.pl\ and after I hit enter, it printed the message as it was meant to. However, I'm wondering why I had to put a \ at the end, when I didn't have to for helloworld.pl? Oh and thank you also for teaching me how to change directories. I appreciate it :)

Replies are listed 'Best First'.
Re^5: perl can't find my script on ubuntu
by roboticus (Chancellor) on Dec 15, 2010 at 19:17 UTC

    Samurai Monkey:

    OK, it sounds like you have a space at the end of the name of your script. If so, you can rename it like this:

    cd begperl mv newline.pl\ newline.pl

    Note: that's one space after the \, and then another to separate that file name from the new file name.

    Regarding your next question (what is the ls -lb command), you can use man ls to read the man page for the ls command. When you do so, it should show something like this:

    LS(1) User Commands + LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by defa +ult). Sort entries alphabetically if none of -cftuvSUX nor --sort. Mandatory arguments to long options are mandatory for short opt +ions too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE use SIZE-byte blocks. See SIZE format below

    As you can see above, the -b switch tells ls to put C style escapes in the file names where required. Perl and C escapes are basically the same, and since you didn't report any characters after the \, I guessed that it was a space. Here's a simple program to generate a file with a name with escapes in it:

    #!/usr/bin/perl -w open my $FH, '>', "test\ \r\x1b" or die; print $FH "foo\n"; close $FH;

    After I run it, I next run ls -alb to get:

    $ ls -alb total 2 drwxr-xr-x+ 1 301058 Domain Users 0 2010-12-15 14:14 . drwxr-xr-x+ 1 301058 Domain Users 0 2010-12-15 14:13 .. -rw-r--r-- 1 301058 Domain Users 91 2010-12-15 14:12 foo.pl -rw-r--r-- 1 301058 Domain Users 4 2010-12-15 14:14 test\ \r\033

    Then, to delete it, I just type "rm test" and hit the tab key to get the rest of the filename autocompleted for me, and then I press Enter to get rid of the file:

    $ rm test\ ^M^[

    Note how bash displays a carriage-return as ^M and escape as ^[ while ls -b shows them as \r and \033 respectively.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.