Hi there, i want to implement a a system to search for a file in a folder using the file name and if its there, i want it to be displayed. I have one through a couple of books on how to implement this but still, it does not open the file.
Above is how far i've gone, please can anyone help me on this.
Stunna
8 1857 KevinADC 4,059
Recognized Expert Specialist
What does happen when you run your script?
When i run the script, it does not open the file specified nor attempt to open a file, it just displays the error message that the file does not exist even though i put in a fcorrect file name that exists. It simply does not attempt to search for the file. Actually, am trying to implement a system that searches a folder for a file and displays it. Thanks for your interest
KevinADC 4,059
Recognized Expert Specialist
change this line: - open(FILE, "<C:/docs/media/$name") or print "<p> File '$name' does not exist";
to: - open(FILE, "<C:/docs/media/$name") or die "Can't open 'C:/docs/media/$name' : $!";
-
and see what gets printed. If you are entering a valid filename and perl can't open it and the path and filename is correct, I don't know what the problem is.
Thanks very much for your help so far. I think the problem is when i uploaded the file, it stored the file path and not the file name. Do you know how to strip of the file path or directory tree from the file name so that only the filename is stored. And usually when searching for a file, one might not know the filepath.
miller 1,089
Recognized Expert Top Contributor
Hi stunna,
Yes, use the File::Basename core library. -
use File::Basename qw(basename);
-
-
my $filename = "whatever your full path plus filename is";
-
-
my $basename = basename($filename);
-
- Miller
i used what you suggested but i get an error message "fileparse( ): need a valid pathname"
Sorry, just sorted it out. Thanks guys for your help, i reallly appreciate
miller 1,089
Recognized Expert Top Contributor
Sorry, just sorted it out. Thanks guys for your help, i reallly appreciate
Your welcome. Glad you were able to figure it out.
- Miller
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jeff_Relf |
last post by:
Hi Tom, You showed: <<
private const string PHONE_LIST =
"495.1000__424.1111___(206)564-5555_1.800.325.3333";
static void Main( string args ) {
foreach (string phoneNumber in Regex.Split (PHONE_LIST, "_+")) {
Console.WriteLine (phoneNumber); } }
Output:
495.1000
|
by: Jean-Marc Blaise |
last post by:
Dear all,
Will we be able to apply FP8 (that comes out end of January) directly
without obligation to go thru FP7a or will we have to step thru FP7a ?
I wish to know the answer for both 8.1 and migration from V7.2 to 8.2 FP8.
Best regards,
Jean-Marc
|
by: joshc |
last post by:
If I have an array of data that I know to be sorted in increasing
order, and the array is less than 50 elements, and I want to find the
first element greater than a certain value, is a simple linear search
the best here(for loop from beginning to end of array)? It seems like
some other search algorithm like binary or whatever would be of no
benefit on this data set.
|
by: lawrence k |
last post by:
Here is the thing. When you go to this page:
http://www.accumulist.com/index.php?search%5BallFields%5D=api
I've put in some HR tags in the HTML to separate the 3 different
queries. After those 3 queries you'll see results at the bottom. For
me, those results look like this:
api (4), darren (1), xml (12), battlepanda (1), war+on+drugs (6),
stupid (1), moron (1), nightmare (1), hell (1), mijkuynbvfsds (1),
|
by: arnuld |
last post by:
hai folks,
well, it's me again and again, i am asking questions. anyway, with
your help i have finalised that i will start learning c++ (as you told
me that i do not need to know any OO language before c++). that was 15
days ago IIRC. now that with my skill set i went on to search for a
good book. my knowledge is limited to the following:
1.) "A gentle introduction to symbolic computation" - David S.
Touretzky
| |
by: onetitfemme |
last post by:
Say, people would like to log into their hotmail, yahoo and gmail
accounts and "keep an eye" on some text/part of a site
..
I think something like that should be out there, since not all sites
provide RSS feeds nor are they really interested in providing
consistent and informative content (what we (almost) all are looking
for).
..
I have been mostly programming java lately. THis is how I see such an
API could -very basically indeed- be...
|
by: TheDataGuy |
last post by:
Using MS ACCESS 2002
Problem - I developed a form, and within that FORM, I added a SEARCH BUTTON, and then I created a SUB-FORM, so when an end user clicks on the FORM it will POP-UP the SUB-FORM, and in that SUB-FORM I added all the FIELDS I want to view.
However, when I try to type in data into the FIELDS I am searching for, it does not let me. I would just like to type in an ID or the name of the Document and have Access PULL that...
|
by: narayan2586 |
last post by:
Hi all,
When ever i am trying to connect my application it's giving below error message:
RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: ; nested exception is: javax.ejb.EJBException: Connection to pool failed! - com.ibm.websphere.ce.cm.StaleConnectionException: SQL1224N The database manager is not able to accept new requests, has terminated all requests in progress, or has terminated your...
|
by: Ragavendran |
last post by:
Hi,
I am using this method for search:
Query =org.apache.lucene.queryParser.QueryParser.parse(String arg0) throws ParseException
Hits = org.apache.lucene.search.Searcher.search(Query query, Sort sort) throws IOException
Problem :
I cant able to search the word. If the word contain special character like , %BF It just taken that special character a empty space and search the remaining character
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |