The $file variable is out of scope when you check it. It doesn't exists when the foreach loop ends. Try using an additional array variable.
And I suppose you will have to reasign user input to the variable @func1 inside the loop, because instead results will always be the same and incorrect.
I know this must be really easy, but i can't get it to work
I've got a perl script, with a file.
I want to print an empty line, and the following doesn't seem to work:
print nameoffile "\n"
thanks for your help!! (3 Replies)
Hi,
May I know how to check for empty file in Perl.
Iam missing something, somewhere.
#!/usr/bin/perl
my $open_dir = '/path/';
my $file;
my $ma = "abc_.*.\.psv\$"
opendir(VAR, $open_dir) or die "Can't open $oepn_dir: $!\n";
while( defined ($file = readdir VAR) ) #read all... (1 Reply)
Hi All,
I am checking for a empty input file to do some further action , but I am getting exit status 0 in both the cases , for empty and non empty file both.
The value of $? is coming 0 in if part also and else part too.
#!/bin/ksh
if ]; then
echo "data"
# exit 0
echo "$?"
else... (4 Replies)
I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Hi Everyone,
I am looking for neat way to grep a non-empty string that basically contains a hostname, which might be in FWDN form or without the domain, for example:
hostname.internal.domainname.net
The file I am parsing contains blan lines (^$) and also series of "-" which in other places... (2 Replies)
Hi, I got problem with queue code how to determined empty and full and problem with while loop
Here is my pseudo code :
Input page Access
Input Pgae Frame
For i =3 to pageframe count by 1
construct queue of size i
set pageFaultCount to 0
while morepages do
page = NextPage... (1 Reply)
Hi Guys,
i'm writing a perl script which whenever runs, should empty 3 pre-decided directories as first step and then the script has the logic to parse some other directories and copy the files inside those directories into these 3 directories. I've the logic already developed, just need to... (2 Replies)
Hi
The below script used to work fine. Suddenly it's uploading empty file. I am very new to perl. Please help me to find out the problem.
#!/usr/bin/perl
#script: upload.pl
use CGI qw/:standard/;
print header,
start_html('File upload');
print_form();
print_results() if... (2 Replies)
Discussion started by: Anupam_Halder
2 Replies
LEARN ABOUT DEBIAN
autouse
autouse(3perl) Perl Programmers Reference Guide autouse(3perl)NAME
autouse - postpone load of modules until a function is used
SYNOPSIS
use autouse 'Carp' => qw(carp croak);
carp "this carp was predeclared and autoused ";
DESCRIPTION
If the module "Module" is already loaded, then the declaration
use autouse 'Module' => qw(func1 func2($;$));
is equivalent to
use Module qw(func1 func2);
if "Module" defines func2() with prototype "($;$)", and func1() has no prototypes. (At least if "Module" uses "Exporter"'s "import",
otherwise it is a fatal error.)
If the module "Module" is not loaded yet, then the above declaration declares functions func1() and func2() in the current package. When
these functions are called, they load the package "Module" if needed, and substitute themselves with the correct definitions.
WARNING
Using "autouse" will move important steps of your program's execution from compile time to runtime. This can
o Break the execution of your program if the module you "autouse"d has some initialization which it expects to be done early.
o hide bugs in your code since important checks (like correctness of prototypes) is moved from compile time to runtime. In particular,
if the prototype you specified on "autouse" line is wrong, you will not find it out until the corresponding function is executed. This
will be very unfortunate for functions which are not always called (note that for such functions "autouse"ing gives biggest win, for a
workaround see below).
To alleviate the second problem (partially) it is advised to write your scripts like this:
use Module;
use autouse Module => qw(carp($) croak(&$));
carp "this carp was predeclared and autoused ";
The first line ensures that the errors in your argument specification are found early. When you ship your application you should comment
out the first line, since it makes the second one useless.
AUTHOR
Ilya Zakharevich (ilya@math.ohio-state.edu)
SEE ALSO perl(1).
perl v5.14.2 2011-09-19 autouse(3perl)