[7398] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1023 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 14 13:17:10 1997

Date: Sun, 14 Sep 97 10:00:38 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 14 Sep 1997     Volume: 8 Number: 1023

Today's topics:
     Re: A module to my cgi-bin dir <rjo100@york.ac.uk>
     Re: A simpler perl question. <petri.backstrom@icl.fi>
     Re: C++Builder means Future. (Tim Smith)
     Re: Call remote perl script in another script <webmaster@imaginative-creations.com>
     Re: Filtering CR & CRLF from text input <rjo100@york.ac.uk>
     Re: Free Perl CGI Script <rootbeer@teleport.com>
     Help me with this pls <cc.wee@student.qut.edu.au>
     Re: Help me with this pls (Tad McClellan)
     Re: Help with perl script <rjo100@york.ac.uk>
     Re: How can I tell which modules are installed ? <jerryp.usenet@SPAMconnected.demon.co.uk>
     Re: How can I tell which modules are installed ? <rootbeer@teleport.com>
     Re: Incredibly basic Newbie question <ginakra@one.net>
     Installing a new version of perl (Bill Ferrett)
     Re: Is there a simpler syntax for: defined $a && $a ne  <rjo100@york.ac.uk>
     Re: Is there a simpler syntax for: defined $a && $a ne  <flavell@mail.cern.ch>
     Re: Method call bug (Eric Bohlman)
     Multiple choices in scroll down box in form <ginakra@one.net>
     Re: Multiple choices in scroll down box in form <rootbeer@teleport.com>
     Re: Newbie Needs help! <webmaster@imaginative-creations.com>
     Re: Patternmatching with arrays <rjo100@york.ac.uk>
     Re: Perl conference <srivasta@datasync.com>
     Re: send values from form, read html result, not displa <petri.backstrom@icl.fi>
     Re: sort - help needed (Jens Heunemann)
     Re: tar on NT <rjo100@york.ac.uk>
     Re: unshift function (brian d foy)
     Re: unshift function <ajohnson@gpu.srv.ualberta.ca>
     Re: Using Perl to access pages for Java applet <tou@tou.com>
     Re: Win 95 Perl & Tk <rhempel@log.on.ca>
     Re: win95 install question <webmaster@imaginative-creations.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 13 Sep 1997 18:52:22 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: A module to my cgi-bin dir
Message-Id: <341AD2D6.EC3D7D68@york.ac.uk>

Aitor wrote:
> 
> How may I upload a module (CGI.pm & libwww) to my cgi-bin directory?
> 
> I've got a mac. Upload to a unix server.

FTP them, or use whatever method you use to get your scripts there. 
However the chances are they're already installed on the server anyway so
you won't need to.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Sun, 14 Sep 1997 12:59:42 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: A simpler perl question.
Message-Id: <341BB58E.4F42@icl.fi>

If you use the File::Recurse module, you don't have
to do much anything as a debugged version that works
has already been written.

Just use it. And it most likely already exists on
your system. If not, search http://www.perl.com/CPAN/

Anyway, if you do want to do it yourself, just
write a routine to go through each file in
a starting directory, and when you encounter
a file which tests as a directory, then call
your routine recursively, and so on.

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland

Aaron wrote:
> 
> I have been reading this with interest
> 
> and learned a bit as well
> 
> but my question
> 
> along these same lines
> 
> is
> 
> how do you get it to spit out the file names recursively
> 
> What I have (using the knowledge gained here) is a listing of the files in
> that directory but I also want a listing of allt he files below the
> directories, etc.
> 
> Ritchard Shadian <rshadian@hawaii.edu> wrote in article
> <Pine.GSO.3.95q.970909161209.15260A-100000@uhunix1>...
> > Another really easy UNIX way is:
> >
> > chop(@files = `ls mydirectory`)
> > foreach $file (@files) {..};
> > --
> > Ritchard
> >
> > On 6 Sep 1997, OrdwayNet Webmaster wrote:
> >
> > > I have a directory full of files.  Lets say that I want to add
> something to
> > > each one of those files.  How would I do it?
> > >
> > > I think it would be something like this, but it isn't enough-
> > >
> > > foreach $file
> > >
> > > print "bla bla"\n";
> > >
> > > How do I make $file mean every file in the dir.


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

Date: 14 Sep 1997 00:38:24 -0700
From: tzs@halcyon.com (Tim Smith)
Subject: Re: C++Builder means Future.
Message-Id: <5vg49g$mtm$1@halcyon.com>

Christopher Browne <cbbrowne@hex.net> wrote:
>UNIX is also a philosophy and a set of standards.

Unix *was* a philosopy.  That died a long time ago.  What passes for Unix
nowadays is only Unix in the physical sense--it degenerated from Unix code, or
is a clone of things that degenerated from Unix code, but it is not Unix in
spirit.

--Tim Smith


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

Date: Sun, 14 Sep 1997 02:14:53 -0400
From: "Mr. Ozette Brown" <webmaster@imaginative-creations.com>
Subject: Re: Call remote perl script in another script
Message-Id: <341B80DC.FD35B07B@imaginative-creations.com>

Yes,

I would suggest you use the 'do' operator in Perl.  Example:  do
(filename) evaluates the Perl code in filename.

#!/usr/bin/perl

do 'doable.pl';
print $path;

Hope it helps.

Wei Tang wrote:

> Hi, there:
>
> I have two Perl scripts which are on two servers (I have to place
> them on two servers), say site1-perl and site2-perl. I want to run
> site1-perl as a cron job and call site2-perl in site1-perl, let
> site2-perl query a database and then return the results to site1-perl.
>
> Both scripts can be accessed using URL naming convention.
>
> Is that possible? Which is the easiest way? I don't want to implement
> the httpd protocol by myself.
>
> Please help me out. Thanks.
>
> CC: wtang@cs.ualberta.ca





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

Date: Sun, 14 Sep 1997 14:58:34 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Filtering CR & CRLF from text input
Message-Id: <341BED8A.A0A7A404@york.ac.uk>

Matthew Burnham wrote:
> 
> bart.mediamind@tornado.be (Bart Lateur) wrote:
> 
> [...] someone's told me that if the user adds their
> own newlines in <TEXTAREAS> these are sent as non-urlencoded !
> characters.
> 
> Can anyone confirm this?

Bzzzt! Wrong! CRs and CRLFs _are_ sent URL-encoded from a <TEXTAREA>.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Sun, 14 Sep 1997 09:12:23 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: michael.nilsson@maze.se
Subject: Re: Free Perl CGI Script
Message-Id: <Pine.GSO.3.96.970914090639.17242N-100000@julie.teleport.com>

On Sat, 13 Sep 1997 michael.nilsson@maze.se wrote:

> I am aware of the potentially problem if some one that uses a proxy does
> a failed log ins and block out the proxy address.

So it's okay with you that any AOL user can block out all of the others?
:-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 14 Sep 1997 04:46:10 GMT
From: "Charles Wee Chun Chiang" <cc.wee@student.qut.edu.au>
Subject: Help me with this pls
Message-Id: <01bcc0c9$eabc4de0$082ab583@pacific.net.sg.pacific.net.sg>

Hi all,
	I am writing a email form which will detect missing blank email address
and also blank question and answers in their respective fields. For example
if any of these fields are not filled in then there will be an error
message asking users to try again. I use the following code to do this:

	$destadd=$in{'to'};
	$fromadd=$in{'from'};
	$Subject=$in{'Subject'};
	$Answer=$in{'Answer'};

	unless($destadd && $fromadd && $Subject &&Answer) 
	{
	  Error messages asking users to retry again
	}
	  print "Your email has been sent";
	}

	This code that i wrote is able to test for empty destadd, fromadd and
subject fields but cannot detect an empty Answer field. I cannot understand
why this is so because they are all similar in the error checking or is it
not? I tried using If statement to do the error checking but i got the same
result. The destadd, fromadd and Subject fields are all textfield while
Answer field is actually a textarea in html form. Can anyone help me with
this?

regards
Charles Wee Chun Chiang



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

Date: Sun, 14 Sep 1997 08:59:39 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help me with this pls
Message-Id: <bkqgv5.pl.ln@localhost>

Charles Wee Chun Chiang (cc.wee@student.qut.edu.au) wrote:
: Hi all,
: 	I am writing a email form which will detect missing blank email address
: and also blank question and answers in their respective fields. For example
: if any of these fields are not filled in then there will be an error
: message asking users to try again. I use the following code to do this:

: 	$destadd=$in{'to'};
: 	$fromadd=$in{'from'};
: 	$Subject=$in{'Subject'};
: 	$Answer=$in{'Answer'};

: 	unless($destadd && $fromadd && $Subject &&Answer) 
                                                ^^^
                                                ^^^  && $Answer

You should ALWAYS use the -w switch.

It would have found this error for you...



You don't need to copy them before testing either:

   unless ($in{to} && $in{from} && $in{Subject} && $in{Answer})



If $Answer = 0 the above will probably not do the Right Thing...


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Sun, 14 Sep 1997 11:30:49 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Help with perl script
Message-Id: <341BBCD9.8252D89B@york.ac.uk>

jmisiris@hotmail.com wrote:
> 
> I also had to copy the cgi.pm file to the location where my cgi script
> was because neither:
> 
> use lib '/perl5/lib/CGI.pm';
> 
> OR
> 
> BEGIN {
>        unshift(@INC,'/perl5/lib/CGI.pm');
>       }
> use CGI;
> 
> worked.

I think @INC should contain paths, not filenames, so try:

BEGIN {
       unshift(@INC,'/perl5/lib');
      }
use CGI;

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Sun, 14 Sep 1997 10:27:17 +0100
From: Jerry Pank <jerryp.usenet@SPAMconnected.demon.co.uk>
Subject: Re: How can I tell which modules are installed ?
Message-Id: <6ISxXDA136G0EwfH@connected.demon.co.uk>

>From the divine hand of  
lvirden@cas.org, fell this pearl:
>
>According to Jerry Pank  <its.spelt.out.in.the.sig@file.OK>:
>:Is there an easy way to find exactly which module are already installed?
>:
>What about going into 
>perl -MCPAN -e shell
>and looking around?
>
Because I can't run Perl from the command line (perl : not found) or am
I missing something very basic here ?

{
re-inserted
My ISP (DEMON) gives me a very limited shell, (only the safest /bin
commands are available) and for security? will not allow perl to be run
from the command line.
}

-- 
This post in every-way totally reflects the views of my employer...

I am he.
Jerry           jerryp dot usenet at connected dot demon dot co dot uk

Warning - Wash out the spam filter.


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

Date: Sun, 14 Sep 1997 09:03:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: How can I tell which modules are installed ?
Message-Id: <Pine.GSO.3.96.970914085745.17242M-100000@julie.teleport.com>

On Sat, 13 Sep 1997, Jerry Pank wrote:

> My ISP gives me a very limited shell, (only the safest /bin commands are
> available) and for security? will not allow perl to be run from the
> command line. 
> 
> This has not caused me problems so far but I can't seem to find which
> perl modules are already installed on the server by snooping about. 
> 
> Is there an easy way to find exactly which module are already installed? 

Yes: Ask the sysadmin. :-)  But if the sysadmin won't let you run Perl,
IMHO you should install a new one. :-)

But it wouldn't be hard to write a program to run on a web server which
would report the names of installed modules. Is that the kind of server
you mean, or is it a news server, FTP server, or domain name server you're
talking about? :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!




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

Date: Sun, 14 Sep 1997 10:09:16 -0400
From: Gina Anderson <ginakra@one.net>
Subject: Re: Incredibly basic Newbie question
Message-Id: <341BF00C.9917D703@one.net>

Fred,
 
> I simply want to see it do something before I move on to more
> difficult tasks.  My problem is that I have no idea how to run the
> damn thing (under Windows95).  I typed it as text with Notepad, then
> changed the filetype to .prl>

I was in the same boat you are just a week or so ago!  I am incredibly a
newbie too, but first of all, I am pretty sure you ned to name the file
hello.pl instead of hello.prl.

> but when I try to run it via the Start/Run function of Windows95, it simply opens it as a text file. Do I have to go to the MS.DOS window? What exact steps do I have to take to run it?

You can't run a perl script from the Start/Run command, you have to use
the MS DOS window.  In order to see perl in action on your computer, you
need to have perl installed on your system.  I installed Perl 5.003 for
Win 95.  I am not sure where I found it, but I can send you the program
with simple install instructions if you want to email me privately.

After you install perl, you would see the program in action by typing at
the MS DOS prompt:

perl (path to the perl program)hello.pl and hitting enter.

For example if I had the hello.pl file in my C:\perl scripts folder it
would be:

<prompt>perl C:\perl\hello.pl

It would then output Hello World! on the screen.

You might be lucky enough to have perl alread on your system, you can
find out by going to a DOS prompt and typing:

perl -v

which if you have perl installed, it will tell you the version number. 
If it gives you a bad command, you need to install it.
> 
> Can it be run on a p.c. or does it need to be uploaded first to a UNIX
> system?

  You can run it off a server I am sure, but I don't know how, I assume
you must upload it to the server before you test it, but that could be
wrong.  I would just install perl instead, less hassle! :)
> 
> If it can be run from a p.c., do I need to compile it first, or is
> that part of the run fuction? Do I need a program/compiler that is not part
> of the general Windows95 system (and if so, which one, and how do I
> install it?)

You don't need to compile perl.  The text, as long as it is named .pl or
 .cgi, I have found will work when I have perl installed on my computer.
 
> (Can someone point me to a tutorial or book which covers such
> elementary basics?)

I am using "Discover Perl 5" by Naba Barkakati published by IDG.  It's
still kind of hard, but it did cover this stuff in it.  Thats how I
learned!

Let me know if you want that file:)

Hope this helps!
Gina

-- 
    _\/_                 |                _\/_
    /o\\             \       /            //o\
     |                 .-'-.                |
    _|_______     --  /     \  --     ______|__
 jgs         `~^~^~^~^~^~^~^~^~^~^~^~`
     Gina Anderson             ginakra@one.net
           http://members.aol.com/ginakra 
                 Need a web page? 
           Contact Me For Affordable Rates!


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

Date: Sun, 14 Sep 1997 12:56:59 GMT
From: bill@billf.demon.co.uk (Bill Ferrett)
Subject: Installing a new version of perl
Message-Id: <341bddef.21991211@news.demon.co.uk>

I currently run perl 5001 but would like to upgrade to be able to use
libwww.

I have downloaded the ActiveWare build 310 which is based on 5003.007.

The question is do I need to uninstall the old version or can I just
extract the new zip file over the old version?

The new zipped/exe doesnt contain an install.bat. Do I need one, can I
use the old one?

If I dont either a) uninstall or b) install then will I have registry
problems?

Thanks for any help,

Bill


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

Date: Sun, 14 Sep 1997 15:04:29 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Is there a simpler syntax for: defined $a && $a ne ''
Message-Id: <341BEEED.950CAC7@york.ac.uk>

Brett Denner wrote:
> 
> I frequently need to ensure that a scalar contains "something"; i.e.,
> that it is defined and that it contains some non-empty value.  I usually
> try something like this:
> 
>     $a = 1 unless (defined $a and $a ne '');
> 
> Is there a simpler, more concise syntax for the "unless" part of this
> expression?  I've tried things like:
> 
>     $a = 1 unless length $a;
> 
> and
> 
>     $a = 1 unless $a =~ /./;
> 
> but these don't work unless $a is already defined.  Also, I can't just
> test for true or false, because '0' is false, but would be acceptable
> under my criterion.

The Llama book, 1st Ed, p12 (footnote), says undef 'looks like an empty
string to the eq operator'. Therefore you could use...

$a = 1 if $a eq '';

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------



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

Date: Sun, 14 Sep 1997 16:42:27 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Is there a simpler syntax for: defined $a && $a ne ''
Message-Id: <Pine.A41.3.95a.970914183037.99094A-100000@sp065>

iOn Sun, 14 Sep 1997, Russell Odom wrote:

> Brett Denner wrote:
 ..wants a neater way to achieve..
> >     $a = 1 unless (defined $a and $a ne '');

> The Llama book, 1st Ed, p12 (footnote), says undef 'looks like an empty
> string to the eq operator'. Therefore you could use...
> 
> $a = 1 if $a eq '';

Yes, but I _think_ the questioner is trying to avoid provoking a "use of
uninitialized value" warning at that point.  I'm afraid your suggestion
causes that warning too. 

Under the warning message itself, the only suggestion seems to be to
initialize all variables before use.  This doesn't always address the
problem, does it, since if $a gets set to the result of some expression,
it could, depending on circumstances, result in $a becoming undefined,
even though it had been initialized before?

No, sorry, I don't know a better answer.  Good job there are some
experts around here, maybe they can help, or tell us definitively there
isn't a better answer...





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

Date: Sun, 14 Sep 1997 13:00:15 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Method call bug
Message-Id: <ebohlmanEGI1GF.Bq3@netcom.com>

Krisztian Flautner (manowar@sauropod.engin.umich.edu) wrote:

: Below is a small program I tried:

:     package test;
:     sub new {

:         my $class = shift;
:         my $self = {};

:         bless $self, $class;

:         return $self;

i.e. return a reference to a hash.

:     }

No problems here.

:     package test;
:     sub print {

:         my $self = shift;

:         print "hehehe\n";

:     }

No problems here either.

:     package main;

:     $a = new test;

$a is a reference to a (empty) hash.

:     print $a, "\n";

Printing a reference to a hash doesn't dereference it; it "stringifies" 
it, giving you your "HASH(<hex number>)". 

:     $a->print();

Fine.

:     %ttt = ();
:     $ttt{$a} = 1;

You can't use a reference as a key to a hash.  The actual key is going to
be the stringified version, which can't subsequently be used as a
reference.  You can, however, use a reference as a *value* in a hash.

:     foreach $key (keys %ttt) {
:         print $key, "\n";
:         $key->print();

Equivalent to "HASH(0x227c50)->print();" which is gibberish.


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

Date: Sun, 14 Sep 1997 10:13:34 -0400
From: Gina Anderson <ginakra@one.net>
Subject: Multiple choices in scroll down box in form
Message-Id: <341BF10E.B940D412@one.net>

Hi guys!

I had been looking for the answer to a problem with posting results from
a form that has a scroll down box where the user can choose several
items.  The form results are being posted to another html file and
displayed.  Of course, for some reson this newbie doesnt understand,
only one choice, even though multiple items are chosen, is displayed.

I found the answer yesterday by someone who had posted the same
question, and I should've printed out the message, but I went on reading
posts.  I lost the message, can't find it.  Would someone be kind enough
to either repeat the answer, or point me somewhere where I can find the
info on the answer:)

Thanks
Gina
-- 
    _\/_                 |                _\/_
    /o\\             \       /            //o\
     |                 .-'-.                |
    _|_______     --  /     \  --     ______|__
 jgs         `~^~^~^~^~^~^~^~^~^~^~^~`
     Gina Anderson             ginakra@one.net
           http://members.aol.com/ginakra 
                 Need a web page? 
           Contact Me For Affordable Rates!


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

Date: Sun, 14 Sep 1997 09:13:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gina Anderson <ginakra@one.net>
Subject: Re: Multiple choices in scroll down box in form
Message-Id: <Pine.GSO.3.96.970914091259.17242O-100000@julie.teleport.com>

On Sun, 14 Sep 1997, Gina Anderson wrote:

> I had been looking for the answer to a problem with posting results from
> a form that has a scroll down box where the user can choose several
> items. 

Use CGI.pm, and a list context. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Sun, 14 Sep 1997 02:18:54 -0400
From: "Mr. Ozette Brown" <webmaster@imaginative-creations.com>
Subject: Re: Newbie Needs help!
Message-Id: <341B81CD.71215209@imaginative-creations.com>

Yes,

Try to use the SYSTEM function.

Example:  system 'cd..' and/or print system "dir".

Consult a good Perl book/manual.

Hope this helps.  Good luck.

Larry G. Dunn wrote:

> I am a "newbie" when it comes to PERL progamming. What I need
> to be able to do is to change into a directory without knowing
> ahead of time what the name of the directory is going to be.
>
> In other words, I want to be able to do something like:
>
>         cd newdirectory*
>
> The directory is a composition of the date and time of day that
> the directory is created. Anyone with code "frags" or if someone
> might suggest a way this can best be done please mail me at:
>
>         dunn.l.g@wcsmail.com
>
> Thanks in advance,
>
> Larry Dunn
> Westinghouse Communications
> (412) 244-6559





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

Date: Sun, 14 Sep 1997 12:36:40 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Patternmatching with arrays
Message-Id: <341BCC48.C2053AEF@york.ac.uk>

Robert wrote:
> 
> This is a the piece of the code that's the problem
> 
> open (OLD, "$REAL") || die ("couldnt open file for reading");
> @search_array = <OLD>;
> while (<OLD>) {
>     if ($search_array =~ "/<!-- $TIME $ROOM --!>/\n") {
>         #[stuff snipped]
>         close (OLD);
>     }
> }

You'll need to escape the special characters (< and >) in that regexp with
\.

What're the double quotes round the regexp for? It's delimited with //.

Why's the \n _outside_ the regexp? 
(Is it actually needed at all? You could chomp() the incoming line.) 

Is there any need to read the contents of the file into an array?
If you do '@search_array = <OLD>;' you can't then do 'while (<OLD>)'
without reopening the file.

Why are your variable names in uppercase?

Are you sure you want to close the file within the 'if' statement? If the
line is not in the file, it won't be closed.

You don't need ""s round the variable in open ();

How about...

--------------------------------
open (OLD, $real) or die ("Aaaaaaargh!");
while (<OLD>) {
    chomp;                            # Removes \n from $_
    if (/\<!-- $time $room --!\>/) {  # Regexp checks $_
        # Print HTML here
        last;   # Exits while loop once line is found, since there's no
                # point printing the HTML again if there's more than one 
                # matching line.
    }
}
close (OLD);
##### Only add the following lines if there's some need to read the file
##### into @search_array
#open (OLD, $real) or die ("Aaaaaaargh!");
#@search_array = <OLD>;
#close (OLD);
#chomp (@search_array);  # removes \n from all elements of @search_array
#####
--------------------------------

HTH,

Russ

PS I'm new to perl myself, so expect some of the above to be picked apart
by someone. However, it does work.

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: 13 Sep 1997 23:59:26 -0500
From: Manoj Srivastava <srivasta@datasync.com>
Subject: Re: Perl conference
Message-Id: <87afhgze1e.fsf@tiamat.datasync.com>

Hi,
>>"Hal" == Hal Wigoda <hwigoda@Mcs.Net> writes:

Hal> Pictures of larry wall, randall schwartz, tom chritiansen, and
Hal> others is at www.wigoda.com/perl.html

	Well now. Seems like a step up from the usual pictures one
 gets offered on USENET ;-).

	manoj

obPerl: Are there any restrictions on the values of hashes tie'd into
DB_File databases? For example,  if I have a hash

%User_info = 
  ( "John Doe" => {
      'Address' => "22 Main st,\n No Town, USA",
      'Email'   => "L.User@no.such.domain"
      },
    "Jane Doe=> {
      'Address' => "2234 Oak st,\n Yes Town, USA",
      'Email'   => "J.Doh@no.such.domain"
      });

	Can I still tie this into a DB_File?
-- 
Manoj Srivastava               <url:mailto:srivasta@acm.org>
Mobile, Alabama USA            <url:http://www.datasync.com/%7Esrivasta/>


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

Date: Sun, 14 Sep 1997 13:14:50 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: send values from form, read html result, not display it?
Message-Id: <341BB91A.1F3@icl.fi>

Mark Worsdall wrote:
> 
> Please forgive me for this one....
> 
> There is a certain service that allows one to pass it two values from a
> form, it then generates a html page with the answer.
> 
> Using perl I want to call the script on the server, but instead of the
> html page being displayed, I want to read it into memory, search for the
> parts I want, and build my own page including the values returned from
> the original page, then display them as an html page.
> 
> I know you are going to say it is rude not to ask etc. but hey, is it
> possible?

Of course it is possible. Everything is possible
with software; it is all just 1's and 0's after
all, and the only issue is in which order to
string them together, and how long a string to
make ;-)

Anyway, this string has been pieced together for
you already: Look up libwww (LWP) on the Comprehensive
Perl Archive Network http://www.perl.com/CPAN/

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Sun, 14 Sep 1997 11:04:39 GMT
From: jens.heunemann@stud.uni-muenchen.de (Jens Heunemann)
Subject: Re: sort - help needed
Message-Id: <341bc128.1275800@news.lrz-muenchen.de>

On Mon, 25 Aug 1997 15:03:51 +0200, denis@mathi.uni-heidelberg.de
wrote:

>hi,
>
>i have an array (@xx) with fields such as these:
>
>$xx[]="text1 text2 number text3";
>
>and i want so sort it by the numbers. so i tries something like 
>this:
>
>sub numb
>{
>	@tmp=split(/\s+/);
>	$tmp[2]{$a} <=> $tmp[2]{$b};
>}
>
>@xx2=sort numb @xx
>
>but this doesnot work... maybe i search in the wrong variable...
>or is $tmp[2]{$a} wrong?
>
>thanks for any help
>
>	denis

I don't know if this is the best solution (most probably not :-),
but it works:

@xx2=sort {	($a =~ m/^\S+\s+\S+\s+(\d+)/)[0] <=>
	 		($b =~ m/^\S+\s+\S+\s+(\d+)/)[0] }  @xx;

Probably this also works:
@xx2=sort {	($a =~ m/^\S+\s+\S+\s+(\d+)/)[0] <=>
	 		($b =~ m//)[0] }  @xx;
( Should work according to my perl book)

Explanation:
In the List-context provided by the (...)[0] the matching operator m//
returns a list of all the ()-enclosed substrings, here the number in
the third field { (\d+) }
If the numbers are real numbers, you probably have to replace the \d+
with \S+.

Hope this helps,

Jens


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

Date: Sun, 14 Sep 1997 13:16:01 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: tar on NT
Message-Id: <341BD581.FDAA532B@york.ac.uk>

Nigel Reed wrote:
> 
> Larry Nguyen (Larry_P_Nguyen@qmail2.sp.trw.com) wrote:
> > is there a Win NT or DOS version of tar executable some where that I can
> > download? I'm trying to unpack and install the latest.tar.gz and I got
> > the gzip.tar file which I need a tar executable to un-tar it.
> 
> Look for tar.exe and gzip.exe. You might find it on
> http://oak.oakland.edu
> http://www.simtelnet.net
> http://www.cdrom.com
> http://www.windows95.com

Even better, get Winzip, from http://www.winzip.com/. It handles both of
these formats as well as others, all in one go, and has a nice friendly 
user interface.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Sun, 14 Sep 1997 01:49:29 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: unshift function
Message-Id: <comdog-ya02408000R1409970149290001@news.panix.com>

In article <5vfe4o$bh0$1@prometheus.acsu.buffalo.edu>, boonteh@acsu.buffalo.edu (Rick B Teh) wrote:

>Can someone please show me an example of using the unshift function?
>I have just lost my camel book. ANy help will be appreciated.


just an example?  btw, there is always the perlfunc man page 
( or perldoc -f unshift )...

#!/usr/bin/perl

my @array = qw( 2 3 5 8 13 );

$" = ' ';

print "before: @array\n";

unshift @array, 1;

print "after:  @array\n";

__END__

before: 2 3 5 8 13
after:  1 2 3 5 8 13

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sun, 14 Sep 1997 00:51:30 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: unshift function
Message-Id: <341B7B62.68BF7230@gpu.srv.ualberta.ca>

Rick B Teh wrote:
> 
> Can someone please show me an example of using the unshift function?
> I have just lost my camel book. ANy help will be appreciated.
> Thanks.

@array=qw(two three four);
print "@array\n";
unshift @array, "one";
print "@array\n";

regards
andrew


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

Date: Sat, 13 Sep 1997 19:57:36 -0700
From: Joel Shellman <tou@tou.com>
Subject: Re: Using Perl to access pages for Java applet
Message-Id: <341B52A0.1FF03750@tou.com>

Paul Holden wrote:
> 
> Hi,
> 
> I've been trying to find out how to write a Perl script that will read some
> web page hosted on another server, and redirect its contents to a Java
> applet. As applets are allowed to read files from the server on which they
> originated, the applet can easily open the script and tell it what page it
> wants, for example by reading :
> 
> http://www.myserver.com/cgi-bin/grabpage?http://www.anotherserver.com/page.h
> tml
> 
> the grabpage script will be run, and the applet will read in the data that
> the script outputs. That bit's fine.
> 
> The problem is, I've only been programming in Perl for a months or so, and
> for the life of me I can't think how to get the script to open a page on
> some other server. Can anyone help? Replies via email would be much
> appreciated.
> 
> Thanks in advance,
> Paul Holden
> paulh@irsoft.demon.co.uk

I have this same need--please respond to me also.

Thank you,

Joel
-- 
TaoTree Research and Development
Web Development/Design, Virtual Servers, hosting, Perl/CGI programming
http://www.tou.com/rd/

Revolutionary new clicks-based Banner Exchange Guarantees you traffic
http://www.tou.com/ite/


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

Date: 14 Sep 1997 15:30:05 GMT
From: "Ralph Hempel" <rhempel@log.on.ca>
Subject: Re: Win 95 Perl & Tk
Message-Id: <01bcc123$680f98c0$29e7a4cf@pro-150>

I got the latest PERL/TK up and running on my WIN95
box too, and once again, congrats to the porters that
makes this kind of thing possible!

One question. I looked at using TCL in the first place
because it can talk to WIN95 serial ports. This is
confirmed by running the TCL interpreter. But dammit,
I STILL can't get anything to come out the serial port
under PERL.

I have looked thru DEJA NEWS, I have tried all the
system call variants, used the flush lib, everything.

I have written serial IO code using Visual C++, but admit
that I don't want to know too much about hooking PERL
to a C Library. That's why I use PERL scripts in the first
place, to do things quickly. :-)

Just my 2 pennies worth, and I'll keep looking for the
elusive serial solution. And if I find it, I'll post it!

Cheers, Ralph




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

Date: Sun, 14 Sep 1997 02:23:04 -0400
From: "Mr. Ozette Brown" <webmaster@imaginative-creations.com>
To: Holly Sample <holiday@allmed.net>
Subject: Re: win95 install question
Message-Id: <341B82C8.E00166DB@imaginative-creations.com>

Hello,

I would suggest putting the following line at the top of your Perl script:

print "Content-type: text/html\n\n"; # for html
print "Content-type: text/plain\n\n"; # for text

This should work.  I would also suggest that you search for a good Perl
manual on the web.

Good Luck!

Holly Sample wrote:

> I'm have used perl before, but always remotely, and I am now attempting
> to install it on a (local) win95 machine in order to test scripts before
> uploading to the win NT 4.0 server.
>
> I've downloaded perl version 5.003_07 for win32 build 307,  it's
> apparently installed fine, however when I run any scripts, all my output
> goes to a dos window.  So how do I somehow redirect the output to appear
> in my browser?
>
> Thanks for any help someone can offer,
> Nathan Stitt
> nate@wavecomputers.net





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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1023
**************************************

home help back first fref pref prev next nref lref last post