Hi Everyone,
i have written small code where it fetches the required files from required dir path
& deleting those files before proceeding further.
script goes like this: -
my $@file_names;
-
my $full_path;
-
my $dir = "c:\\svap\\input\\";
-
my $file_name ="*.xls";
-
&check_file($dir,$file_name);
-
-
sub check_file($dir,$file_name){
-
$full_path = $dir.$file_name;
-
@file_names = glob($full_path);
-
if(@file_names eq 0){
-
print " no *.xls file found,can proceed further!!!";
-
}
-
else{
-
foreach my $i(@file_names){
-
unlink "$i";
-
}
-
}
-
}
-
The above code works fine if there is only *.xls file but my problem is:
sometimes i get *.xls + filename.xls.xls files in the dir
how to delete these *.xls.xls files with out altering the $file_name value(ie,$file_name = "*.xls.xls")
Can anyone help me on this ???
Regards,
Vijayal
4 1679
The code you posted will not even run, so post some good code. There is little sense in helping you with code that is bad to begin with.
Bareword found where operator expected at script line 2, near "$@file_names"
(Missing operator before file_names?)
Illegal character in prototype for main::check_file : $dir,$file_name at script line 8 .
Bareword found where operator expected at script line 2, near "$@file_names"
(Missing operator before file_names?)
Illegal character in prototype for main::check_file : $dir,$file_name at script line 8 .
Can't use global $@ in "my" at script line 2, near "my $@"
syntax error at script line 2, near "$@file_names"
Hi Kevin,
As i am newbiee to perl, it was my mistake(type error)
2nd line has to be:
and then in line no 8, am just trying to concatenate the 2 values to get this value
please can you help me to delete *.xls.xls file ??
Thanks,
Vijayarl
There are other problems with your code. See how this works: - my $dir = 'c:\svap\input\\';
-
my $file_name = '*.xls';
-
&check_file($dir,$file_name);
-
-
sub check_file {
-
my ($dir, $path) = @_;
-
my @file_names = glob("$dir$path");
-
if(@file_names == 0){
-
print " no *.xls file found,can proceed further!!!";
-
}
-
else{
-
foreach my $i (@file_names){
-
unlink "$i" or print "Can't delete $i : $!\n";
-
}
-
}
-
}
hi Kevin,
Thank you very much for your support... it really worked ..
able to rectify my mistakes from you..
thanks once again...
pls keep doing good work, it helps all newbiee's in perl.
bye
vijayarl
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alfons |
last post by:
Hello,
I have build a program that can do file transferring between a Windows
XP computer and a DOS computer via a serial port. The Windows program
I have build in C++ with Visual Studio 6.0....
|
by: Amar |
last post by:
I am trying to connect to my college LDAP directory using ASP.NET. This LDap
does not have security as it returns only user demographic information.
i do not need to bind with a username or...
|
by: Justin Time |
last post by:
Is there any way to to get a list of file names that were deleted as a
result of deleting their parent directory??
Cheers
|
by: Pitcairnia |
last post by:
The basic purpose of the site is for authenticated users to post event
listings, which often include photographs. The user is faced with a page
where they can insert all of the information about...
|
by: Wysiwyg |
last post by:
I'm going back to a previous asp.net (C#) web project after a few months of
inactivity and my first form, the login, won't submit. I ran with the
debugger and still can't see how to resolve this. I...
|
by: Lee |
last post by:
Hi,
when deleting a directory using;-
string dir = "whatever";
Directory.Delete(dir);
it fails if files/directories exist within the directory being deleted. is
there an easy way of...
|
by: vijju |
last post by:
Hi all !
I'm an amateur to DB2.I installed DB2 ESE trial edition on
my system.It was all going well and suddenly when i was trying to
create an instance, i faced a problem which i listed it below....
|
by: James Wong |
last post by:
Hi,
After I use the function "Directory.Delete" or "Directory.Move", my session
will destory.
Why? Thanks.
James
|
by: john20 |
last post by:
Hi All,
I am trying to use webpart in my page for that i am putting webpartmanager and webpartzone.
but as soon as i am putting webpartmanger in the page it is giving me below error, let me...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |