CGI.pm name-and-file-handle magic? variable 
Author Message
 CGI.pm name-and-file-handle magic? variable


Quote:

>How is that possible? How can a variable hold both a filehandle (which I
>take means either \*FOO or a FileHandle/IO::Handle) and a plain scalar?
>Shirley the package isn't using symbolic references?

File handles can be strings.  See "perldoc -f open".  It is not quite the
same thing as a symbolic reference.
        $_ = <FOO>;
        $handle = "FOO"; $_ = <$handle>;

Quote:
>ObHandsOn: I would try rather than ask, but my web provider won't let me
>install my own CGI apps, and wants money to install ones that upload
>files.

It's trivial to install perl on your own PC.  You don't need to have a
full-blown web server with CGI just to test file handles.

        -Joe
--
See http://www.*-*-*.com/ ;ReBoot" pages.



Thu, 30 Jan 2003 03:00:00 GMT  
 CGI.pm name-and-file-handle magic? variable

Quote:

> > You don't need to have a full-blown web server with CGI just to test
> > file handles.

> No, but to explore what kind of tricks CGI.pm performs with them and
> file upload, it helps. :-)

If you're running a Windoze box at home, then Active Perl and Win32
Apache take only half an hour or so to install, and form a pretty good
simulation of what you'd get at a web hosting site, modulo the
differences between w32 and unix.

There are more lightweight web servers that would suffice but would
be less similar to what Apache gives you.

Of course if you're a linux fan it's even closer. (Beware of
nonstandard Apache RPMs and linuxconf, though).

Quote:
> Of course, that's moot if it does nothing out of the ordinary. Which may
> or may not be the case. My perl reading skills aren't (yet?) up to
> figuring it out.

That's why having a working system at your fingertips beats
poking around in the entrails of a distant SP's system.

good luck



Thu, 30 Jan 2003 03:00:00 GMT  
 CGI.pm name-and-file-handle magic? variable
The string-as-filehandle thing does not work with 'use strict'.  For
example, #1 works, but #1 does not:

#1) No strict:
my $filename="test";
open ($filename, $filename) || die $!;
print <$filename>;

#2) strict:
use strict;
my $filename="test";
open ($filename, $filename) || die $!;
print <$filename>;

perl version 5.005_03 built for i386-linux

Quote:




> > >How is that possible? How can a variable hold both a filehandle (which I
> > >take means either \*FOO or a FileHandle/IO::Handle) and a plain scalar?
> > >Shirley the package isn't using symbolic references?

> > File handles can be strings.  See "perldoc -f open".  It is not quite the
> > same thing as a symbolic reference.
> >       $_ = <FOO>;
> >       $handle = "FOO"; $_ = <$handle>;

> Hmm, perl seems to disagree with you about the symbolic reference bit.

> % perl -we 'use strict; my $foo = "STDIN"; print scalar <$foo>;'
> Can't use string ("STDIN") as a symbol ref while "strict refs" in use at
> -e line 1.

--
---------------------------------------------------------------------

"If you're not part of the solution, you're part of the precipitate"
---------------------------------------------------------------------



Thu, 30 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. TDateTimeField / TDateField Issue

2. Opening a File Handle on a File with a Variable Name

3. CGI.pm and variable named form elements

4. CGI.pm and variable named form elements

5. SQL Sequence Counter in Local InterBase?

6. Handling type=file without CGI.pm??

7. Make File Handle into a reference as returned from CGI.pm

8. Problem with File Handles using CGI.pm

9. Query Variables aka file.cgi?name=value&...

10. CloseFile in Delphi DLL not Closing File till Dll Unloads when called from VB

11. Borland C++ API

12. HTML Parser 2.23 TokenParser without a file handle or file name

 

 
Powered by phpBB® Forum Software