[7272] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 897 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 20 21:17:24 1997

Date: Wed, 20 Aug 97 18:00:26 -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           Wed, 20 Aug 1997     Volume: 8 Number: 897

Today's topics:
     Re: *Really* dynamic function loading? (Dan Zerkle)
     Re: *Really* dynamic function loading? <zenin@best.com>
     Assign directory WRITE permission only - How? (Eric)
     Re: Beginner problems (Matthew S. Staben)
     Re: Buy any Perl book in print (Terje Bless)
     Re: Carriage Return Problem (frank)
     Re: Carriage Return Problem (Mike Stok)
     Re: CGI: Forms RADIO BUTTONS <polone@sanasys.com>
     Re: create a file in a user directory with a perl scrip <polone@sanasys.com>
     Re: create a file in a user directory with a perl scrip <srichard@san-jose.ate.slb.com>
     FAQ Database <jasonmc@mail.utexas.edu>
     Hash + Regex (Paul Hankes Drielsma)
     Re: Hash + Regex (Mike Stok)
     Re: Hash + Regex (Jot Powers)
     Help me !!! :) <falbanese@usa.net>
     Re: Help on 'system' function <yoder5@gate.net>
     Re: HELP!!!!Please..... (Mike Stok)
     Re: HELP!!!!Please..... xewj@odin.sunquest.com
     Re: How can I make this CGI script work <yoder5@gate.net>
     Re: How do I find the system date/time? <bherder@orrqms2.psf.lmco.com>
     Re: How do I find the system date/time? <yoder5@gate.net>
     include tags <temp.ed.vanderbush@bentley.com>
     Re: incredibly simple question (Gary Chambers)
     Re: Novice scratches head <polone@sanasys.com>
     Passing 1 programs O/P to anothers I/P via file handles <jaydee@worsdall.demon.co.uk>
     Re: Reading a string, splitting it, and using it <dboorstein@ixl.com>
     SATAN on a linux (Jim Meritt)
     Special Char in "BJRN" treated as EOF by NT Perl 5? <peter_xihong_wang@ccm.jf.intel.com>
     undeclared variables ??? <xkn14@dial.pipex.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 20 Aug 1997 22:34:22 GMT
From: zerkle@krakatoa.cs.ucdavis.edu (Dan Zerkle)
Subject: Re: *Really* dynamic function loading?
Message-Id: <5tfrde$c1e$1@mark.ucdavis.edu>

M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
: >Hmmm.  The Perl FAQ seems to be inaccessible.  I guess I'll have
: >to post.

: I don't believe that.   Apart from the copy at perl.com,

Perl.com doesn't seem to have anything to do with Perl, although
it does have a link to a "real" Perl site, presumably this
CPAN thing.  Unfortunately, that link was dead.  It leads to
some sort of "songline.com" thing.

: there's a copy
: in the documentation which comes with every modern version of perl,

Couldn't find it at my installation.  Probably here somewhere,
though.  Of course, I would hardly be surprised if someone nuked
it to save disk space.

: there are copies (in five different formats) on every CPAN site around
: the world,

 ...which I couldn't find, given that perl.com was so singularly
unhelpful.  I tried.

: or (since it has been posted here) you could always find it
: via DejaNews.

I found the micro-FAQ and presumed that anything more useful
would be on the Web.

: You mean _none_ of these resources were available?

Bingo.  Someone ought to do something about this.  I suppose
I could have done a Web search, though.
--
Dan Zerkle  zerkle@cs.ucdavis.edu
GCS d(---)(!) p- c++ !l u++ e++(+++) m s++/-- !n h+(--) f g+++(-) w+ t+ r(-) y+
Stamp out Internet spam!  See http://www.vix.com/spam/ to help.


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

Date: 20 Aug 1997 23:06:48 GMT
From: Zenin <zenin@best.com>
Subject: Re: *Really* dynamic function loading?
Message-Id: <5tfta8$slt$2@nntp2.ba.best.com>

[posted & mailed]
Dan Zerkle <zerkle@krakatoa.cs.ucdavis.edu> wrote:
> : You mean _none_ of these resources were available?
> Bingo.  Someone ought to do something about this.  I suppose
> I could have done a Web search, though.
	>snip<

	http://www.perl.com/perl/CPAN/CPAN.html

	Although I knew this off hand, I still did a search to see how easy
	it was to find using only local man pages:
	man perl
		Always start here if you don't know were to look.
		On the first page I find, "perlfaq     Perl frequently asked
		questions". So...
	man perlfaq
		On the first page I find, "the perlfaq2 manpage: Obtaining
		and Learning about Perl   Where to find source and
		documentation to Perl, support and training, and related
		matters."  So...
	man perlfaq2
		A text search for "CPAN" brings be right to it, save for
		paging down once or twice.

	Total search time, less then 30 seconds, before I even touched the
	internet. Yes, the given URL will redirect you to another site.  That's
	because it's probably the best local mirror of CPAN for you based on the
	information has about you (hostname, subnet, etc).  That's it's job. 

	A search for "CPAN" on Yahoo took an entire 5 seconds to locate.

	How long did it take to write your reply BTW?

-- 
-Zenin
 zenin@best.com


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

Date: Wed, 20 Aug 1997 21:44:50 GMT
From: eric@intiman.org_nospam (Eric)
Subject: Assign directory WRITE permission only - How?
Message-Id: <33fb6481.1728346@intXnt>

Is there a way in Perl to assign permissions for files and directories?  I'm
using the Perl5 Win32 version.  It will be running on a NT 3.51 server to
set mail directory permissions.  I need to assign only write permissions for
the everyone group.

Ideas?   Thanks!

eric@intiman.org_nospam
Eric Kylstra
Computer Coordinator
Intiman Theatre

I have the nospam on the end of my email address for the obvious reason.
Remove it to email me directly.


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

Date: Wed, 20 Aug 1997 21:38:16 GMT
From: mstaben@poboxes.com (Matthew S. Staben)
Subject: Re: Beginner problems
Message-Id: <33fb6393.23644182@nntp.iea.com>

On 20 Aug 1997 08:25:10 GMT, mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:

>In article <33FAA4CC.9487ED07@west.net>, John Callender  <jbc@west.net> wrote:
>>2. The DOS/Windows perl implementation doesn't understand the
>>
>>#!/usr/local/bin/perl -w
>>
>>line. That's a Unix convention. It doesn't hurt, since it's commented by
>>the initial # character, but it doesn't help, either.
>
>Not quite true  -  Perl still processes the line and acts on the -w flag.
>So the line is worth including.

So, now I've got to be careful what I comment on ...

email any responses, as I don't frequent this newsgroup



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

Date: Wed, 20 Aug 1997 22:36:52 +0200
From: link@tss.no (Terje Bless)
Subject: Re: Buy any Perl book in print
Message-Id: <link-2008972236520001@news.uit.no>

In article <33ED1FF4.1DC1@whtbs1.agw.bt.co.uk>,
    Andy Nelson <nelsona@whtbs1.agw.bt.co.uk> wrote:

>In article <link-0908971634390001@news.uit.no>,
>    Terje Bless <link@tss.no> wrote:
>>
>>Gawd, how I would love a book that teaches you to program and does so using
>>Perl as the example language. Algorithms and datastructures demonstrated in
>>Perl rather than Pascal.
>
>Or you could do worse than trying 'Learn Perl 5 in 21 Days'

You probably could, but, from what I've heard, not by much. :-)

I was thinking of something like all the "standard" Computer Science 101
books rewritten to use Perl example code. I know Perl, perl and a little
programming that I've picked up from various sources (mostly c.l.p.m ;D). I
started out with "Locomotive BASIC for GEM Desktop" way back when and moved
on thru4 Pascal, 6502 assembler, csh (don't ask ;D), some minor peeks at C
and ended up with Perl. I've never taken a Computer Science course and I'm
starting to feel the lack in terms of knowing too little about concepts
(like state machines) and well known algorithms (like the "bubble" sort or
the Sieve of Whatever-his-name-was ;D and the Boyer-Moore "skip" array).
I'm probably also quite lacking in proper terminology tho4 you can pick up
a lot of that from USENET.

Perl suits me and I can learn about all I need from the provided
documentation and examples (which must be the best available for *any*
language/environment), but when I try to attack any CS101-type subject I'm
allways defeated by the use of Pascal (which it's been *years* since I've
used) or C (which I never got around to learning (to any significant
extent)).

What prompted the post was the book "Algorithms and Datastructures"
(Addison, Westley (the correct spelling escapes me at the moment ;D)) which
I've given up for the second time now. :-( It's just too dang annoying to
have to dredge up old Pascal skills to understand the given examples. I
expect I'll have to rewrite all the examples to Perl if I'm to ever finish
that book (which might not be a bad idea, but adds a significant amount to
the time required to digest the thing).

So I got to thinking; there's no real reason why a book that aims to teach
you programming and/or computer science couldn't use Perl when it needs to
use example code. Quite the opposite IMO. So wouldn't it be great if such a
beast existed? :-)

Oh well, it was a peachy keen idea anyway. :-)

-- 
Party? Party, lord? Yes, lord. Right away, lord.
        - Beopunk Cyberwulf


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

Date: Wed, 20 Aug 1997 16:08:07 -0500
From: fsoganda@mitre.org (frank)
Subject: Re: Carriage Return Problem
Message-Id: <fsoganda-ya023180002008971608070001@newsflash.mitre.org>

> The users who have posted have hit the carriage return extensively in
> their postings. 

I have come across this problem, and would like to simply replace the CRs
with spaces using tr/xx/ /. 

What is the escape character (xx above) for a CR in a textarea box? I was
unsuccessful with \n.

Looking at the raw text file, each of the CRs looks like a control M. What
escape character do I search/replace to kill these guys??? I hope this
doesn't depend on platform.....

TIA

-- 
frank <<fsoganda@mitre.org>>


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

Date: 20 Aug 1997 20:43:56 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Carriage Return Problem
Message-Id: <5tfkuc$itt@news-central.tiac.net>

In article <fsoganda-ya023180002008971608070001@newsflash.mitre.org>,
frank <fsoganda@mitre.org> wrote:
>> The users who have posted have hit the carriage return extensively in
>> their postings. 
>
>I have come across this problem, and would like to simply replace the CRs
>with spaces using tr/xx/ /. 
>
>What is the escape character (xx above) for a CR in a textarea box? I was
>unsuccessful with \n.
>
>Looking at the raw text file, each of the CRs looks like a control M. What
>escape character do I search/replace to kill these guys??? I hope this
>doesn't depend on platform.....

You probably want to say

  $string =~ tr/\cM/ /;

to remember that it's Ctrl-M, or use \r (\n is a Ctrl-J assuming a
"normal" environment)

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 20 Aug 1997 16:17:42 -0500
From: Patrick O'Lone <polone@sanasys.com>
To: Shaun O'Shea <lmisosa@eei.ericsson.se>
Subject: Re: CGI: Forms RADIO BUTTONS
Message-Id: <33FB5EF6.2B78@sanasys.com>

Shaun O'Shea wrote:
> 
> Hi,
>   I hve just started trying to use forms and I'm having a bit of
> trouble:
> 
> I have some radio buttons and a text form on one page and I'm having
> trouble trying to get the state of the radio buttons in the resulting
> perl script.
> 
> The following is the relevant exerpt from the first page:
> 
> <form action="/cgi-bin/s1.pl"
>       method="POST"><br>
> 
> <P><input type="radio" name="tpe" value="eng" checked>  ##Choice 1</P>
> 
> <P><input type="radio" name="tpe" value="dec"> ##choice 2</P>
> 
> <P><B><I><FONT COLOR="#0000FF"><FONT SIZE=+2>Enter your search string
> below:</FONT><FONT SIZE=+3>
> </FONT></FONT></I></B></P>
> 
> <textarea name="string" cols=40 rows=4>
> </textarea>
> 
> <input type="reset" value="Reset">
> <input type="submit" value="search">
> </form>
> 
> ##Now I know that if I want to get what's in the text search string I
> do:
> 
> %incoming = &read_input;        # Read information into associated
>                                 # array %incoming.
> $your_text = $incoming{'string'}; # Fetch the text from the array.

Notice how the associative array uses the NAME of the object to get the
data from it.  The same is true for the radio buttons.  As an example,

$radio_button_data = $incoming{'tpe'};

If you print the value of this, you get whichever they chose.   If the
user had chosen "eng", then the value of radio_button_data would equal
"eng".

-- 
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."


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

Date: Wed, 20 Aug 1997 16:54:10 -0500
From: Patrick O'Lone <polone@sanasys.com>
To: srichard@san-jose.ate.slb.com
Subject: Re: create a file in a user directory with a perl script ...
Message-Id: <33FB6782.1900@sanasys.com>

I wouldn't suggest using the web as a place to create files on your
server.  It presents a lot of security holes.  I would suggest just
telling users to use FTP or Telnet.

-- 
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."


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

Date: Wed, 20 Aug 1997 15:03:37 -0700
From: Stephane Richard <srichard@san-jose.ate.slb.com>
To: polone@sanasys.com
Subject: Re: create a file in a user directory with a perl script ...
Message-Id: <33FB69B9.7948E220@san-jose.ate.slb.com>

Ok I have to explain a liitle bit more :

I want to use the vacation program to give to the users the possibility
to enable their vacation files with Netscape. I have 450 users and 1/3
have Mac, 1/3 have PC and 1/3 have Sun, then ...
I need to create four files in their own directory.
I have try to give to a script the permission of the user, for another
the root permission
I did a setuid in C program,   but it doesn't work

Could somebody help me ?

For the securuty holes, they is a firewall for the outside and for
inside I we believe in our employees :))

Here it's my C program :

/* cpvacation.c  */

#include <sys/types.h>
#include <stdio.h>

void main( argc, argv)
int argc;
char * argv[];
{
    int x;
    char *cdl1;
    char *ncdl1;
    int newuid;

    printf("%d\n",argc);
    for (x=0; x<argc; x++)
        printf("%s\n",argv[x]);

newuid = atoi(argv[3]);

 printf (" Effective uid before    %i \n", geteuid());
 printf (" Effective gid before    %i \n", getegid());

 printf (" User ID before          %i \n", getuid());
 printf (" Setuid (%i)              %i \n", newuid, setuid(newuid));
 printf (" User ID after           %i \n", getuid());

 printf("The new owner of this file is %s\n",argv[1]);
 printf("Directory to be copy is %s\n",argv[2]);

system("id");
system("sh");

execl("cp", "cp", "/tmp/.vacation.msg", argv[2], NULL);
execl("cp", "cp", "/tmp/.vacation.pag", argv[2], NULL);
execl("cp", "cp", "/tmp/.vacation.dir", argv[2], NULL);
execl("cp", "cp", "/tmp/.forward", argv[2], NULL);

}



Patrick O'Lone wrote:

> I wouldn't suggest using the web as a place to create files on your
> server.  It presents a lot of security holes.  I would suggest just
> telling users to use FTP or Telnet.
>
> --
> Patrick O'Lone
> Sana Systems Webmaster Administrator
> polone@sanasys.com
> "The edge is everything..."





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

Date: Wed, 20 Aug 1997 16:01:10 -0500
From: Jason McNutt <jasonmc@mail.utexas.edu>
Subject: FAQ Database
Message-Id: <33FB5B16.6385@mail.utexas.edu>

I am developing an FAQ but I haven't seen any scripts to create and
search a flat database on an FAQ.  If anyone has suggestions or know
where to find the script let me know.  I don't want to re-invent the
wheel.

Thanks,

Jason


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

Date: 20 Aug 1997 20:31:18 GMT
From: drielsma@snow.ingenia.com (Paul Hankes Drielsma)
Subject: Hash + Regex
Message-Id: <5tfk6m$k4i$1@news.ingenia.com>

Heya all,

I'm somewhat of a newbie and I'm wondering if there is any problem
associated with calling a hash within a regular expression.  I have a line
which looks like this
s/<title><\/title>/<title>$titles{$var}<\/title>/ig; 
for inserting title into an HTML page.

It dies a horrible death with "Scalar found where operator expected" and I'm
wondering if perhaps the dollar signs or braces are being misinterpreted
within the regex.

Thanks in advance,
Paul


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

Date: 20 Aug 1997 21:07:43 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Hash + Regex
Message-Id: <5tfmav$k52@news-central.tiac.net>

In article <5tfk6m$k4i$1@news.ingenia.com>,
Paul Hankes Drielsma <drielsma@snow.ingenia.com> wrote:
>Heya all,
>
>I'm somewhat of a newbie and I'm wondering if there is any problem
>associated with calling a hash within a regular expression.  I have a line
>which looks like this
>s/<title><\/title>/<title>$titles{$var}<\/title>/ig; 
>for inserting title into an HTML page.
>
>It dies a horrible death with "Scalar found where operator expected" and I'm
>wondering if perhaps the dollar signs or braces are being misinterpreted
>within the regex.

#!/usr/local/bin/perl -w

%titles = ('one' => 'First Title',
           'two' => 'Second Title',
          );

foreach $var ('one', 'two') {
  $title = "...<title></title>..."	# missing ;
  $title =~ s:<title></title>:<title>$titles{$var}<\title>:ig;
  print "got $title\n";
}

__END__

dies with a message starting "Scalar found where operator expected at
 ./try.pl line 9", but in recent versions of perl the error message now
says: 

Scalar found where operator expected at ./try.pl line 9, at end of line
        (Missing semicolon on previous line?)

which might be more helpful (note that all I did to myour s/// command was
change the / to :)

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 20 Aug 1997 21:30:55 GMT
From: news@bofh.com (Jot Powers)
Subject: Re: Hash + Regex
Message-Id: <5tfnmf$c8g$1@gazette.corp.medtronic.com>

In article <5tfk6m$k4i$1@news.ingenia.com>, Paul Hankes Drielsma wrote:
>Heya all,
>
>I'm somewhat of a newbie and I'm wondering if there is any problem
>associated with calling a hash within a regular expression.  I have a line
>which looks like this
>s/<title><\/title>/<title>$titles{$var}<\/title>/ig; 
>for inserting title into an HTML page.
>
>It dies a horrible death with "Scalar found where operator expected" and I'm
>wondering if perhaps the dollar signs or braces are being misinterpreted
>within the regex.

If I were to make a guess, I'd guess that your hash value has special
characters (say a /) that make it break.  Observe:

main::(-e:1):   1
  DB<1> $bob{'fred'} = "Joe"  
 
  DB<2> $name = "fred" 
 
  DB<3> $_ = 'A<title></title>B'
 
  DB<4> s#<title></title>#<title>$bob{$name}</title>#ig
 
  DB<5> p $_
A<title>Joe</title>B
  DB<6> 


Things of note:  
   
	o I made my separator # instead of / so that I didn't
	  have to escape /'s
	o My hash didn't contain a #

It would help if you could post a small program with sample
input to generate the error:

(Of course, I just did the following, and it didn't break:

  DB<6> $_ = 'A<title></title>B'
 
  DB<7> $bob{'fred'} = "#joe"
 
  DB<8> s#<title></title>#<title>$bob{$name}</title>#ig
 
  DB<9> p $_
A<title>#joe</title>B


So, obviously you have another problem.

-- 
Jot Powers  news@bofh.com
Unix System Administrator
"Sometimes you just have to grab the bull by the tail and face the situation."


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

Date: 20 Aug 1997 19:07:04 GMT
From: Fabio Albanese <falbanese@usa.net>
Subject: Help me !!! :)
Message-Id: <5tff8o$6g3@mikasa.iol.it>

Hello

I'm looking for a complete guide about PERL language...

Is there something in WWW ?

Please reply me in email: falbanese@usa.net

Thanx

Fabio



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

Date: Wed, 20 Aug 1997 19:40:15 -0400
From: Brian Yoder <yoder5@gate.net>
Subject: Re: Help on 'system' function
Message-Id: <33FB805F.1EE4@gate.net>

Well, if the two programs must be different scripts and different
run-time processes, then you might try:

   First Program  first.pl
   $amount = `second.pl $amount`  # Enclose command in backtics
                                  # to capture stdout in $amount

Also, and especially for multiline output, you could use open()
and append "|" to the name to open second.pl and create a pipe
that you can read as needed and close when done.

Brian


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

Date: 20 Aug 1997 20:36:52 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: HELP!!!!Please.....
Message-Id: <5tfkh4$ih4@news-central.tiac.net>

In article <5tfh0o$99r@foobar.cs.jhu.edu>,
Nilay Jhaveri <jhaveri@hops.cs.jhu.edu> wrote:
>
>I have a Perl Question for anyone kind enough to help me.
>I have an array of words, say @fields...
>But since this array is dynamically allocated, I do not know how many
>words are in it before run time.
>Is there a regular expression that basically looks for those words in
>sequence, but allowing unlimited spaces(\s)+ between words?
>so if  @fields is("joe", "jack");
>it will match
>joe jack

>etc...etc..
>
>
>If I know the words that are in sequence  before run time, i could do
>$word1[\s]+$word2[\s]+$word3
>
>but dynamically I am not too sure....

Dependong on how often the pattern changes and how often you use the
pattern you might be able to do something like:

  $pattern = join '\\s+', map {quotemeta} @fields;

and then something like this may suffice

  if ($data =~ /$pattern/) {
    ...
  }

but that may turn out to be hugely inefficient if the fields list changes
often (and it doesn;t really handle what's before & after the pattern) so
you might want to look at
http://perl-com.songline.com/CPAN-local/doc/FMTEYEWTK/regexps.html and see
how match_any generates code on the fly so that a regex is only compiled
once.

Without knowing more about how this is used it's a little hard to know
which of the ways to do it in perl is appropriate.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 20 Aug 1997 22:07:17 GMT
From: xewj@odin.sunquest.com
Subject: Re: HELP!!!!Please.....
Message-Id: <5tfpql$fv2$1@iggy.sunquest.com>

In article <5tfh0o$99r@foobar.cs.jhu.edu>,
Nilay Jhaveri <jhaveri@hops.cs.jhu.edu> wrote:
>I have an array of words, say @fields...
>But since this array is dynamically allocated, I do not know how many
>words are in it before run time.
>Is there a regular expression that basically looks for those words in
>sequence, but allowing unlimited spaces(\s)+ between words?
>so if  @fields is("joe", "jack");
>it will match
>joe jack
>or 
>joe          jack
>or joe
>
>jack
>but if @fields is("joe", "jack", "jill")
>it will match
>joe jack
>    jill

Well, it's a bit kludgy, but try:

$checkvar=join('\s+',"",@fields,"");
$eval= $matchme=~/$checkvar/;

remove the "" before and after @fields if you want to match initial and ending
partials.


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

Date: Wed, 20 Aug 1997 19:44:12 -0400
From: Brian Yoder <yoder5@gate.net>
Subject: Re: How can I make this CGI script work
Message-Id: <33FB814C.7B20@gate.net>

I. John Misiris wrote:
[snip]
> I run the OS2HTTPD Ver. 1.04 and try to run my first cgi perl script
> 
> first.pl
> ----------------------------
> #!/perl5/perl5
> use CGI ':standard";
[snip]

It's been a while, but if I recall correctly, OS/2 doesn't support
the #! magic. Change the first line to something like:

  # extproc perl -S

Of course, be sure perl and the script are both in a directory
within the current PATH.

Brian


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

Date: Wed, 20 Aug 1997 17:08:34 -0400
From: Brad Herder <bherder@orrqms2.psf.lmco.com>
Subject: Re: How do I find the system date/time?
Message-Id: <33FB5CD2.79@orrqms2.psf.lmco.com>

Alan J. Flavell wrote:
> 
> On Mon, 18 Aug 1997, Marcantonio Fabra wrote:
> 
> > print "Today's date is: <B>$months[$mon] $mday, 19$year</B><BR>\n";
> 
> Y2K, here we come.
> 
> Better make that 1900+$year , methinks.
> 
> --

Is that really correct?  Is Unix going to return 100 in the year 
2000?  Or is it going to return 00?  

I'd really like to know.

Fortunately, I only have one subroutine to change if this is wrong,
which is:

#----------------------------------------------------------------------
# Year2000 - Convert Year to 4 digits.
#----------------------------------------------------------------------
sub Year2000
{
local ($year) = @_;

if ( $year > 90 ) 
{ $year = $year+1900; } 
else 
{ $year = $year+2000; }

return $year;

Thanks,
Brad Herder
bherder@orrqms2.psf.lmco.com


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

Date: Wed, 20 Aug 1997 19:46:48 -0400
From: Brian Yoder <yoder5@gate.net>
Subject: Re: How do I find the system date/time?
Message-Id: <33FB81E8.3677@gate.net>

Brad Herder wrote:
[snip]
> >
> > Better make that 1900+$year , methinks.
> >
> > --
> 
> Is that really correct?  Is Unix going to return 100 in the year
> 2000?  Or is it going to return 00?
[snip]

In the year 2000, a year of 100 will be returned. It really is
going to return (year - 1900). That returned year won't fit into
a 2-digit decimal representation anymore, of course.

Brian


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

Date: Wed, 20 Aug 1997 17:47:24 -0400
From: Ed Vander Bush <temp.ed.vanderbush@bentley.com>
Subject: include tags
Message-Id: <33FB65EC.5B03@bentley.com>

Can I print a include tag in a dynamicly generated web page is this
possible?


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

Date: 20 Aug 97 23:05:21 GMT
From: geecee@netquarters.net (Gary Chambers)
Subject: Re: incredibly simple question
Message-Id: <slrn5vmu2r.1j1.geecee@flyfish.netquarters.net>

>branch doesn't seem to get taken no matter what you type.
>if ($resp = ~ /^[yY]+/)

The operator you're using has no spaces in it.  IOW, try:

if ($resp =~ /^y/i)

 ...and you'll find that it works as expected.  Remember, there's more
than one way to do it.

-- 
Gary

//------------------------------------------
// NetQuarters, Inc., Brunswick, ME 04011
// 207-798-8400 (Voice) 207-798-8403 (Fax)
// Midcoast Maine's Total Internet Solution
//------------------------------------------


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

Date: Wed, 20 Aug 1997 16:42:19 -0500
From: Patrick O'Lone <polone@sanasys.com>
To: Mike McCurdy <mccurdy@rohan.sdsu.edu>
Subject: Re: Novice scratches head
Message-Id: <33FB607D.E51@sanasys.com>

Mike McCurdy wrote:
> 
> My understanding was that perl would treat these variables as integers
> when used like this. Given that $x's value is not equal to 100000, why is
> $x being printed? TIA ...
> 
> #!/usr/local/bin/perl
> $x = system "/usr/bin/sar -r 1 | tail -1 | cut  -c26-32";
> if ($x == 100000) {
>         print $x;
> }

 When you placed the data into the variable $x, you placed it as a
literal string.  That means you need to compare for string values, not
numerical values.  Thus, by changing your if statement to the following:

if ($x eq "100000") {
   print $x;
}

This will check to compare as if it was a string literal, not a
numerical value.  try that, I think it should work.

-- 
Patrick O'Lone
Sana Systems Webmaster Administrator
polone@sanasys.com
"The edge is everything..."


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

Date: Wed, 20 Aug 1997 21:11:19 +0100
From: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: Passing 1 programs O/P to anothers I/P via file handles
Message-Id: <OSQO0cAn90+zEwkA@worsdall.demon.co.uk>

Hi, I have a script that sends me an email. It opens the unix mail
program and then just print stuff to it via the print command with the
handle MAIL. While this program is open I want to open another (Easy I
guess) and pass it's Output direct to the Mail program input while that
is open.

I think I might be on the right trail below but is there such a thing as
doing a:-

print MAIL TRACE

(where MAIL is the handle for the mail program and TRACE is the handle
for the traceroute program, so data flow directly from it?)

HELP I am all confused!


# $surfer is an IP address.
# $traceprog is the location and name of traceroute.


# Open The Mail Program
open(MAIL,"|$mailprog -t");

print MAIL "To: jaydee\@worsdall.demon.co.uk\n";
print MAIL "From: A.perl.script\n";

# Check for Message Subject
print MAIL "Subject: $surfer\n\n";

print MAIL "Today: $date\n";
print MAIL "$ENV{'HTTP_X_FORWARDED_FOR'}:- $surfer\n";
print MAIL "Visited from : $ENV{'HTTP_REFERER'}\n";
print MAIL "using browser: $ENV{'HTTP_USER_AGENT'}.\n\n\n";

if ($surfer eq $ENV{'HTTP_X_FORWARDED_FOR'}) {
        if ($ENV{'REQUEST_URI'} eq '/index.stm') {
                open(TRACE,"|$traceprog "+$surfer);
                close (TRACE);
        }
}
close (MAIL);

-- 
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydee@worsdall.demon.co.uk  WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmaster@shadow.org.uk    WEB site:- http://www.shadow.org.uk


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

Date: Wed, 20 Aug 1997 16:28:16 -0400
From: Dan Boorstein <dboorstein@ixl.com>
To: temp.ed.vanderbush@bentley.com
Subject: Re: Reading a string, splitting it, and using it
Message-Id: <33FB5360.594C6B00@ixl.com>

Ed Vander Bush wrote:
> 
> I am reading information from a database I created into an aray
> A line of data in the Database woulde be in this format
> var1|var2|var3|var4|var5|var6|var7
> With Var 1 being a specific id number
> $id = $Cookies{'itg'};
> open(USERDATABASE, "$database")||die "Database cannot be opened";
> @database = <USERDATABASE>;
> close(USERDATABASE);
> foreach (@database){
> if(/^$id/) {
> ($idn,$name,$itemone,$itemtwo,$itemthree,$itemfour,$itemfive) =
> split(/|/,7);
> open(LOG, ">$logfile");
> print LOG $name, $itemthree;
> close(LOG);
> My problem is that the variable are not being returned.... Why?

One problem i see right off is that you are using | in a regex which is
taken as an 'or', not a literal. You need to escape it like '\|'. Second
split expects a string to be split after the regex. If no string is
supplied $_ is used. Of course this precludes usage of the limit option.
In your case split thinks you want to split 7 everywhere possible. Try:

split '\|', $_, 7;

good luck,

dan


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

Date: 20 Aug 1997 19:09:46 GMT
From: merittj@wangfed.com (Jim Meritt)
Subject: SATAN on a linux
Message-Id: <5tffdq$d1f@elf.wang.com>

Anyone gotten S.A.T.A.N. (using Perl 5 or better, of course) to run on a PC
(using linux or SCO or some such)?

-- 
James W. Meritt
The opinions expressed above are my own.  The facts simply
are and belong to none.



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

Date: Wed, 20 Aug 1997 09:36:01 -0700
From: "Peter X. Wang" <peter_xihong_wang@ccm.jf.intel.com>
Subject: Special Char in "BJRN" treated as EOF by NT Perl 5?
Message-Id: <33FB1CF1.556C@ccm.jf.intel.com>

Trying to parse a data file which contains a special character
as in the following line between "BJ" and "RN".

796,82,BJRN JONSSON,,BJRN,,JONSSON,1476,

This char looks like a black box from a Windows editor, and is
thus invisible to me.  Although I would imagine this is a char that is 
commonly used in a northern European language.

The problem is my Perl parsing script will treat this special
char as EOF and exit immediately after seeing it, and thus
cann't parse any record after this one.

The data file that I was trying to process was dumped from a
mainframe computer.

I am handling a large database and desparately seeking help to
get this problem solved to move on.  Any help would be greately 
appreciated.

Thanks.

- Peter


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

Date: 20 Aug 1997 23:05:59 GMT
From: "Jon Marshall" <xkn14@dial.pipex.com>
Subject: undeclared variables ???
Message-Id: <01bcadbd$46f1b0c0$0bf482c1@jon>

could someone please explain why the folllowing when run 
complains about an undeclared variable on line 28 - i have been
working on this and it's driving me mad - the code works but 
i would like it to run with the -w switch  - incidentally - is the find
module for perl supposed to run faster than unix find - both run 
too slow for this job - hence the following approach 

many thanks in advance 

jon marshall


#!/usr/bin/perl -w  
#

use diagnostics;

%all = ();

@dirs = `cat bin/direcs`;

foreach $proj ( @dirs ) {
        chomp($proj);
        &break($proj);                 
        foreach $key ( keys %all ) {
               print "$key   =  $all{$key}\n";
        }
        undef %all;
}
sub break {
          my($proj) = @_;
          my($size,$dir,$file,@whole,@direcs) = 0;
          chdir $proj;
          opendir (SUB, ".");
          @whole = grep !/^\.\.?$/, readdir SUB;
          closedir(SUB);
          foreach $file ( @whole ) {
                  if ( ! -d $file ) {
                     $size = -s $file;
                     $all{$file} += $size; # line 28 #        
                  } else {
                     $dir = join '/', $proj,$file;
                     push(@direcs,$dir);         
                  }
          }
          foreach $dir ( @direcs ) {
                  &break($dir);
          }
          return %all;
}



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

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 897
*************************************

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