CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
stripping the root / path from a input field filename

 



eontek
Deleted

Oct 19, 2000, 11:52 AM

Post #1 of 5 (440 views)
stripping the root / path from a input field filename Can't Post

I am grabbing an input field "file" from a form and manipulating the variable in my perl code. I have one problem where I need to strip the path and root off of the file when some one fills it out in the form.


japhy
Enthusiast

Oct 19, 2000, 12:17 PM

Post #2 of 5 (440 views)
Re: stripping the root / path from a input field filename [In reply to] Can't Post

There's a module that comes with Perl to help you do this. Look at the documentation for File::Basename.

------------------
Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher



eontek
Deleted

Oct 19, 2000, 2:01 PM

Post #3 of 5 (440 views)
Re: stripping the root / path from a input field filename [In reply to] Can't Post

OK I've figured out this much w/o finding the documentation..

i've used

--------------------------------
use File::Basename;
$fnonefull = "$FORM{'file-to-upload-01'}";
($base,$dir,$type) = fileparse $fnonefull,'\.jpg');

$fnone = $base;

------------------------------
however, when displaying the

$base = "C:\winnt\dir\test"
$type = ".jpg"
$dir = "./"

?? whats a miss

I need for $base = "test.jpg"

?? help please!!


Kanji
User / Moderator

Oct 19, 2000, 2:24 PM

Post #4 of 5 (440 views)
Re: stripping the root / path from a input field filename [In reply to] Can't Post

 <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>OK I've figured out this much w/o finding the documentation.. <HR></BLOCKQUOTE>

That's your problem right there: you didn't RTFM, and there's no good reason for you not to.

Not being able to fnd the documentation is a pretty lame excuse as it's contained within the module itself (run the command "perldoc File::Basename") and all over the web.

Major hint: fileparse_set_fstype.


eontek
Deleted

Oct 19, 2000, 2:51 PM

Post #5 of 5 (440 views)
Re: stripping the root / path from a input field filename [In reply to] Can't Post

Sorry, I didn't know the command.. I did a search on file::basename and figured out that much from my results..

$fnonefull = "$FORM{'file-to-upload-01'}";
$fname = $fnonefull;
$fname =~ s!^.*(\\|\/)!!;
$fnone = $fname;

I found this tidbit that seems to work, however, I don't know the logic behind why or how it works.. I just plucked it from another piece of code..

I'm a very very basic beginner..

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives