Sponsored Content
Top Forums Shell Programming and Scripting creating/using libraries Perl...blank outout? Post 302416278 by bigben1220 on Monday 26th of April 2010 02:52:24 AM
Old 04-26-2010
creating/using libraries Perl...blank outout?

Good morning!!

Im trying to create a script that should get a list of numbers from the user (using STDIN or a list of arguments), and call my library function.
Code:
#!use/bin/perl

require 'my-lib.pl';
@userArray = <STDIN>;

while()
{
chomp;
last if ! /\d/;
push(@userArray,&_);
}
($sum,$avg) = $sumIt(@userArray);

print "Total:$sum\nAverage\n:$avg\n";

Im my library it should contain a function that takes in an array of numbers, then the function will calculate the average of the numbers, the total of the numbers and a new array of numbers which is divided by 2. The new list will contain all this information.

My library:
Code:
sub sumIt {
my @functionArray = @_;
forwach my $line(@functionArray){
$functionSum += $line;
$count++
}
return ($sunctionSum,$functionSum / $count);
}
1:

But it doesnt return anything to help me. No errors, nothing. It appears to hang?

Any help with this will be greatly appreciated!
Bigben

Last edited by Franklin52; 04-26-2010 at 04:00 AM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

blank line deletion in a file using perl

Dear All, I am looking for an option in perl using which i could delete empty lines in a file. Or the alternative of sed '/^$/d' <filename> in perl. Sed is not working in my perl script :( Pls help me out . Thanks, VG (4 Replies)
Discussion started by: vguleria
4 Replies

2. Shell Programming and Scripting

Blank space cause error when use perl

I write a script with register and login user. So, i encrypt password with encryptedpass=`perl -e "print crypt("${mypass}",salt)"` if password do not contain blank space, it work but if password have blank space, it cause error in that line the error is: syntax error at -e ..... Anyone... (3 Replies)
Discussion started by: WuZun
3 Replies

3. Shell Programming and Scripting

Count uncommented, blank and source lines in perl

Hi friends, I am working on a perl script to count the commented lines, blank lines and source lines separately. Let me know if you have one. For example i have a file containing the lines: /** * SOURCE CODE */ public class SessionConstants { /** * Code for Session created */... (4 Replies)
Discussion started by: nmattam
4 Replies

4. Shell Programming and Scripting

using libraries with Perl..getting blank output

Good morning!! Im trying to create a script that should get a list of numbers from the user (using STDIN or a list of arguments), and call my library function. My script: #!use/bin/perl require 'my-lib.pl'; @userArray = <STDIN>; while() { chomp; last if ! /\d/;... (1 Reply)
Discussion started by: bigben1220
1 Replies

5. Shell Programming and Scripting

getting requestName from xml outout in log file

hi all, i was wondering if there is an easy and smart way of greping for requestname (in bold below) from xml output from application log file on a solaris 10 system. The requestName is the actual method name which gets called e.g it could be 'getAccount' or getId or getAddress etc etc ... (1 Reply)
Discussion started by: cesarNZ
1 Replies

6. UNIX for Dummies Questions & Answers

Creating a blank string of a specified size

I want to have a string which has n blank spaces For example set N = 3 create str = " " So the length depends on the value of N. I am in tcsh. (4 Replies)
Discussion started by: kristinu
4 Replies

7. Shell Programming and Scripting

Replicating jobs, renaming outout

Can anyone tell me if it's possible to write a script that will repeat the same job several times but give the output a slightly different name each time (i.e. change or add a number at the end of the output file)? Here is the script I use to run a single job: #!/bin/bash #PBS -N job0 #PBS -l... (1 Reply)
Discussion started by: peterjb100
1 Replies

8. Shell Programming and Scripting

awk to indent file outout

i have a file that contains information such as this: hostname.sky.net === 12.39.59.35 hostname.sky.net === 12.39.59.35 hostname.sky.net === 12.39.59.35 hostname-newyork.sky.net ==== 13.45.35.24 hostname-newyork.sky.net ==== 13.45.35.24... (3 Replies)
Discussion started by: SkySmart
3 Replies

9. Shell Programming and Scripting

Bc in shell script is creating blank files

Hi, I am creating a shell script which will check the processing of the main script if the error count is more than 2% of the record count in a feed. Part of the code is below: err_tol=`echo $feed_cnt \* 0.02 |bc` while read line do err_cnt=$(grep -i "$line" $err_log | wc -l) ... (5 Replies)
Discussion started by: member2014
5 Replies

10. Programming

Perl: restrict perl from automaticaly creating a hash branches on check

My issue is that the perl script (as I have done it so far) created empty branches when I try to check some branches on existence. I am using multydimentional hashes: found it as the best way for information that I need to handle. Saing multidimentional I means hash of hashes ... So, I have ... (2 Replies)
Discussion started by: alex_5161
2 Replies
ERR_load_strings(3)						      OpenSSL						       ERR_load_strings(3)

NAME
ERR_load_strings, ERR_PACK, ERR_get_next_error_library - load arbitrary error strings SYNOPSIS
#include <openssl/err.h> void ERR_load_strings(int lib, ERR_STRING_DATA str[]); int ERR_get_next_error_library(void); unsigned long ERR_PACK(int lib, int func, int reason); DESCRIPTION
ERR_load_strings() registers error strings for library number lib. str is an array of error string data: typedef struct ERR_string_data_st { unsigned long error; char *string; } ERR_STRING_DATA; The error code is generated from the library number and a function and reason code: error = ERR_PACK(lib, func, reason). ERR_PACK() is a macro. The last entry in the array is {0,0}. ERR_get_next_error_library() can be used to assign library numbers to user libraries at runtime. RETURN VALUE
ERR_load_strings() returns no value. ERR_PACK() return the error code. ERR_get_next_error_library() returns a new library number. SEE ALSO
err(3), ERR_load_strings(3) HISTORY
ERR_load_error_strings() and ERR_PACK() are available in all versions of SSLeay and OpenSSL. ERR_get_next_error_library() was added in SSLeay 0.9.0. 0.9.7a 2000-02-24 ERR_load_strings(3)
All times are GMT -4. The time now is 04:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy