perl Unix programming Question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl Unix programming Question
# 1  
Old 03-02-2012
perl Unix programming Question

Hello can somebody tell me whats wrong with this good

PHP Code:
 #/bin/perl -f
 
substr$_, -2) = "" unless length$_ ) % 
i get an error :
Code:
 ./ev: syntax error at line 2: `(' unexpected

please help

thank you

Last edited by radoulov; 03-03-2012 at 03:19 AM..
# 2  
Old 03-03-2012
Please post the entire code and explain what exactly you're trying to achieve.
# 3  
Old 03-03-2012
Quote:
Originally Posted by koricha
...can somebody tell me whats wrong with this good
PHP Code:
 #/bin/perl -f
 
substr$_, -2) = "" unless length$_ ) % 
i get an error :
Code:
 ./ev: syntax error at line 2: `(' unexpected

...
The shebang is incorrect, because the "!" character is missing after the "#".

The way it is right now, it's acting as a shell script comment. I say "shell script" because you are executing it as a shell script due to the way you've invoked it. And so the shell balks at the "(" character.

tyler_durden
# 4  
Old 03-03-2012
Quote:
Originally Posted by radoulov
Please post the entire code and explain what exactly you're trying to achieve.
Ok that is the cod i am trying to save in vi
steps

open vi example1

Code:
#!/bin/perl -f
   substl( $_, -2, 1 ) = "" unless length( $_ ) % 2

save and quite

Code:
chmod +x example1

Code:
./example1

and it gives me an error

Last edited by radoulov; 03-04-2012 at 04:43 AM.. Reason: Code tags, please!
# 5  
Old 03-03-2012
Hi koricha,

You are not helping us so much. Your code has no sense for me.

1. -f switch gives me next error: Can't emulate -f on #! line at ./example1 line 1
2. substl is not a valid function in perl.
3. $_ has no value.
4. Describe your error. We cannot see your screen.
5. You run your program without arguments. So, try to answer to radoulov and say what you want to achieve.

Regards,
Birei
# 6  
Old 03-03-2012
Never mind it works


PHP Code:
#!/bin/ksh
perl -pe 'substr( $_, -2, 1 ) = "" unless length( $_ ) % 2' 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl programming

how to link the linux files in perl on the local webpage ???? suppose we have some results and want to get them published on the local webpage of our internal site. how this can be done using HTML and perl together , so that the results are published directly on the webpage. thanks kullu (0 Replies)
Discussion started by: kullu
0 Replies

2. Programming

Programming help - Perl !

I am having a text file with Vivek 50 Ram 34 Hulk 45 Vivek 23 Ram 23 Vivek 55 Now I need a perl script to display the fields of 1st column & the 2nd column with summation (& avoid the duplicates). Vivek 128 Ram 57 hulk 45 Plz help me... (1 Reply)
Discussion started by: gameboy87
1 Replies

3. UNIX for Dummies Questions & Answers

How does unix system administration, unix programming, unix network programming differ?

How does unix system administration, unix programming, unix network programming differ? Please help. (0 Replies)
Discussion started by: thulasidharan2k
0 Replies

4. UNIX for Dummies Questions & Answers

Wireless network programming in Unix (question)

Greetings everyone, I've been using OpenWRT for some time primarly for research in the University. I've also started with some basic network programming (sending UDP packets for instance). But since most of the available tutorials on unix network programming are more related to ethernet... (4 Replies)
Discussion started by: aztroboy
4 Replies

5. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

6. UNIX for Dummies Questions & Answers

Programming question

How do I create a program that will allow a user to type in a number, while the program outputs that number in words. For example, if a user types in 21, the computer would respond with twenty-one. Please allow the program to work for 0-30. How do I let the user know if a number typed in is not in... (2 Replies)
Discussion started by: lexydoll87
2 Replies

7. Programming

C programming question

How do I find multiples of a number in C programming? Thanks (4 Replies)
Discussion started by: Aseda
4 Replies

8. UNIX for Dummies Questions & Answers

Carreer:Networking Programming in Unix (C programming Language)

Hello, I am trying to learn Networking Programming in C in unix enviorment. I want to know how good it is to become a network programmer. i am crazy about Network programming but i also want to opt for the best carreer options. Anybody experienced Network Programmer, please tell me is my... (5 Replies)
Discussion started by: vibhory2j
5 Replies

9. Shell Programming and Scripting

Unix Systems Programming Vs Unix Programming

Several months ago I found a link that explained the difference between how a Unix Systems Admin would do scripting compared to what a Unix Programmer would do. It showed a basic script and then show several iterations that explained how the Systems Admin would change it to make it better. I was... (0 Replies)
Discussion started by: BCarlson
0 Replies
Login or Register to Ask a Question