in reply to Re: Quick Regex question
in thread Quick Regex question

(fastolfe) gemina:~$ cat test use File::Basename; fileparse_set_fstype('MSWin32'); # Because I'm on Unix while (<DATA>) { chomp; printf("%20s %s\n", $_, basename($_)); } __DATA__ a:\pic3.jpg a:\some\dir\pic.jpg a:\some\other\pic \blah\pic. a:\pic a:pic.jpg a:\pic3. (fastolfe) gemina:~$ perl test a:\pic3.jpg pic3.jpg a:\some\dir\pic.jpg pic.jpg a:\some\other\pic pic \blah\pic. pic. a:\pic pic a:pic.jpg pic.jpg a:\pic3. pic3.
So if File::Basename is working properly, perhaps your input is messed up somehow? Are you reading your filenames from a file perhaps and forgetting to chop off the newline?

Replies are listed 'Best First'.
Re: Re: Re: Quick Regex question
by Stamp_Guy (Monk) on Jan 14, 2001 at 07:36 UTC
    Let me explain in a little more detail what I'm trying to do. I have a form that writes to a text database. In that form, I have file upload fields that are used solely to get filenames for a photographic tour. When the names are written to the database, they have to have their paths chopped off. Those upload fields don't upload images because I couldn't get an upload script working that would upload that many images at once... The filenames are written to a text file (after having their paths chopped off) that tells what files need to be uploaded. Any path works so long as it has some folder in the path. Eg: A:\pic3.jpg would not work, whereas A:\test\pic3.jpg would.
      What was the problem getting the upload images to work? Just use CGI. To the best of my knowledge the only limits are throttles in CGI.pm and/or in the webserver that limit the size/number of uploads to avoid denial of service attacks. If those limits are a problem, they should be configurable and instructions to configure it should be in the documentation.
        Don't I wish it were that easy!!! I used CGI, but I couldn't get it working for the life of me, even after a week solid of work and trying out 5 different scripts! I finally got one that works for one file at a time without using CGI.pm, and it is stable. I gave up after getting that frustrated. One file isn't all that bad either when you have a slow connection. My web server has TERRIBLE documentation and I don't even have telnet access to it, so I have no clue what checks are in place there. Got any tested scripts that upload multiple files at once and work on both UNIX and WIN9X/NT boxes? If so, I would be really interested in seeing them.
        Don't I wish it were that easy!!! I used CGI, but I couldn't get it working for the life of me, even after a week solid of work and trying out 5 different scripts! I finally got one that works for one file at a time without using CGI.pm, and it is stable. I gave up after getting that frustrated. One file isn't all that bad either when you have a slow connection. My web server has TERRIBLE documentation and I don't even have telnet access to it, so I have no clue what checks are in place there. Got any tested scripts that upload multiple files at once and work on both UNIX and WIN9X/NT boxes? If so, I would be really interested in seeing them.
      If sounds like you just want s/.*\\// or perhaps s!.*[\\/:]!!
      But why do you say that File:Basename did not work?
        I'll try that one too, but for some reason, File::Basename wouldn't cut the path off for me. Wierd, huh?