f



file extention from file file location

Hi,

I am new to perl (only working on this one problem) but I program in other
languages.

We have an upload script written in cgi.  Can anyone tell me how to get the
file extension from the variable $File1 (actual file location on uploader's
computer) then find out if it is equal to "txt"

Thanks in advance for not telling me to read the manual.


Ron


-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html
0
Ron
7/23/2003 6:33:17 PM
comp.authoring.cgi 612 articles. 0 followers. Chandran.Rama (1) is leader. Post Follow

3 Replies
1899 Views

Similar Articles

[PageSpeed] 50

"Ron" <his_ron@yahoo.com> wrote in message
news:NxATa.101305$xg5.95041@twister.austin.rr.com...
> Hi,
>
> I am new to perl (only working on this one problem) but I program in other
> languages.
>
> We have an upload script written in cgi.  Can anyone tell me how to get
the
> file extension from the variable $File1 (actual file location on
uploader's
> computer) then find out if it is equal to "txt"
>

if ($File1 =~ /\.txt/i) { # do something if string $File1 contains .txt }

The \ escapes the "dot" which otherwise means a non-space character.
The i at the end says ignore the case so that it will also match .TXT .txt
..TxT etc

Roger



-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html
0
Roger
7/23/2003 6:44:25 PM
"Roger Moffatt" <news@NOSPAMPLEASE.ducati.demon.co.uk> wrote in message
news:bfml29$2s8$1@titan.btinternet.com...
> "Ron" <his_ron@yahoo.com> wrote in message
> news:NxATa.101305$xg5.95041@twister.austin.rr.com...
> > Hi,
> >
> > I am new to perl (only working on this one problem) but I program in
other
> > languages.
> >
> > We have an upload script written in cgi.  Can anyone tell me how to get
> the
> > file extension from the variable $File1 (actual file location on
> uploader's
> > computer) then find out if it is equal to "txt"
> >
>
> if ($File1 =~ /\.txt/i) { # do something if string $File1 contains .txt }
>
> The \ escapes the "dot" which otherwise means a non-space character.
> The i at the end says ignore the case so that it will also match .TXT .txt
> .TxT etc
>
> Roger
>
>
>
> --
> PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
> SELF-MODERATED newsgroup. aa.net and boutell.com are
> NOT the originators of the articles and are NOT responsible
> for their content.
>
> HOW TO POST to comp.infosystems.www.authoring.cgi:
> http://www.thinkspot.net/ciwac/howtopost.html

Thanks Roger,

I have been testing this code with

if ($FILE1 =~ /\.txt/i){
my $Ext1 = "txt";
}else{
my $Ext1 = "NO";
}

Both "my" statements print out without the "if" statement.  FILE1 is a file
location like "C:\MYDir\myNextDir\File name.txt"  can't seem to get this to
work.  Using a W2k machine to upload file to form on the server. I have
printed out the variable $FILE1 so I know I am getting the file location.

Any suggestions?

Ron





-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html
0
Ron
7/23/2003 9:30:10 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <C7DTa.101341$xg5.9517@twister.austin.rr.com>, Ron wrote:
> 
> I have been testing this code with
> 
> if ($FILE1 =~ /\.txt/i){
> my $Ext1 = "txt";
> }else{
> my $Ext1 = "NO";
> }
> 
> Both "my" statements print out without the "if" statement.

And with the if, $Ext1 goes out of scope after the if statement, so
no longer exists.  Declare $Ext1 before the if blocks with my, then
assign to it in the if/else blocks without my.

use strict at the top of your program probably would have alerted you
at least to the fact that $Ext1 was not in scope outside the if blocks.

Oh, BTW, RTFM:

perldoc -f my
perldoc strict
perldoc perlsub

or the appropriate locations in the Camel.

- --keith

- -- 
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
alt.os.linux.slackware FAQ:  http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj8fH34ACgkQhVcNCxZ5ID8FGwCfTcZODmlDzrKnv7MuWPC5qrxe
gawAmgOF+hZHSCFboQaQCr09tOeKBJTM
=br75
-----END PGP SIGNATURE-----

-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html
0
Keith
7/23/2003 11:51:30 PM
Reply:

Similar Artilces:

file.exe file generation from file.m file
How to generate application (*.exe) file from *.m file, which has lots of graphics. Program was written for image watermarking by using image processing toolbox. I want to send this program some where else but with out sowing the program codes. By this *.exe no need to use matlab6.5 platform. Also tell me How to generate *.p file from *.m file Which is hide the code to user but for run this program need matlab6.5 Please give me some idea about it. it is very urgent for me. I will be very great full to you "Biswajit Kar" <hibiswajitkar@rediffmail.com> wrote in message ne...

Iteration through File.file? misses entries for which File.file?(entry) == true
Hello everyone, I'm new to Ruby, so I'm most likely making an elementary mistake. However, searching Google didn't help me find my answer, and after mucking around with irb I still haven't figured it out. I wrote a method that was intended to take all of the files in a given directory and put them into an array. Here's the code I wrote: def getFiles(dir) pwdFiles = Array.new Dir.foreach(dir) do |entry| pwdFiles.push(entry) if File.file?(entry) == true end end This works fine when called on the working directory --- that is, getFile...

How to copy a file to a file with a prefixed file name
I'm trying to write a program that will archive selected files to an archive directory. The files in the archive directory will have a prefix in the format yyyymmdd-hhmmss-filename.ext. So, if the file is called "somefile.dat", then the filename in the archive directory should be "20090522-164325-somefile.dat". I'm using Clipper's COPY FILE command to do the copy. I can't figure out how to get the prefix in front of the file name. Creating the prefix string is no problem, but I can't figure out how to tack that onto the front of the filename. If I...

how to tell if a file is inary file or ascii file?
Hello, Is there a way to find if a file is a binary executable file or an ASCII executable file in unix? especially, if I have a file with permission of --x--x--x. Thanks, Peter peter wrote: > Hello, > > Is there a way to find if a file is a binary executable file or an ASCII > executable file in unix? especially, if I have a file with > permission of --x--x--x. If in a shell you could start with man file Tobias On Wed, 14 Jan 2004 05:31:11 +0000, peter wrote: > Is there a way to find if a file is a binary executable file or an ASCII > executable file in...

Text files read multiple files into single file, and then recreate the multiple files
Hiya, The title says it all really, but im a newbie to python sort of. I can read in files and write files no probs. But what I want to do is read in a couple of files and output them to one single file, but then be able to take this one single file and recreate the files I put into it. Im really at a loss as to how I go about recovering the files? obviously if i scan for a string that specifys the start and end of each file, theres the chance that the file might contain this term to which would split the files into unwanted chucks of file, which wouldnt be wanted. Any ideas? code snippets...

File share, File Sharing, File Host
http://fileuplo.de File share, File Sharing, File Host -- questo articolo e` stato inviato via web dal servizio gratuito http://www.newsland.it/news segnala gli abusi ad abuse@newsland.it ...

write file + input file + write file
Hi, I want to write some latex command to a file (file1), input the file at the end of the document. These command shall write to another file (file2) and at a second run I use the file2. Whatever I have tried nothing works and I don't known why. The goal is to save a set of special commands and run them at the end of the document, because they use some values which are only available at the end! Can anybody please help me with that? Thanks in advance! I should be something like: \begin{document} \usepackage{style} \input{file2} %file exists from a previous run \end{document} style.sty:...

object files, header files, source files?
I can't find any books describing the anatomy of C/C++ programs. What is an object file? Can it be generated from a header file?, what is linking?, why does a source file need an object file? etc. I have looked in The C programming Language, The C++ Programming Language, Accelerated C++, GNU make etc but they don't describe these basic subject. Any literature that covers these subjects? saneman wrote: > I can't find any books describing the anatomy of C/C++ programs. What is > an object file? Can it be generated from a header file?, what is > linking?, why does a s...

How to rebuild the dll file, I only have the dll file, no m file
when I load a dll built by older version matlab, it said Invalid MEX-file ,it's not a valid win32 application. From the matlabcentral, it says to rebuild this mex file then it can be loaded by matlab with version newer than 7 how to rebuild this mex file ? Now I do not have the source m code, but only the dll file xueqian xueqian wrote: > when I load a dll built by older version matlab, it said Invalid > MEX-file ,it's not a valid win32 application. From the matlabcentral, > it says to rebuild this mex file then it can be loaded by matlab with > version newer than 7 > ...

Is file a font file?
How can detect a file without extension is font file or not in cocoa? or any other I tried with CFStringRef fontNam=CFStringCreateWithCString(NULL,[getfile UTF8String],kCFStringEncodingMacRoman); ATSFontRef frefarr= ATSFontFindFromName((CFStringRef)[getArray objectAtIndex:rowcount] ,kATSOptionFlagsDefault); But frefarr gets nil any thing wrong please help, with thanks Excuse my language. Yabber <eyabber@gmail.com> wrote: > How can detect a file without extension is font file or not in cocoa? > > or any other > I tried with > > CFStringRef...

How to find New File,Write file and close file?
Hi Anyone can show me how to find New File,Write File and close file in block diagram.The picture of file names are as show in pics. Thanks &nbsp; Nyan Lin File find.JPG: http://forums.ni.com/attachments/ni/170/322096/1/File find.JPG Hi. The functions You're looking for are under "File I/O --&gt; Advanced File Functions" (At least the NEW File) The 2 others are in the "File I/O" menu on the functions palette. Good luck.Message Edited by BCL@Servodan on 05-08-2008 03:38 AM Hi again. My mistake. I was looking in my LabView7. In 8.5.1 the Icons have changed.....

Unifying files and no files.
Is there an idiom that folds the no-files case into the files-exist case so they can be handled with a single mechanism? $ bash --version GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc. $ ls $ chmod a-x * chmod: cannot access `*': No such file or directory $ I could do this $ chmod a-x * 2>/dev/null $ but that just hides the error; there are still two cases (the exit status tells the tale). I could do this $ chmod a-x * 2>/dev/null ; : $ but that's more hiding. This works $ files=$(...

Random file in a file
I am trying to take a random file from a folder what can I do to get random to find a file but not numbers? On Tue, 20 Oct 2015 19:24:03 +0000, Baldvin Vigfússon wrote: > I am trying to take a random file from a folder what can I do to get > random to find a file but not numbers? You could get a list of files in the folder, generate a random integer between 1 and the number of files, then use that RN to index the file list. Bruce ...

What is self.file = file for?
Hello! I have trouble understanding something in this code snippet: class TextReader: """Print and number lines in a text file.""" def __init__(self, file): self.file = file . . . When would you do a thing like self.file = file ? I really don't find an answer on this. Please help me understand this. wxPythoner@gmail.com wrote: > Hello! > > I have trouble understanding something in this code snippet: > > class TextReader: > """Print and number lines in a text file.""&q...

Web resources about - file extention from file file location - comp.authoring.cgi

Liberia: Revisit School Reopening - Weah Wants Extention Return
Liberia's national legislature has issued a three-page report calling for the postponement of the date of reopening of schools. The legislature ...

Apple: Street Cheers MacBook Pro, iOS Extentions
Shares of Apple (AAPL) are up $4.61, or 0.8%, at $575.78, following the company’s Worldwide Developer Conference in San Francisco yesterday, ...


CNET explores tech that is an extention of you
CNET's Lindsey Turrentine and Brian Cooley talk to folks from Fitbit, Nest and Leap Motion about how humans interact with this next generation ...

Grexit Looms; Tsipras Rules Out Extention Of Troika Bailout For Greece
As a number of us have been muttering for some time now it becomes ever more likely that Greece will end up leaving the euro. Not because anyone ...

Danger Of Long Lashes: Study Shows Extentions Can Harm Your Health
Many women covet long lashes , as they are often associated with being ultra sexy and feminine. The desire for full lashes makes mascara a staple ...


Southampton midfielder Lloyd Isgrove signs contract extention
Barclays Premier League Football news, fixtures, results and more from TEAMtalk.com.

Amazon Brings a Really Simple Send to Kindle Extention to Firefox
You really meant to do all that longform reading, but you just didn’t have an easy way to send it to your Amazon eReader and you don’t like reading ...

Hornets sign coach Clifford to contract extention
Charlotte Hornets coach Steve Clifford, who guided the best November run in the NBA club's history, was rewarded Wednesday with a contract extension. ...

Resources last updated: 1/28/2016 6:22:29 AM