wallyweezle has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone, I've been searching everywhere on the internet for a decent tutorial on Perlscript, and could not find one, so I figured I would turn to the brethren at Perl Monks. Actually what I'm looking for is how to open/read files in Perlscript from within an ASP page. I am new to Perl, and thus even newer to Perlscript. Thanks, Eric

Replies are listed 'Best First'.
Re: File opening in ASP/Perlscript
by Aristotle (Chancellor) on Jul 27, 2003 at 19:15 UTC
    Just like you do anywhere else you use Perl. See perldoc perlopentut.

    Makeshifts last the longest.

      Hey, thanks guys for the feedback. I figured there was a way to invoke the standard perl functions. I'll also take a look at those tut's. Regards, Eric
Re: File opening in ASP/Perlscript
by jryan (Vicar) on Jul 27, 2003 at 22:11 UTC

    A better link might be: perlopentut.

    Also, for a general Perl tutorial, you might want to try Robert's Perl Tutorial. Its a bit dated, and often doesn't use the best style, but its a pretty good tutorial for beginners considering that its free. If you want to spend a few bucks, you might want to try a book like Learning Perl by merlyn.

Re: File opening in ASP/Perlscript
by chunlou (Curate) on Jul 27, 2003 at 22:36 UTC

    Try this:

    <SCRIPT language="PerlScript"> use Win32::Script qw/WScript/; $Shell = WScript('Shell'); $Exec = $Shell->Exec('cat a.txt'); $window->document->write($Exec->StdOut->ReadAll); </SCRIPT>

    It prints the content of a.txt file.

    With ASP/Perscript, you mostly only need to know how to use Win32::OLE, Win32::Script or other related Win32 wrapper modules. Otherwise, Microsoft COMs (related to ASP or your work) are what you should learn.

      So how is that any better than the following?
      <SCRIPT language="PerlScript"> use Win32::Script qw/WScript/; my $content = do { local $/; my $fh; open $fh, '<', 'a.txt' ? <$fh> : "Couldn't open a.txt: $!;" }; $window->document->write($content); </SCRIPT>
      In fact I dare say it's worse - you were spawning an external process to read the file. There's sometimes something to be said for the brevity of qx{cat a.txt}, but you even gave up on that.

      Makeshifts last the longest.

        Whatever works is fine by me. I don't have any preference.