How can I modify my awk code to get rid of the divion by zero error message? If I run the script without an input file, it should return error message "Input file missing" but not divison by zero.
Code:
#!/bin/nawk -f
BEGIN {
if (NR == 0)
{print "Input file... (4 Replies)
I need to read the file divide 3 column with 2nd and run a modulus of 10 and check whether the remainder is zero or not if not print the entire line.
cat filename | awk '{ if ($3 / $2 % 10 != 0) print $0}'
Whats wrong with it ? (4 Replies)
I received error "awk: division by zero" while executing the following statement.
SunOS 5.10 Generic_142900-15 sun4us sparc FJSV,GPUZC-M
echo 8 | awk 'END {printf ("%d\n",NR/$1 + 0.5);}' file1.lst
awk: division by zero
Can someone provide solution?
Thanks
Please use code... (11 Replies)
hello
i try to divide 2 variables in order to get a percentage--that's why i'm not interested in integer division--but nothing seems to work
I think awk is suitable for this but i'm not quite sure how to use it..
any ideas?
here's what I want to do:
percentage = varA/varB
thank you (2 Replies)
Hi Friends,
I have an input file like this
cat input
chr1 100 200 1 2
chr1 120 130 na 1
chr1 140 160 1 na
chr1 170 180 na na
chr1 190 220 0 0
chr1 220 230 nd 1
chr2 330 400 1 nd
chr2 410 450 nd nd
chr3 500 700 1 1
I want to calculate the division of 4th and 5th columns. But, if... (3 Replies)
Hi Friends,
I don't understand why "a" is always being printed as zero, when I execute the following command.
awk '{if($6||$8||$10||$12==0)a=b=c=d=0;else (a=$5/$6);(b=$7/$8);(c=$9/$10);(d=$11/$12); {print... (6 Replies)
Hello,
How can I add a logic to awk to tell it to print 0 when encountering a division by zero attempted? Below is the code. Everything in the code works fine except the piece that I want to calculate read/write IO size. I take the kbr / rs and kbw / ws. There are times when the iostat data... (5 Replies)
Discussion started by: tommyd
5 Replies
LEARN ABOUT DEBIAN
html::formfu::constraint::callbackonce
HTML::FormFu::Constraint::CallbackOnce(3pm) User Contributed Perl Documentation HTML::FormFu::Constraint::CallbackOnce(3pm)NAME
HTML::FormFu::Constraint::CallbackOnce - Code Callback Constraint
SYNOPSIS
$form->constraint({
type => 'CallbackOnce',
name => 'foo',
callback => &sfoo,
);
sub foo {
my ( $value, $params ) = @_;
# return true or false
}
DESCRIPTION
Unlinke the HTML::FormFu::Constraint::Callback, this callback is only called once, regardless of how many values are submitted.
The first argument passed to the callback is the submitted value for the associated field; this may be a single value or an arrayref of
value. The second argument passed to the callback is a hashref of name/value pairs for all input fields.
This constraint doesn't honour the "not()" value.
METHODS
callback
Arguments: &sub_ref
SEE ALSO
Is a sub-class of, and inherits methods from HTML::FormFu::Constraint
HTML::FormFu
AUTHOR
Carl Franks "cfranks@cpan.org"
LICENSE
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2012-01-23 HTML::FormFu::Constraint::CallbackOnce(3pm)