1752277 Members
4666 Online
108786 Solutions
New Discussion юеВ

Re: perl in unix editor

 
divihavan
New Member

perl in unix editor

How to run perl in unix through unix os. I am not able to write the line as #!/usr/local/bin/perl. [It does not allow me to enter '#' key]

WITHOUT THIS LINE OS DIDNOT RECOGONIZE the perl commands like "print". So please help me to run the perl program.
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: perl in unix editor

Shalom,

Can you say which editor you are using?

# key is certainly permitted entry in vi for example.

Knowing what kind of system you are using, PC or X terminal or whatnot would also be extremely helpful.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven Schweda
Honored Contributor

Re: perl in unix editor

> Can you say which editor you are using?

Can you say which _anything_ you are using?

> [...] unix os [...]

Not a very detailed description of anything.

uname -a

> [It does not allow me to enter '#' key]

What, exactly, is "It"? What, exactly, are
you doing? What, exactly, happens when you
do it?

Have you tried anything like, say:

perl your_file
?
Dennis Handly
Acclaimed Contributor

Re: perl in unix editor

>It does not allow me to enter '#' key

What is your stty setting for erase? "@" and "#" cause problems if you don't set these to non-default.
Bill Hassell
Honored Contributor

Re: perl in unix editor

> [It does not allow me to enter '#' key]

You probably have not run a standard profile during your login. Standard profiles reset the stty settings for backspace and cancel from # and @ to backspace and CTRL-U. If you are using Xwindows, the default action in HP-UX is to silently ignore profiles (a very bad setting) so enable all profiles by running this command when you are logged in:

echo "*loginShell: true" >> $HOME/.Xdefaults

Then logout and login again. Now, your # key should work normally.

If you're not using Xwindows or the above doesn't fix the problem, your .profile files do not have the correct stty commands. Here is what you need:

stty erase "^H" kill "^U" intr "^C" eof "^D" -parity ixoff
stty susp \^Z dsusp \^Y

These are found in the standard .profiles:

/usr/newconfig/etc/skel/.profile


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: perl in unix editor

Hi:

> How to run perl in unix through unix os. I am not able to write the line as #!/usr/local/bin/perl. [It does not allow me to enter '#' key]

You have a bigger problem than anything related to Perl.

Without the ability to specify a "she-bang" (otherwise known as an interpreter line) --- the '#!' your shell will think that it is the interpreter for anything you attempt to run. Of course, as Steven suggested, you can always specify the interpreter externally.

Regards!

...JRF...
Ralph Grothe
Honored Contributor

Re: perl in unix editor

Besides from your hashmark printing problem, you can of course also run your Perl script by giving its path as an argument to the perl interpreter.
First look if it compiles.

$ /usr/local/bin/perl -cw /path/to/your/perlscript.pl


Then if no errors appear you can excute it by ommitiing the "-c" (compile only) option.

Strange, no one mentioned this.

But if you want to do any serious Perl hacking you simply can't do without the hashmark char. Just think about Perl single line comments, the array last element index sigil e.g. $#ary, or simply regex delimiter e.g. m#...#, s#...#...# etc
Madness, thy name is system administration