Perl : Error in calling script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl : Error in calling script
# 1  
Old 05-12-2011
Perl : Error in calling script

I am getting a strange error with perl's inbuilt script flush.pl. I am callling this script in my other script but it kept throwing error:
flush.pl did not return a true value at ./abc.pl line 1

abc.pl has:
require 'flush.pl';

Not sure why this error is coming. Can someone pls throw some light on how to rectify this error. Just to let you know, I can't remove flush.pl from my script.

Thanks, Abhi
# 2  
Old 05-12-2011
All Perl modules that are used or required have to "return" a true value. Simplest way: write a single 1; on a stand-alone line at the very bottom of your module.
# 3  
Old 05-12-2011
I agree with you.. But this is the perl's own script residing in its own libraries so I can't modify it. And also this script already has 1; at the end of it. Pls see below code snippet of this script:

flush.pl
--------
Code:
sub printflush {
    local($old) = select(shift);
    $| = 1;
    print @_;
    $| = 0;
    select($old);
}
1;

Moderator's Comments:
Mod Comment Please start using [CODE] tags for listings etc...

Last edited by pludi; 05-12-2011 at 05:57 AM..
# 4  
Old 05-12-2011
Slould be:
Code:
sub printflush {
local($old) = select(shift);
$| = 1;
print @_;
$| = 0;
select($old);
1;
}

# 5  
Old 05-12-2011
Hm, on my system with Perl 5.10.1 it's no problem to run
Code:
perl -we 'require "flush.pl"; &flush(*STDOUT);'

Can you post any more code, your Perl version used, ... any information that might be relevant.

As a side note, the file explicitly states that
Code:
# This library is no longer being maintained, and is included for backward
# compatibility with Perl 4 programs which may require it.
#
# In particular, this should not be used as an example of modern Perl
# programming techniques.

so it might be better to switch to IO::Handle, or change the value of $| (see [url=http://perldoc.perl.org/perlvar.html]perldoc perlvar[/icode] for a description)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calling a shell script present on another server using perl script.

Hi, I am working on a sever A. I want to write a perl script to execute a shell script persent on the server B. please help me in this. thanks in advance. (3 Replies)
Discussion started by: anandgodse
3 Replies

2. Shell Programming and Scripting

How we can pass the argument when calling shell script from perl script

Can someone let me know how could I achieve this In one of per script I am calling the shell script but I need to so one thing that is one shell script call I need to pass pne argument.In below code I am calling my ftp script but here I want to pass one argument so how could I do this (e.g:... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies

3. Shell Programming and Scripting

calling a perl script with arguments from a parent perl script

I am trying to run a perl script which needs input arguments from a parent perl script, but doesn't seem to work. Appreciate your help in this regard. From parent.pl $input1=123; $input2=abc; I tried calling it with system("/usr/bin/perl child.pl $input1 $input2"); and `perl... (1 Reply)
Discussion started by: grajp002
1 Replies

4. Shell Programming and Scripting

Calling a Perl script in a Bash script -Odd Situation

I am creating a startup script for an application. This application's startup script is in bash. It will also need to call a perl script (which I will not be able to modify) for the application environment prior to calling the application. The problem is that this perl script creates a new shell... (5 Replies)
Discussion started by: leepet01
5 Replies

5. Shell Programming and Scripting

Calling 3 perl script from one

hi all, I have 3 perl scripts a.pl,b.pl and c.pl each of these work when i pass a date for eg: perl c.pl 2010-05-27 now i want to write a perl script that would call the 3 scripts and make it run all the 3 scripts (a.pl,b.pl,c.pl) parallelly rather than 1 after the other....... pls... (2 Replies)
Discussion started by: siva_nagarajan
2 Replies

6. UNIX for Dummies Questions & Answers

Calling a c program using perl script

On bash I run precompiled c Program as follows: ./create_cust 1 10000 US S > us_cust.csv create_cust is a c program and requires 4 parameters. I am redirecting the output of this program to csv file I need to run this same program in perl I am aware of exec command though not... (7 Replies)
Discussion started by: gkbond
7 Replies

7. Shell Programming and Scripting

calling problem in perl script

Hi , Here is my piece of code-- main(); sub main { $result = GetOptions ("LogDir=s" => \$LogDir, "Summary" => \$Summary, "Indiviual=s" => \$Individual , "Diagnostics=s" => \$Diagnostics, ... (1 Reply)
Discussion started by: namishtiwari
1 Replies

8. Shell Programming and Scripting

Calling Expect script in Perl...

I call a EXPECT script from my perl script with machine IP and a FIle. The script logins to the machine and exports the value. The values to be exported or stored in a file. I have close to 10 machines and I have created 10 files and pass the corresponding files in command line, Now I could like... (4 Replies)
Discussion started by: ramkriz
4 Replies

9. Shell Programming and Scripting

Calling Winzip from perl script

Hi, I would like to invoke "Winzip" utility from a perl script, input the name of zip file and provide output path for unzipped files. Any pointers will be appreciated. Thanks (5 Replies)
Discussion started by: MobileUser
5 Replies

10. Shell Programming and Scripting

calling a shell script from perl

Hi all, Not sure if this is the right forum to post query regarding perl script. I have a perl script which internally calls a shell script. My problem is that the shell script should be passed command line arguments. I call a shell script from perl using: system("sript.sh"); How do... (3 Replies)
Discussion started by: gurukottur
3 Replies
Login or Register to Ask a Question