Adding indexes with PERL

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Adding indexes with PERL
# 1  
Adding indexes with PERL

Hello. I'm trying to self learn Perl and am stuck. I have a data.csv file that contains the following:


I'm trying to get Perl to take the indexes and add them all together to get 134. It says I need to use split and invoke the file via
<> (built-in provides data from files and standard-in) the command line. So I'm doing ./ data.csv to run it but I'm just
getting 4 lines containing a single 0. Any pointers?

Here is the code I have so far:

while (<>){

print ("\n");

# 2  
Moderator's Comments:
Mod Comment

Please do not add color to your code. It makes reading almost impossible.

Please edit your post and remove all the color you added.


# 3  
Your task is pretty basic. You will find a lot of examples if you...

... search google for "perl read from stdin" ...
... read the documentation for the functions, e. g. perldoc -f split

I do not see where you are assigning a value to your variable $input, which you'd like to split.

Last edited by stomp; 4 Weeks Ago at 05:37 AM..
This User Gave Thanks to stomp For This Post:
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #677
Difficulty: Medium
The IEEE does not test equipment for compliance with their standards.
True or False?

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I need to find out disk usage for particular indexes for different hosts

Need disk utilisation script for particular indexes on few hosts (3 Replies)
Discussion started by: Krish5v
3 Replies

2. Shell Programming and Scripting

Adding timestap to filename using perl

Hello, I am trying to create a file in windows and i want the filename to have timestamp as well but something is wrong and i can not understand waht. The code that i use is the following ($cwkday,$cmonth,$cday,$ctime,$cyear) = split(/\s+/, localtime); $current_date =... (5 Replies)
Discussion started by: chriss_58
5 Replies

3. Shell Programming and Scripting

open files with multiple indexes

Hi, I want to work with multiple files which all contain 2 numbers. I tried to make a nested for loop but for some reason it doesn't recognize the $j as a number. The output is cannot open file `175-T-pvalue.xls'. How do I make sure that it takes the numbers from the inner loop as $j? ... (4 Replies)
Discussion started by: linseyr
4 Replies

4. UNIX for Dummies Questions & Answers

Perl - adding columns to file

I have a file in which I need to add more columns to based on a key in the first file: File1 key1,abc,123, key2,def,456, key3,ghi,789, File2 key2,zyx,111,qqq, key3,yuu,222,www, key1,pui,333,eee, key4,xxx,999,rrr, I would like to create the following output: Output (1 Reply)
Discussion started by: WongSifu
1 Replies

5. Programming

Adding information to c file using perl

Hi, I have c file which contains more number of tests. two or more tests in one c file. I have the XMl data regarding tests. i need to add this xml data to c file at before the test. I know which file having which test and i created hash table for that. so the problem is i have to add information... (13 Replies)
Discussion started by: veerubiji
13 Replies

6. Shell Programming and Scripting

matrix indexes

I wanted to use matrixs in awk and got some problem, here is some of the script code, from the BEGIN tag: row_char="a";row_char="b";row_char="c";row_char="d";row_char="e"$ row_char="h";row_char="i";row_char="j";row_char="k"; from the proccess passage: sentence,1]=1; diffrence=4; i=7;... (2 Replies)
Discussion started by: tal
2 Replies

7. Shell Programming and Scripting

Analyze the indexes and rebuild them

Hello UNIX and Oracle Gurus, After doing an intensive search from different websites, the UNIX forum I am posting this message seeking help.. I am trying to accomplish the following tasks through the shell script: 1. Rebuild indexes on a Table in Oracle 2. Analyze indexes and table... (0 Replies)
Discussion started by: madhunk
0 Replies

8. UNIX for Dummies Questions & Answers

using sed with indexes

Hi people, Is this possible and if so any tips are very welcome. Im trying to do the following: this is what I have: 800__1__ this is what I want: 8000010 12345678 Im... (1 Reply)
Discussion started by: seaten
1 Replies

Featured Tech Videos