[9184] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2801 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 3 19:08:47 1998

Date: Wed, 3 Jun 98 16:01:00 -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, 3 Jun 1998     Volume: 8 Number: 2801

Today's topics:
        Batch files? <Dpaladin@ix.netcom.com>
    Re: File Upload Script rpearce@my-dejanews.com
    Re: Fun with two arrays (Abigail)
    Re: HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <featheredfrog@geocities.com>
    Re: HELP!!!!!!!!!!!!!!!!!!!!!!! (Michael J Gebis)
    Re: How do you send .htaccess username and pass? suave@colba.net
        How to set timezone via cgi using perl bthak@bascom.com
    Re: How to set timezone via cgi using perl (Larry Rosler)
    Re: map in void context regarded as evil - suggestion (Michael J Gebis)
    Re: map in void context regarded as evil - suggestion (Abigail)
        Misuse of email addressers of posters to c.l.p.m. (Larry Rosler)
        Multiuser situation with SDBM / Tied hash <webmaster@profind.com>
        newbie: trying to remove unwanted data from an array... <steven@mail.dhc.com>
    Re: newbie: trying to remove unwanted data from an arra (Bob Trieger)
    Re: newbie: trying to remove unwanted data from an arra (Larry Rosler)
        Perl Class Browser / DB tutorial <webmaster@easy.web66.com>
    Re: Perl module for doing a unix 'which'? <vallon@bear.com>
    Re: Please Help: How do you make a vote/polling script? rpearce@my-dejanews.com
        Program output piping under NT (for web browser) <mcadir1@umbc.edu>
    Re: regex help. (Craig Berry)
    Re: regex help. (Craig Berry)
    Re: Saving variable in $ENV{'REMOTE_USER'} suave@colba.net
        Seeking on a pipe herkimer@cs.wisc.edu
    Re: Seeking on a pipe (Jonathan Stowe)
    Re: Specialized Split (Tad McClellan)
    Re: Specialized Split (Jonathan Stowe)
    Re: Spider programms in PERL (I R A Aggie)
    Re: Suggestions? suave@colba.net
    Re: value of a environment variable Bobd@my-dejanews.com
    Re: Win32 Perl and Unix Perl <rootbeer@teleport.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 03 Jun 1998 14:17:17 -0700
From: Douglas Nusbaum <Dpaladin@ix.netcom.com>
Subject: Batch files?
Message-Id: <3575BD5C.CF2EBC86@ix.netcom.com>

Is it possible to run a batch file from a perl script?
If so, could someone send me some sample code.

Code.
more code(file.bat)
more code

Do there exist tools for compiling perl, and running the compiled code
instead of the source?

thanks



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

Date: Wed, 03 Jun 1998 21:39:41 GMT
From: rpearce@my-dejanews.com
Subject: Re: File Upload Script
Message-Id: <6l4fqt$h03$1@nnrp1.dejanews.com>

In article <6kuve2$h1c$1@news.interlog.com>,
  "Media Kitchen Inc." <info@mediakitchen.ca> wrote:
>
> Hi,
>
> I would like to know where i could
> find a script that will allow users to
> upload files into a certain directory
> on my server.
>
> Thanks
> PHil
>
>
Try www.cgi-resources.com .  Look in Scripts then Perl then File Upload.

Rick...


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 3 Jun 1998 22:54:10 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Fun with two arrays
Message-Id: <6l4k6i$6sg$1@client3.news.psi.net>

Daniel (daniel.mendyke@digital.com) wrote on MDCCXXXVII September
MCMXCIII in <URL: news:6l46bs$389$1@nntpd.lkg.dec.com>:
++ 
++ 
++ Given:
++ 
++ my @first = qw( one two three four );
++ my @second = qw( mon tue wed thr );
++ 
++ What is the quickest way to produce a thrid
++ array such that it contains
++ "one mon two tue three wed four thr"?
++ 
++ my @third = ????


        die "Unequal lengths" unless @first == @second;
        $#third = $#first * 2 + 1;

        foreach ($i = $j = 0; $i < @first; $i ++) {
           $third [$j ++] = $first  [$i];
           $third [$j ++] = $second [$i];
        }


But that's boring.

Fun is something like:

        @hash {@first} = @second;
        @third = map {$_ => $hash {$_}} @first;


Abigail
-- 
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
           print+Just (), another (), Perl (), Hacker ();'


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

Date: Wed, 03 Jun 1998 17:22:09 -0400
From: "Michael D. Hofer" <featheredfrog@geocities.com>
Subject: Re: HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Message-Id: <3575BE81.3992@geocities.com>

<sigh!, putting on the old SUN SE hat...>

James, Sun Solaris boxes don't come with a c compiler any more, and
haven't for some time.  Your best bet is to surf to the free software
for sun site linked from http://opcomm.sun.ca/ (I think it's midway down
the list on the left), and from that (it's a sunsite), find GCC2721, a
relatively recent compilation of the GNU C compiler.  Install that, and
then build your perl.  The perl on that free site, while precompiled, is
several generations old, and the build of the 5.004_04 is fairly quick.

michael


James wrote:
> 
> hi, I wish u all good greetings....
> I'm from the philippines. I wanna ask u how would I set up our web server
> properly to
> run Perl 5.004 ?? I read that perl is downloaded by source and I need to
> compile it using
> C. But when I checked our web server it says :
> 
>    /usr/ucb/cc : language optional software package not installed.
> 
> Does this mean that our Solaris has no C installed in it ??
> 
> And also, the kernel version we have is SunOS 5.5.1.
> 
> architecture is sun4m
> 
> application architecture is sparc.
> 
> can someone help me how to install Perl and if ever the C compiler there
> doesn;'t exist,
> can someone help me or guide me how I will be able to install C there ??
> 
> Thanx and God Bless
> 
> James
> 
> by the way, I tried checking /usr/bin but there is no C compiler there.
> The CC compiler is at /usr/ucb
> 
> it says it's a link to the BSD compiler located at /usr/ccs/bin/ucbcc but
> then
> I cannot find such file at our server (file ucbcc doesn't exist ) What Can
> I do and help me
> what are the proper things to do... thanx again

-- 
Cian ua'Lochain /mka/ Michael D. Hofer
No Unsolicited Commercial Email: $500.00/Item for proofreading!
I'm not a medievalist - I just play one on weekends!
http://www.geocities.com/SoHo/Lofts/9800/


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

Date: 3 Jun 1998 21:33:59 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: HELP!!!!!!!!!!!!!!!!!!!!!!!
Message-Id: <6l4fg7$23m@mozo.cc.purdue.edu>

"James" <mayo98@portalinc.com> writes:

}hi, I wish u all good greetings.... 

Yeah, u too.

Anyway, you asked about installing a C compiler so that you can
install perl.  From the phrasing of your questions, let me offer this
suggestion:

Go bake some really sweet, fattening chocolate chip cookies.  Go to
your sysadmin.  Share the cookies.  Talk with him.  Really listen; get
to know him as a person.  Later, if you find your new friendship is
blossoming, ask him about this.

Your question does not have a succinct answer.  You wouldn't want
someone to teach you long division over a newsgroup, and your question
is harder to answer.  Ask a local expert, and YOU will be happier.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 03 Jun 1998 17:15:11 -0400
From: suave@colba.net
Subject: Re: How do you send .htaccess username and pass?
Message-Id: <3575BCDF.7C891AD5@colba.net>

Ric Alcazar wrote:
> 
>     Hello,
> 
>     I'm trying to run an authorization script for a section of my website.
> I've created a script which prompts user for login and password (and if
> correct) sends them on to another page within my website.  Unfortunately...
> this does not provide as much security as I like.  (A user could simply just
> enter the URL of the page and get sent right there.)  I've, therefore,
> implemented a server authentication (.htaccess) to protect those documents.
> 
>     This bring up another piece to my puzzle.  Now the user has to
> authenticate twice (once for my script and again for the server) to get to
> the page.  I'd like for the user only to have to authenticate once.  Is
> there anyway that I can pass the username and password from my perl script
> to the server authentication?  This would help to solve the dilemma of
> having to enter your login and password twice.  Please help!
> 
>     Ric.

Forget about the authentication script, and use the web server's
authentication feature. Using .htaccess and .htpasswd will be much
simpler, and you can still use remote environment variables like
REMOTE_USER, etc... if you need to, because the browser sends that
information with every request anyways.

Mark Steele
Technical Support Supervisor
ColbaNet Internet Inc.
suave@colba.net


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

Date: Wed, 03 Jun 1998 21:42:16 GMT
From: bthak@bascom.com
Subject: How to set timezone via cgi using perl
Message-Id: <6l4fvo$hfc$1@nnrp1.dejanews.com>

I did search on dejanews for that subject and it wasnt much help. If someone
can help me out it would be greatly appreciated.

I want to be able to set timezone via web interface.  Not sure how to.
the args in localtime don't seem to have TZ. Thanks in advance.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 3 Jun 1998 15:47:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to set timezone via cgi using perl
Message-Id: <MPG.fdf72479e074fb5989693@hplntx.hpl.hp.com>

In article <6l4fvo$hfc$1@nnrp1.dejanews.com>, bthak@bascom.com says...
> I did search on dejanews for that subject and it wasnt much help. If someone
> can help me out it would be greatly appreciated.
> 
> I want to be able to set timezone via web interface.  Not sure how to.
> the args in localtime don't seem to have TZ. Thanks in advance.
 ...

You can determine the timezone of the processor on which the program is 
executing without looking at the TZ environment variable.  Some systems 
(such as Windows/DOS) don't have such a variable, yet they know the 
localtime.  [Believe it or not, Unix guys.  The existence of $ENV{TZ} is 
a reliable differentiator between Unix and WinDOS.  $^O is not 
implemented in older perls such as 5.002, and $^O needs to be parsed in 
any case.]

#!/usr/local/bin/perl -w
use strict;

my ($l_min, $l_hour, $l_year, $l_yday) = (localtime $^T)[1, 2, 5, 7];
my ($g_min, $g_hour, $g_year, $g_yday) = (   gmtime $^T)[1, 2, 5, 7];
my $tzval = ($l_min - $g_min)/60 + $l_hour - $g_hour +
    24 * ($l_year <=> $g_year || $l_yday <=> $g_yday);
print $tzval, "\n";

This prints -7 where I am now (PDT), takes summer time into account, and 
works for every timezone which has offsets from UTC in integral minutes.  
There are none that I know of with offsets in seconds, but it would be 
trivial to include that too.

> I want to be able to set timezone via web interface.  Not sure how to.

It's not clear to me what 'set timezone via web interface' means, but I 
Hope This Helps (TM).

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: 3 Jun 1998 21:20:40 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <6l4en8$1pm@mozo.cc.purdue.edu>

abigail@fnx.com (Abigail) writes:

}If only HTML was designed by a committee. BLINK, FONT, BGCOLOR, etc, are
}all "inventions" from the evil empire - Netscape Communication Corporation.
}And they don't believe in standards. 

I guess you're probably mad that we're not all still using gopher+ and
that somebody came up with the <IMG> tag.  But arguing this is best
done in the www.advocacy newsgroup (or really, not done at all).  This
wasn't the point.

}As for paragraphs being containers - that's follows from HTML being defined
}with SGML rules. The decision to move HTML towards SGML was proposed by
}Dan Conolly, back in 1992 or so.

I guess you missed my point, which was:

"HTML used to be a hell of a lot like pod."

		OR

"The road to HTML was paved with good intentions"


-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 3 Jun 1998 22:24:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <6l4if7$6gd$1@client3.news.psi.net>

Michael J Gebis (gebis@albrecht.ecn.purdue.edu) wrote on MDCCXXXVII
September MCMXCIII in <URL: news:6l4en8$1pm@mozo.cc.purdue.edu>:
++ abigail@fnx.com (Abigail) writes:
++ 
++ }If only HTML was designed by a committee. BLINK, FONT, BGCOLOR, etc, are
++ }all "inventions" from the evil empire - Netscape Communication Corporation.
++ }And they don't believe in standards. 
++ 
++ I guess you're probably mad that we're not all still using gopher+ and
++ that somebody came up with the <IMG> tag.

You couldn't be more wrong.




Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Wed, 3 Jun 1998 15:13:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Misuse of email addressers of posters to c.l.p.m.
Message-Id: <MPG.fdf6a5afa651c6c989692@hplntx.hpl.hp.com>

[posted and emailed]

"Thomas P. Missert" <thomas@net1plus.com> wrote to me by email...
> This is the blind request that I have been sending out to people that have
> anything to do with perl. I could really use some help.
> 
> I am hoping that you can help me. I have exhaust my resource of Perl
> Software Engineers in the MA/NH area and need help. Do you know someone that
> might be interested in checking out the following opportunity?
 ... (107 more lines snipped)

You are going to make many posters to this newsgroup very angry by using 
their email addresses in this fashion.  If you want to use the Usenet for 
recruiting, post to the suitable 'jobs' group and use the keyword 'Perl'.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 03 Jun 1998 23:28:08 -0400
From: Philip Kallerman <webmaster@profind.com>
Subject: Multiuser situation with SDBM / Tied hash
Message-Id: <35761448.4AA5@profind.com>

Hello,

I have a little question about SDBM. I am now curious about how to
stabilize the hash vectors in multiuser (both retreival and insertion)
situations. Is this possible, and in that case  how can it be done?

/Philip Kallerman


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

Date: Wed, 03 Jun 1998 21:33:03 GMT
From: "Steve Neuharth" <steven@mail.dhc.com>
Subject: newbie: trying to remove unwanted data from an array....
Message-Id: <jijd1.711$On1.2740532@ptah.visi.com>

O.k. I KNOW there's an easy answer to this.... I can't seem to find it
anywhere....
I've got an array (@rawoutput). I only need the lines that contain
"SUB-TOTAL:".... I'm trying some thing like this.....
$x=0;
   for ($y=0;$y <= @rawoutput; $y++){
      if (@rawoutput[$y] =~ /SUB-TOTAL:/) {
         @output[$x] = @rawoutput[$y];
         $x++;
      }
   }
@output never seems to populate with data (not sure why).

I was thinking there should be a way to do it something like this (?).......
@output = (@rawoutput =~ /SUB-TOTAL:/);





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

Date: Wed, 03 Jun 1998 21:48:27 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: newbie: trying to remove unwanted data from an array....
Message-Id: <6l4ge5$g9t$1@strato.ultra.net>

[ posted and mailed ]
"Steve Neuharth" <steven@mail.dhc.com> wrote:
-> O.k. I KNOW there's an easy answer to this.... I can't seem to find it
-> anywhere....
-> I've got an array (@rawoutput). I only need the lines that contain
-> "SUB-TOTAL:".... I'm trying some thing like this.....
-> $x=0;
->    for ($y=0;$y <= @rawoutput; $y++){
->       if (@rawoutput[$y] =~ /SUB-TOTAL:/) {
->          @output[$x] = @rawoutput[$y];
->          $x++;
->       }
->    }

foreach (@rawoutput) {
        next if !/SUB-TOTAL/i; 
        push @output,$_;
}

it's definately a 1 liner using the map function but I don't wanna embarass 
myself trying to do it.

HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-320-9895
    and hang up when somebody answers "


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

Date: Wed, 3 Jun 1998 15:01:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie: trying to remove unwanted data from an array....
Message-Id: <MPG.fdf6780d222ba5d989691@hplntx.hpl.hp.com>

In article <jijd1.711$On1.2740532@ptah.visi.com>, steven@mail.dhc.com 
says...
> O.k. I KNOW there's an easy answer to this.... I can't seem to find it
> anywhere....
> I've got an array (@rawoutput). I only need the lines that contain
> "SUB-TOTAL:".... I'm trying some thing like this.....
> $x=0;
>    for ($y=0;$y <= @rawoutput; $y++){
>       if (@rawoutput[$y] =~ /SUB-TOTAL:/) {
>          @output[$x] = @rawoutput[$y];
>          $x++;
>       }
>    }
> @output never seems to populate with data (not sure why).
> 
> I was thinking there should be a way to do it something like this (?).......
> @output = (@rawoutput =~ /SUB-TOTAL:/);

Here is the best way by far to do it:

@output = grep /SUB-TOTAL:/, @rawoutput;

Now that that's out of the way, it might be instructive to make your 
attempt work.

> $x=0;
>    for ($y=0;$y <= @rawoutput; $y++){

It would be more Perlish to say
   foreach (@rawoutput) {
to get a line at a time (into $_ as written).  Using your indexing 
approach, you are off by one in this line.  @rawoutput in scalar contect 
is the number of elements in the array.  As you index from 0, the highest 
index should be one less than that.  Replace <= by <.

>       if (@rawoutput[$y] =~ /SUB-TOTAL:/) {
>          @output[$x] = @rawoutput[$y];

As for the other errors, replace in all three places '@arrayname[$index]' 
by '$arrayname[$index]' because what you want to use are scalar members 
of the arrays, and $ is the prefix for 'scalar'.

And you could use 'push' to add elements to the array @output, instead of 
indexing.  I'd suggest buying 'Learning Perl' from O'Reilly & Associates.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 03 Jun 1998 23:59:06 +0200
From: Malte Ubl <webmaster@easy.web66.com>
Subject: Perl Class Browser / DB tutorial
Message-Id: <3575C72A.7370@easy.web66.com>

Hi,

1.) I just started using objects for programming in Perl and
thought that it would be cool to have a class browser.
Does anyone know a freeware class browser for Perl?

2.) Does anyone know a website that provides a tutorial for
Perl-Database connection?

Any comment would be appreciated!

Thanx,
Malte Ubl

PS: If you can, please answer via eMail and News.

-- 
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<HEAD>\n";
print "<TITLE>Malte Ubl</TITLE>\n";
print '<META NAME="DESCRIPTION" ';
print 'CONTENT="Free and easy to use Access Counter ';
print 'and other CGI Perl Scripts at:">' , "\n";
print '<META NAME="LOCATION" ';
print 'CONTENT="http://easy.web66.com">' , "\n";
print '<META NAME="EMAIL" ';
print 'CONTENT="webmaster@easy.web66.com"></HEAD>';


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

Date: Wed, 03 Jun 1998 22:44:56 GMT
From: Justin Vallon <vallon@bear.com>
Subject: Re: Perl module for doing a unix 'which'?
Message-Id: <x6e90negl5j.fsf@pearl.bear.com>

Tom Christiansen <tchrist@mox.perl.com> writes:

>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, "Brian J. Sayatovic" <bjs@iti-oh.com> writes:
> :    Has anyone come across a comprehensive module to do the equivalent of a
> :UNIX which in Perl for UNIX/Win32?
> 
>     #!/usr/bin/perl
>     # pgrep - grep for files in your path
>     chop($cwd = `pwd`) unless $cwd = $ENV{'PWD'};
>     $regexp = shift || die "usage: $0 regexp\n";
>     for $dir (split(/:/,$ENV{'PATH'})) {
> 	chdir($dir =~ m#^/# ? $dir : "$cwd/$dir") || next;
> 	opendir(DOT, '.') || next;
> 	while ($_ = readdir(DOT)) {
> 	    next unless /$regexp/o;
> 	    next unless -f;
> 	    next unless -x _;
> 	    print "$dir/$_\n";
> 	} 
>     }

Why chdir?  What about?

    $regexp = shift || die "usage: $0 regexp\n";
    for $dir (split(/:/,$ENV{'PATH'})) {
	opendir(DIR, $dir) || next;
	while ($_ = readdir(DIR)) {
	    next unless /$regexp/o;
	    next unless -f "$dir/$_";
	    next unless -x _;
	    print "$dir/$_\n";
	} 
    }

-- 
-Justin
vallon@bear.com


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

Date: Wed, 03 Jun 1998 21:51:42 GMT
From: rpearce@my-dejanews.com
Subject: Re: Please Help: How do you make a vote/polling script???
Message-Id: <6l4ghe$iaa$1@nnrp1.dejanews.com>

If you want to see some expamples of working scripts that you can modify
yourself, check out www.cgi-resources.com and follow the
Scripts/Perl/Survey links.  There's several working scripts there.


In article <6l1qin$8ju@bgtnsc02.worldnet.att.net>,
  "Matt L." <matt@att.net> wrote:
>
> Thanks a lot for the tip!  I'll check it out.  I'm just getting started
> with PERL, you know, reading the books and writing scripts.
>
> >Matt
>
> --------------
> --------------
>
> Vincent M. Probasco <probavm@cat.com> wrote in article
> > Matt,
> >     I asume you know some PERL. You'll need to have a file seperate from
> > your cgi script that keeps
> > track of the voting results. The file might start out looking like
> > this...
>
> > 0
> > 0
> > 0
> > 0
>
> >         Each zero would be a different field that you want to keep track
> > of. You can then parse this data
> > and add to it as necesary. I know this is brief , but I hope it helps.
> > You'll need to use the open() and
> > close() functions to get to the data inside the file.
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 03 Jun 1998 17:57:30 -0300
From: Martin Cadirola <mcadir1@umbc.edu>
Subject: Program output piping under NT (for web browser)
Message-Id: <3575B8BA.91D68732@umbc.edu>

Hello!!!

I'd need to pipe the output of a program run on a NT web server.
If I run the following script under the command prompt,

--------------------------------------------------
$path =3D 'c:/perl/mail/blat.exe';

open (NETSTATUS, "$path |");
@variable =3D <NETSTATUS>;
close (NETSTATUS);

print "@variable\n";
--------------------------------------------------

I get the information printed out as I want. However, if I run the
following script (adapted for use with a browser) :

--------------------------------------------------
$path =3D 'c:/perl/mail/blat.exe';

open (NETSTATUS, "$path |");
@variable =3D <NETSTATUS>;
close (NETSTATUS);

print "Content-Type: text\html\n\n";
print "@variable\n";
--------------------------------------------------

Then the browser opens a window as if I'd had downloaded a file.
What am I doing wrong? Any hints/tips are welcome.
Thanks again for your assistance!!!
Best regards,

Mart=EDn Cadirola
E-mail: mcadir1@umbc.edu


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

Date: 3 Jun 1998 22:04:08 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: regex help.
Message-Id: <6l4h8o$6oo$1@marina.cinenet.net>

bthak@bascom.com wrote:
: Need some help.
: 
: $temp = shift;
: 
: if ($temp =~ /[a-zA-Z_0-9]{8,}/){

Your character class is identical to \w (in the default locale).  You
might want to use that instead, for improved readability and
maintainability.

:         if ($temp =~ /\d{2,3}/) {
:                 print "good has 8 chars and 2-3 number";
:         }
[snip]
: 
: "($temp =~ /\d{2,3})"  <-- checks for consecutive digit how can i have it so
: something like 1blahblah1 will be a match.

There are (as usual) many ways to do this, but

  @digits = $temp =~ /(\d)/g;
  if (@digits == 2 || @digits == 3) {

strikes me as the most straightforward.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 3 Jun 1998 22:18:16 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: regex help.
Message-Id: <6l4i38$6oo$2@marina.cinenet.net>

Craig Berry (cberry@cinenet.net) wrote:
: There are (as usual) many ways to do this, but
: 
:   @digits = $temp =~ /(\d)/g;
:   if (@digits == 2 || @digits == 3) {
: 
: strikes me as the most straightforward.

Following up my own post:  Using $digits = $temp =~ tr/0-9// is even
better, as mentioned by another poster. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 03 Jun 1998 16:59:55 -0400
From: suave@colba.net
Subject: Re: Saving variable in $ENV{'REMOTE_USER'}
Message-Id: <3575B94B.9A86D0CA@colba.net>

Ric Alcazar wrote:
> 
>     Hello all,
> 
>     Quick newbie question.  When I save a value to the environment variable
> "REMOTE_USER" how come that value returns nothing when I call it in a
> separate pl script?
> 
>     I've saved it like this:
> 
> sub check_login {
> 
>      $ENV{'REMOTE_USER'} = $login;
> }
> 
>     Yet, when I use another script to call the environment variable it
> returns nothing.  I've tried a varied of things...  like adding
> 
>     require "scriptname.pl"
>     &check_login;
> 
>     to the calling script, however that does nothing but give a 500 error.
> I'm throroughly confused.  Perhaps someone could help to shed a little light
> on things.  Thank you.
> 
>     Ric

The reason why you can't access the value in a different script, is that
everytime you lauch a seperate script, you are starting a new process,
which has it's own environment variable information. If you want to save
the information, you save it into a file.

Try this:

# Script to get and save remote user
# get and parse the information from the form or browser, then add the
following
use Fcntl;
$ENV{'REMOTE_USER'} = $login
open (TMPFILE, ">tmpfile") || die "can't open temp file:$!";
flock (TMPFILE, LOCK_EX) || die "can't lock temp file: $!";
print TMPFILE $login;
close (TMPFILE) || die "can't close the tmpfile: $!";
#The rest of the first script here

Now for the second script
# Do whatever you usually do here, and when you want to access the
remote user info
use Fcntl;
open (TMPFILE, "tmpfile") || die "can't open the tmpfile: $!";
flock (TMPFILE, LOCK_EX) || die "can't get a lock on the tmpfile: $!";
while (<TMPFILE>) {
$login = $_;
		}
unlink ("tmpfile");

And that's the way to do it if you want to use the variable information
from different scripts, although I don't understand why you want to use
two different scripts when you could probably do everything you need to
do in the same script. This little snippet of code assumes you only need
one variable (namely, remote user), if you want so save many variables
away, you'll have to do it another way.

Mark Steele
Technical Support Supervisor
ColbaNet Internet Inc.
suave@colba.net


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

Date: 3 Jun 1998 21:10:38 GMT
From: herkimer@cs.wisc.edu
Subject: Seeking on a pipe
Message-Id: <6l4e4e$6ai@spool.cs.wisc.edu>

Hi. I am working on a project that displays various system logs on our
UNIX computers. Most of these are plain text files, so that seeking to
where I left off and only displaying new data is not a problem.
However, several log sets are only available as stdout of programs. No
problem, I thought--I just opened a pipe from the executables as a
file handle, and expected to be able to seek on it just the same as a
normal file, but to no avail. Calling tell on the pipe-filehandle
returns -1 wherever I call it. 

Does anyone have any suggestions for doing what I want to?

-- 
Dan Bongert                | Hire the Morally Handicapped--It's More Fun
dbongert@students.wisc.edu | National Institute for the Morally Handicapped
herkimer@upl.cs.wisc.edu   | just a guy made of dots and lines


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

Date: Wed, 03 Jun 1998 21:55:33 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Seeking on a pipe
Message-Id: <3575c1e5.15966972@news.btinternet.com>

On 3 Jun 1998 21:10:38 GMT, herkimer@cs.wisc.edu wrote :

>Hi. I am working on a project that displays various system logs on our
>UNIX computers. Most of these are plain text files, so that seeking to
>where I left off and only displaying new data is not a problem.
>However, several log sets are only available as stdout of programs. No
>problem, I thought--I just opened a pipe from the executables as a
>file handle, and expected to be able to seek on it just the same as a
>normal file, but to no avail. Calling tell on the pipe-filehandle
>returns -1 wherever I call it. 
>

My Unix programmers reference says:

Unlike standard disk files, the lseek call cannot be used with a pipe.
Data written to the pipe must be read in the same order, and skipping
around is not permitted.

 
>Does anyone have any suggestions for doing what I want to?
>

You will either have to redirect output to a file and then open and
seek on that as required or create the pipe, read in a loop and ignore
bits as appropriate.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Wed, 3 Jun 1998 15:47:34 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Specialized Split
Message-Id: <6pc4l6.176.ln@localhost>

Jeffrey Horn (horn@beaner.cs.wisc.edu) wrote:
: I am looking for a slick way to split on a given character/pattern
: only if that character/pattern does not fall between opening and closing
: parens.

: Thus if I were to split on /\+\-/ 

: (1-3)+(2+5)

: would only split into two elements:

: (1-3)
: (2+5)


No it wouldn't.

Your delimiter string ('+-') does not appear in the string being split...

maybe you meant to write:     /[+-]/   instead?



: Anyone have a slick solution?


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

$_ = '(1-3)+(2+5)';

@parts = grep $_, split /(      # Triggers memory so matched part will be
                                #   included in the generated list.
                                # Without parens, the delimiters are discarded
                                # This is all explained in 'perlfunc'

                          \(    # a literal left parenthesis

                          [^)]+ # anything that is not a right parenthesis
                                #   if your parens can be nested, then
                                #   you'll need more power that is available
                                #   with regular expressions...

                          \)    # a literal right parenthesis
                         )      # stop rembering matched characters
                         |      # or
                         \+     # a literal plus sign
                        /x;     # m//x lets me put these comments here

for (@parts) {
   print "$_\n";
}
-------------------------------


grep() is used to eliminate the null strings that occur between
the delimiters.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 03 Jun 1998 21:29:04 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Specialized Split
Message-Id: <3575baf8.14553861@news.btinternet.com>

On 3 Jun 1998 20:05:22 GMT, Jeffrey Horn wrote :

>I am looking for a slick way to split on a given character/pattern
>only if that character/pattern does not fall between opening and closing
>parens.
>
>Thus if I were to split on /\+\-/ 
>
>(1-3)+(2+5)
>
>would only split into two elements:
>
>(1-3)
>(2+5)
>
>Not the four elements as a normal split would
>
>(1
>3)
>(2
>5)
>
Something like this :

#!perl

$string = "(1-3)+(2+5)";

@vals = split /[()\-+]+/ , $string;

print "@vals";

__END__

willl get just the numbers into @vals (you could remove the
parentheses in the character class if you want to keep them).  The
minus sign needs to be escaped because it has a special meaning within
the character class.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Wed, 03 Jun 1998 17:56:45 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Spider programms in PERL
Message-Id: <fl_aggie-0306981756450001@aggie.coaps.fsu.edu>

In article <01bd8f26$fa78ec80$e8854018@dundas>, "Leonid A.Arcadiev"
<arcadiev@usa.net> wrote:

+ Can anybody advice how to write a spider in perl, that would check on a
+ website and read through its contents.  If the responce has been received,
+ everything is fine, if no responce, generate an error message.

<url:http://www.stonehenge.com/merlyn/WebTechniques/>, Column 14 in
particular (Better bad links).

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: Wed, 03 Jun 1998 17:20:51 -0400
From: suave@colba.net
Subject: Re: Suggestions?
Message-Id: <3575BE33.46AE0011@colba.net>

DejaWank@my-dejanews.com wrote:

<snip> 
> 1. I have absolutely no experience with SQL or any kind of query language for
> databases. Can I use Berkeley DB to hold the records? Is this a good database
> application for keeping this simple database considering I'll be learning it
> from scratch? The number of records will probably never exceed 2000.

Use GDBM, it doesn't have any limits to the number of entries, and can
easily hold over 10000 entries.

<snip>
> 
> 3. Does anyone have experience embedding HTML in database records? Or, is
> there an elegant solution to automatically providing HTML code in returned
> queries of databases other than embedding HTML in the records?

You don't need to embed the html tags in the database, just use the
CGI.pm module for perl, and you'll be able to format the results for the
queries in html. Read the documentation on the CGI.pm module for more
info on this.


Mark Steele
Technical Support Supervisor
ColbaNet Internet Inc.
suave@colba.net


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

Date: Wed, 03 Jun 1998 21:38:11 GMT
From: Bobd@my-dejanews.com
Subject: Re: value of a environment variable
Message-Id: <6l4fo3$gvk$1@nnrp1.dejanews.com>

In article <6l3vm8$ob5$1@nnrp1.dejanews.com>,
  indhiraa@hotmail.com wrote:
>
> Hi,
>
> I need to get the value of environment variable whose name
> is stored in another variable.
>
> Something like,
>
> $envVar = "$LD_LIBRARY_PATH";
>
> As of now I do like,
>
> $ldpath = `echo $envVar`; chop ($ldpath);
>
> to get its value. Is there any elegant way of
> doing it.

Try using the ENV hash, all your enviroment varables are in there.

$value_you_wanted = $ENV{$Env_Var_Name};

Should work fine.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 03 Jun 1998 22:32:07 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Win32 Perl and Unix Perl
Message-Id: <Pine.GSO.3.96.980603151128.13600S-100000@user2.teleport.com>

On Wed, 3 Jun 1998, Christopher Spence wrote:

> Besides os, what is the comparison of speed?  Is there much of a
> difference? 

The speed of the underlying hardware and software is at least as important
as the speed of Perl. And the speed of Perl depends upon the quality of
the compiler used to build it, the options to the compiler, and other
factors, such as the tasks being performed.

In the end, the only way to know what's faster and what's slower is to see
what gets to the finish line first.

Having said all that, I'll add that it would surprise me greatly if a
properly-configured Linux system didn't outperform the corresponding
Windows-based system at running Perl code or at just about any other 
task. Unless the task is to rapidly cause a general protection fault, of
course!  :-) 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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

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