Sponsored Content
Top Forums Shell Programming and Scripting Subtracting columns against each other Post 302399753 by Fredrick on Monday 1st of March 2010 11:29:28 AM
Old 03-01-2010
Hi Pludi,

Thank you very much for your reply. I have tried the following code:

HTML Code:
#!/usr/bin/perl -W

use strict;
use warnings;

while ( my $line = <DATA> ) {
    my @cols = split / /, $line;
    my ( $l, $r ) = ( 0, 0 );
    for ( $l = 0 ; $l <= $#cols ; $l++ ) {
        for ( $r = 0 ; $r <= $#cols ; $r++ ) {
            print $cols[$l] - $cols[$r], " ";
        }
    }
    print "\n";
}
While executing the file, i am getting the error message as follows:

HTML Code:
Name "main::DATA" used only once: possible typo at ./example.pl line 6.
readline() on unopened filehandle DATA at ./example.pl line 6.
Can you tell me, where is the mistake? As per the error message, in line 6 DATA has been used only once.

Expecting your reply and thanks in advance.

Warm regards
Fredrick.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Subtracting date / timestamps

I have looked through the forums and found many date / time manipulation tools, but cannot seem to find something that fits my needs for the following. I have a log file with date time stamps like this: Jun 21 17:21:52 Jun 21 17:24:56 Jun 21 17:27:59 Jun 21 17:31:03 Jun 21 17:34:07 Jun... (0 Replies)
Discussion started by: roadcyclist
0 Replies

2. UNIX for Dummies Questions & Answers

Subtracting an Integer from a Variable

Hello, I am in following situation.- COUNT=`ls -l | wc -l` echo $COUNT ---> 26 NO_OF_FILES=$COUNT-1 echo $NO_OF_FILES ---> 26-1 Here, I want the output to be 25. How could I do this. It seems simple, but I am not getting it. Please help me. (2 Replies)
Discussion started by: The Observer
2 Replies

3. Shell Programming and Scripting

comparing files - adding/subtracting/formating columns

I have two files: file1.txt: FS Total Used Free Used% /u01 10000 8000 2000 80% /u02 10000 8000 2000 80% /u03 10000 8000 2000 80% /u04 10000 8000 2000 80% /u05 10000 8000 2000 80% /u06 10000 8000 2000 80% /u07 10000 8000 2000 80% /u10 10000 5000 5000 50% file2.txt:... (7 Replies)
Discussion started by: oabdalla
7 Replies

4. Shell Programming and Scripting

subtracting variables in ksh

hi all, how do i subract variables in shell ?? am trying to space out the headers and the output generated by the shell so they all line up : currently the output is like this : servers : users server1 : 10 latestServer : 50 so i thought... (3 Replies)
Discussion started by: cesarNZ
3 Replies

5. Shell Programming and Scripting

Subtracting with awk?

i have a small awk script which prints the 5 columns of different o/p i want the 5th column subtracted from 100 and then display the result .. but i do not get the desired result .. I 'm using following script awk ' BEGIN { FS="" RS="us" } { ... (3 Replies)
Discussion started by: fugitive
3 Replies

6. UNIX for Dummies Questions & Answers

Subtracting values from 2 columns in a file

Hello, I have a file with 5 columns that looks like this: A1BG chr19 + 58863335 58866549 A1BG chr19 - 58858171 58864865 A2LD1 chr13 - 101182417 101186056 A2LD1 chr13 - 101182417 101241046 A2M chr12 - 9220303 9268558 A2ML1 ... (5 Replies)
Discussion started by: wolf_blue
5 Replies

7. Shell Programming and Scripting

Searching columns and subtracting values in awk

Hi everyone, I had a similar question a couple days ago but my problem has gotten significantly (to me anyway) more complex. I have two files: File 1: 0808 166 166 62 9 0 1000fights 1 1 2 1 0 100places2visit 2 2 2 2 0 10veronica91 167 167 3 1 0 11thgorgeous 346 346 3806 1461 122... (2 Replies)
Discussion started by: collards
2 Replies

8. Shell Programming and Scripting

Subtracting values from variable

Legends, Please help me in , how do i subtract the variable values listed like below. the first value of orig should be subtracted from first value of prev and so on. san> echo $orig 346 316 340 239 410 107 291 139 128 230 167 147 159 159 172 116 110 260 177 0 177 169 168 186 165 366 195... (15 Replies)
Discussion started by: sdosanjh
15 Replies

9. Answers to Frequently Asked Questions

Subtracting two files

Hi, I want to subtract 2 files and save the remaining text in another file. Lets say, Hello Happy // Hi * Hungry File2 Happy Hi Output Hello (5 Replies)
Discussion started by: beginner_99
5 Replies

10. Shell Programming and Scripting

awk - Adding and Subtracting Numbers from 2 Columns

Hi Folks, I have a file with 2 columns TAB delimited and I want to add '1' to the first column and subtract '-1' from the second column. What I have tried so far is; awk -F"\t" '{ $1-=1;$2+=1}1' OFS='\t' file File 0623 0623 0624 0624 0643 0643 1059 1037 1037 1037 1038 1038... (2 Replies)
Discussion started by: pshields1984
2 Replies
SGML2HTML(1)						      General Commands Manual						      SGML2HTML(1)

NAME
sgml2html - create HTML output from a LinuxDoc DTD SGML source file SYNOPSIS
sgml2html [generic-option...] [--split 0|1|2 ] [--toc 0|1|2 ] [--dosnames] [--imagebuttons] file[.sgml] DESCRIPTION
sgml2html is an old and obsoleted form of the html converter command of LinuxDoc-Tools. It is recommended to switch the new form linuxdoc -B html now. This converts a LinuxDoc DTD SGML source file to HTML output. Output will appear in the top level file file.html and file- n.html for each section, where file is the name of the SGML source file and n is the section name. The attribute/value pair "output=html" is set for conditionals. OPTIONS
sgml2html accepts all the generic options described in linuxdoc(1), and the following specific options: --split, -s What level to split source documents. 0 = don't split, 1 = split by major sections, 2 = split by subsections. --toc, -T What level to generate toc. 0 = don't generate toc at all, 1 = includes major sections(/chapters/parts), 2 = includes subsections. --dosnames, -h Use ".htm" rather than ".html" as the extension of --imagebuttons, -I Use the "next", "previous", and "contents" arrow image icons included in /usr/share/linuxdoc-tools as navigation buttons. --footer, -F Use the specified file as the footer in each resulted html file. Default footer is just plain </BODY> </HTML> --header, -H Use the specified file as the top part of the header in each resulted html file. Note this is not the full part of the header. (i.e. the title and the links (next,previous,contents) in the default header are retained. Default is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> file The SGML source file, named either file or file.sgml. FILES
Many files and executables in /usr/share/linuxdoc-tools and /usr/bin are used. BUGS
None known. AUTHOR
Originally written by Greg Hankins <greg.hankins@cc.gatech.edu>, and Cees de Groot <cg@cdegroot.com> for SGML-Tools (v1). Currently main- tained by Taketoshi Sano <sano@debian.org> for Linuxdoc-Tools. SEE ALSO
linuxdoc(1), sgml2info(1), sgml2latex(1), sgml2lyx(1), sgml2rtf(1), sgml2txt(1), sgmlcheck(1). 16 May 2000 SGML2HTML(1)
All times are GMT -4. The time now is 06:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy