[11271] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4871 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 11 13:07:27 1999

Date: Thu, 11 Feb 99 10:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 11 Feb 1999     Volume: 8 Number: 4871

Today's topics:
    Re: a secure way to do a "rsh"? <baillie@my-dejanews.com>
        bareword "stdin" not allowed? x86 perl bug? foobar678@my-dejanews.com
        cannot run *.pl on browser (Chris Ow Yong)
    Re: cannot run *.pl on browser (Steve Linberg)
    Re: change column of nmbers to 2 dim array (Randal L. Schwartz)
    Re: change column of nmbers to 2 dim array (Abigail)
    Re: change column of nmbers to 2 dim array <jglascoe@jay.giss.nasa.gov>
    Re: Comments in Perl code <aqumsieh@matrox.com>
    Re: Comments in Perl code (Larry Rosler)
    Re: contains? <aqumsieh@matrox.com>
    Re: Converting CSV to LDIF droby@copyright.com
        Creating /tmp files securely? <dwc3q@cs.virginia.edu>
        creating lock file (Stephen J. Tremblett)
    Re: directory tree sherman@cdg.stsv.seagate.com
    Re: Does Perl restrict regular expressions? (Larry Rosler)
    Re: Does Perl restrict regular expressions? <uri@home.sysarch.com>
    Re: Getting the wildcard value <aqumsieh@matrox.com>
    Re: how to use map for complex sort???? (Randal L. Schwartz)
    Re: new to sockets... please help <aqumsieh@matrox.com>
    Re: newbie perl and cgi question..... <argus@sover.net>
        newbie: hitcounter <john@inetpres.com>
        Non-greedy split <tlynch@cisco.com>
    Re: Non-greedy split <Allan@due.net>
    Re: Non-greedy split <uri@home.sysarch.com>
        NT, IIS and Perl.exe <yeah.Right@yourhost.com>
        PDA module... <dcollins@s3two.ie>
    Re: Problem in writing the following expression in Perl <ludlow@us.ibm.com>
    Re: Problem with file creation <undefined@undefined.com>
    Re: Problem with file creation (Larry Rosler)
    Re: Running script locally in browser <Allan@due.net>
        Serialline <janko@cs.tu-berlin.de>
    Re: strict (Randal L. Schwartz)
    Re: Unix to DOS linefeed conversion? dave@mag-sol.com
    Re: Using PERL system call with MS IIS 4.0 (Martin Vorlaender)
        Win32 & OLE Dialog box in Word <bwidman@aps.org>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 11 Feb 1999 17:34:49 GMT
From: wil <baillie@my-dejanews.com>
Subject: Re: a secure way to do a "rsh"?
Message-Id: <79v4bp$61l$1@nnrp1.dejanews.com>

In article <oeen22lt3lm.fsf@alpha.hut.fi>,
  Jarkko Hietaniemi <jhi@alpha.hut.fi> wrote:
>
> wil <wmwilson1@go.com> writes:
>
> > Can someone provide me some info on how I could go about doing something
like
> > a "rsh <hostname> command" from within a perl-script.
> >
> > I'm running Apache with all scripts owned by nobody, so in order to be able
to
> > rsh a command to a remote host, I either need to set up a trust relationship
> > between the host and that user (no thanks), setuid on the script or....[Your
> > suggestion here] =).
>
> ssh.
>
> www.ssh.org
>
> --
> $jhi++; # http://www.iki.fi/jhi/
>         # There is this special biologist word we use for 'stable'.
>         # It is 'dead'. -- Jack Cohen
>

I'd actually rather find another way than that, not that I have anything
against the secure shell.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 11 Feb 1999 15:29:47 GMT
From: foobar678@my-dejanews.com
Subject: bareword "stdin" not allowed? x86 perl bug?
Message-Id: <79ut0v$vgr$1@nnrp1.dejanews.com>

I got this error and I con't figure out why:
      Bareword "STDIN" not allowed while "strict subs" in use

If I say "no strict 'subs'", then it compiles but the constructor
(new SGMLS (STDIN)) doesn't get STDIN.

*This also doesn't work  "new SGMLS (\*STDIN)";
*Neither does "use vars qw(*STDIN)"

*This is the code:

package MBCL::Parse;
use strict;
use vars qw(%wordlist $event $parse *DATAFILE);
use SGMLS;
use Win32::ODBC;
use CGI qw(:standard);
$|=1;
%wordlist = ();
$parse = new SGMLS (STDIN);
                     ^error


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 11 Feb 1999 16:06:51 +0000 (GMT)
From: oyhpeen@bigfoot.com (Chris Ow Yong)
Subject: cannot run *.pl on browser
Message-Id: <1999Feb11.160651.23332@leeds.ac.uk>

I am using Win95. I have written a simple perl script which incorporates 
cgi.pm. When I run *.pl on the web browser(IE3), the web browser keeps popping 
out the save to or open window. Please help.

Thanks in advance for the help.



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

Date: Thu, 11 Feb 1999 11:41:56 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: cannot run *.pl on browser
Message-Id: <linberg-1102991141560001@ltl1.literacy.upenn.edu>

In article <1999Feb11.160651.23332@leeds.ac.uk>, oyhpeen@bigfoot.com
(Chris Ow Yong) wrote:

> I am using Win95. I have written a simple perl script which incorporates 
> cgi.pm. When I run *.pl on the web browser(IE3), the web browser keeps
popping 
> out the save to or open window. Please help.

Browsers don't run Perl. You need a server.

Read the CGI.pm docs, and you will see how you can simulate running your
script under a server while you see about setting one up.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: 11 Feb 1999 07:02:56 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: change column of nmbers to 2 dim array
Message-Id: <m14sotj84f.fsf@halfdome.holdit.com>

>>>>> "Abigail" == Abigail  <abigail@fnx.com> writes:

Abigail> First of all he isn't using map in void context, as the result of the
Abigail> map is the result we're interested in. Just think there's a '@new = '
Abigail> on the line above.

Ahh... my mistake.

Abigail> And whether or not map in a void context is considered bad
Abigail> form by most doesn't matter. Your arguments against
Abigail> apparently don't matter for the people maintaining perl, as
Abigail> otherwise, it would have been fixed a long time ago.

My complaint isn't directed at the maintainers.  My complaint is
directed at users that use it in a void context. :) I'm not expecting
any, haven't requested any, and therefore haven't received any -
assistance from the maintainers.

grep/map in void context is considered bad form.  That's all.  Doesn't
matter if it's inefficient, or badly implemented, or even if it
appeared in some docs you may have read. :)

print map $_, "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 11 Feb 1999 17:13:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: change column of nmbers to 2 dim array
Message-Id: <79v33a$ek7$1@client2.news.psi.net>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MCMXC September
MCMXCIII in <URL:news:m14sotj84f.fsf@halfdome.holdit.com>:
<> 
<> grep/map in void context is considered bad form.


It's considered bad form by some.  

But then, many people consider programming in Perl bad form as well.



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: 11 Feb 1999 12:02:27 -0500
From: Jay Glascoe <jglascoe@jay.giss.nasa.gov>
Subject: Re: change column of nmbers to 2 dim array
Message-Id: <udbtj0rhzw.fsf@jay.giss.nasa.gov>

[courtesy cc of this posting sent to cited author, me, via email...  :)]

Jay Glascoe <jglascoe@giss.nasa.gov> cluelessly writes:

> excuse me?  what?  did I break some rule of etiquette here?
> 

hi all,

Randal and I amicably exchanged private mail regarding the
"[courtesy cc..." concept.  So, now I've switched news readers
from Netscape to Gnus in order to achieve the desired effect
automatically.

This post is both a test of my Gnus setup, and a message
signifying that all is well in Perl Land.  :)


	Jay Glascoe
-- 
http://www.giss.nasa.gov/cgi-bin/csci/change.pl


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

Date: Mon, 8 Feb 1999 11:45:50 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Comments in Perl code
Message-Id: <x3yzp6ooncy.fsf@tigre.matrox.com>


Eric Kihn <kihn@mindspring.com> writes:

> As a final thought. Has anyone considered how simple it would be to
> write a script called deploy.pl that simply
> strips all the comments (and even white space if you want) so that the
> "user" version is as fast as can be, but the coder get's his comments?

Yeah .. it's extremly simple .. 

% perl -pi.bak -e 's/\#.*$//' file.pl



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

Date: Wed, 10 Feb 1999 22:36:08 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Comments in Perl code
Message-Id: <MPG.112c1a2c2cc3ac84989a1d@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <x3yzp6ooncy.fsf@tigre.matrox.com> on Mon, 8 Feb 1999 
11:45:50 -0500 , Ala Qumsieh <aqumsieh@matrox.com> says...
> 
> Eric Kihn <kihn@mindspring.com> writes:
> 
> > As a final thought. Has anyone considered how simple it would be to
> > write a script called deploy.pl that simply
> > strips all the comments (and even white space if you want) so that the
> > "user" version is as fast as can be, but the coder get's his comments?
> 
> Yeah .. it's extremly simple .. 
> 
> % perl -pi.bak -e 's/\#.*$//' file.pl
                       ^   ^
                        Why?

Well, that is indeed extremely simple, and -- like most extremely simple 
solutions to complex problems -- it is extremely wrong.

Consider the following (probably partial) list of ways in which it will 
go astray:

'#' within a string literal: 'x#y'
'#' as a string-literal quote delimiter: q#foo#
'#' as a regex delimiter: m#bar#

These ordinary locutions create problems even for syntax-coloring 
editors (my copy of 'vim' had it wrong as installed, and I fixed it).  I 
think the real solution requires a stateful parser, and a regex simply 
can't hack it.

If there is real demand for this, perhaps a 'perl -#' flag would be the 
best way to implement it.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 8 Feb 1999 11:42:33 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: contains?
Message-Id: <x3y1zk0q22u.fsf@tigre.matrox.com>


bluesrift@aol.com (BLUESRIFT) writes:

> if ($ENV{QUERY_STRING} contains "this string") {...}

if ($ENV{QUERY_STRING} =~ /this string/) { ... }

perldoc perlre



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

Date: Thu, 11 Feb 1999 16:50:47 GMT
From: droby@copyright.com
Subject: Re: Converting CSV to LDIF
Message-Id: <79v1p3$3rv$1@nnrp1.dejanews.com>

In article <1dn16nl.1ad0pvn1qeiddiN@bay1-169.quincy.ziplink.net>,
  rjk@linguist.dartmouth.edu (Ronald J Kimball) wrote:
> What is LDAP?
>

LDAP = Lightweight Directory Access Protocol.

> (How long can we keep this going?  ;-)
>

I think that just about does it.  Now if we'd started with a recursive acronym
it could have gone on forever.  ;-)

> Martin Lvnnar <martin.lonnar@edt.ericsson.se> wrote:
>
> > LDIF = LDAP Data Interchange Format.
> >
> > /martin
> >
> > Steve Palincsar wrote:
> >
> > > CSV stands for "commas separated value" and there
> > > is a perl module in CPAN to help you parse it.
> > >
> > > What is LDIF?
> > >

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 11 Feb 1999 10:40:11 -0500
From: David Coppit <dwc3q@cs.virginia.edu>
Subject: Creating /tmp files securely?
Message-Id: <Pine.WNT.4.05.9902111033560.-108412089-100000@juggernaut>


I've got a script that creates temporary files. Because the files contain
email, I'm concerned about privacy. Now, the Unix way of creating
temporary files is by putting them in /tmp (or where ever TMPDIR points).
I believe this is also part of the POSIX standard.

However, putting files in the /tmp directory is susceptible to symlink
attacks, where an attacker guesses the name of the temp file, and creates
a symlink to his own (readable) file.

Since /tmp is used all the time, I find it hard to believe that there is
*no* way to create a temporary file in /tmp that does not have this
weakness.

Can someone illuminate me on the "right" way to do this, perhaps using
umask and the O_RDWR|O_CREAT|O_EXCL flags? (And maybe argue that this
method is not susceptible to the symlink attack? ;)

Thanks a lot,
David

________________________________________________________________________
David Coppit - Graduate Student        coppit@cs.virginia.edu
The University of Virginia             http://www.cs.virginia.edu/~dwc3q
                "For I am a Bear of Very Little Brain,
             and long words Bother me" - Winnie the Pooh




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

Date: 11 Feb 1999 15:30:58 GMT
From: sjt@cs.mun.ca (Stephen J. Tremblett)
Subject: creating lock file
Message-Id: <79ut3i$edj$1@coranto.ucs.mun.ca>

I need to replicate this action in perl:

        if (-1 == (fd = open(file, O_CREAT|O_EXCL, 0600))) {
                perror("open");
                if (errno != EEXIST) return 0;
        }

I need to create a lock file and open it exclusively in an atomic
operation.

My problem is that this:

        if (!(-e $file)) {
                open FI, ">$file";
        }

isn't an atomic operation.  The sysopen function claims to do what
I want, but I haven't had any success.  The following function consistently
returns 1 without creating the file:

sub acquire {
    my ($lockfile, $timeout) = @_;
    do {
        sleep 1;
        $timeout--;
		next if (-e $lockfile);
        sysopen LF, $lockfile, O_CREAT|O_WRONLY|O_EXCL || print "no open\n";
    } while (!defined(LF) && $timeout);
    if (defined(LF)) {
        print "in here\n";
        print LF "nothing\n";
        close LF;
        return 1;
    }
    return 0;
}
(excuse the debug messages)

Is 'defined(LF)' the correct way to test a filehandle?

Any suggestions?

I have to do it this way because this is one of a group of programs
interacting, and this one has to follow the same rules.

Thanks

--
-=> Steve Tremblett    	  
-=> Memorial University Computer Science
-=> sjt@cs.mun.ca; www.cs.mun.ca/~sjt 


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

Date: Thu, 11 Feb 1999 15:53:19 GMT
From: sherman@cdg.stsv.seagate.com
Subject: Re: directory tree
Message-Id: <79uudb$oj$1@nnrp1.dejanews.com>

In article <36C020CB.E0473F67@logica.com>,
  William Griggs <griggsw@logica.com> wrote:
> Ok, how do I go through a directory tree of unknown structure in Perl,
> putting all files (and their paths) into an array. Any shortcuts?
>
> Cheers,
>
> Bill

hi bill,

try this:

#!/usr/local/bin/perl
use File::Find;
find(\&wanted, "/top/level/directory");
sub wanted {
	push @allfiles, "$File::Find::name";
}

hope this helps!

-sherman

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 10 Feb 1999 21:21:09 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Does Perl restrict regular expressions?
Message-Id: <MPG.112c089e1102928989a1c@nntp.hpl.hp.com>

In article <36C2E14E.6EE20E9@home.com> on Thu, 11 Feb 1999 13:47:28 GMT, 
Rick Delaney <rick.delaney@home.com> says...
+ Uri Guttman wrote:
+ > 
+ > >>>>> "JF" == Jonathan Feinberg <jdf@pobox.com> writes:
+ > 
+ >   JF> Rick Delaney <rick.delaney@home.com> writes:
+ >   >> perl -lpe '$c++ if /somepattern/}$_=$c;{' file
                    ^ ^^                 ^^^ ^  ^

+ >   JF> Wow.  Abigail's silly trick has become an *idiom*.
+ > 
+ > that is scary! also it isn't in effective perl or the cookbook!
+ > but i wouldn't recommend it for anything but one liner hacks and
+ > even then it is just goofy.
+ 
+ yes, but it doesn't require a shift key.

Oh, yes it does (see above)!  Even Uri's code isn't shiftless.  :->
 
-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 11 Feb 1999 10:24:57 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Does Perl restrict regular expressions?
Message-Id: <x7emnxotdi.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> In article <36C2E14E.6EE20E9@home.com> on Thu, 11 Feb 1999 13:47:28 GMT, 
  LR> Rick Delaney <rick.delaney@home.com> says...
  LR> + Uri Guttman wrote:
  LR> + > 
  LR> + > >>>>> "JF" == Jonathan Feinberg <jdf@pobox.com> writes:
  LR> + > 
  LR> + >   JF> Rick Delaney <rick.delaney@home.com> writes:
  LR> + >   >> perl -lpe '$c++ if /somepattern/}$_=$c;{' file
  LR>                     ^ ^^                 ^^^ ^  ^

  LR> + >   JF> Wow.  Abigail's silly trick has become an *idiom*.
  LR> + > 
  LR> + > that is scary! also it isn't in effective perl or the cookbook!
  LR> + > but i wouldn't recommend it for anything but one liner hacks and
  LR> + > even then it is just goofy.
  LR> + 
  LR> + yes, but it doesn't require a shift key.

  LR> Oh, yes it does (see above)!  Even Uri's code isn't shiftless.  :->

but i am! i hit control (in emacs) and shift enough. i like to give my
keys a rest sometimes.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Mon, 8 Feb 1999 11:26:34 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Getting the wildcard value
Message-Id: <x3y3e4gq2th.fsf@tigre.matrox.com>


Rick Holt <holt@watson.ibm.com> writes:

>   <meta name="Author" content="Rick Holt">
> 
> If I want to extract the value of name, I know I can first

This is not the best solution, but you can do the following:

$html = '<meta name="Author" content="Rick Holt">';
($name) = $html =~ /name="(.*?)"/;

If that's all you need, then the above should be enough for you. If,
OTOH, you need more leaborate parsing, you can check CPAN for an
appropriate module.

HTH,
Ala



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

Date: 11 Feb 1999 07:09:43 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how to use map for complex sort????
Message-Id: <m1vhh9ht8o.fsf@halfdome.holdit.com>

>>>>> "Ronald" == Ronald J Kimball <rjk@linguist.dartmouth.edu> writes:

Ronald> @sorted = map { $_ -> [0] }
Ronald>           sort { $a -> [1] <=> $b -> [1] }
Ronald>           map { my(@cols) = split /:/, $_, 4;
Ronald>                 [ $_, $cols[1] + $cols[2] ] } @unsorted;

Ronald> (Also had an off-by-one error. :)

Actually, yeah, the limited split would reduce the time.  So, let's
use the built-in split-destination item counter:

	@sorted =
		map { $_->[0] }
		sort { $a->[1] <=> $b->[1] }
		map {
			my ($col1,$col2,$col3) = split /:/;
			[ $_, $col2 + $col3 ]
		} @unsorted;

Yes.. much clearer.

print map $_, sort map $_, "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 9 Feb 1999 10:28:54 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: new to sockets... please help
Message-Id: <x3y3e4fsiix.fsf@tigre.matrox.com>


Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> writes:

> $wheel->reinvent() || die "use LWP instead";

No .. that is wrong. It should be:

	$wheel->reinvent() && die "use LWP instead";

or .. it could be even clearer

	die "use LWP instead" if $wheel->reinvent();

Ala



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

Date: Thu, 11 Feb 1999 12:06:25 -0500
From: John Barrett <argus@sover.net>
Subject: Re: newbie perl and cgi question.....
Message-Id: <36C30E11.94774972@sover.net>

Here is a code snippet that I use a lot and works like a charm.

sub ReadParse {
    local (*in) = @_ if @_;
    local ($i, $key, $val);
               
    if ( $ENV{'REQUEST_METHOD'} eq "GET" ) { 
       $in = $ENV{'QUERY_STRING'}; 
    } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
       read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
    } else {
        # Added for command line debugging
        # Supply name/value form data as a command line argument
        # Format: name1=value1\&name2=value2\&... 
        # (need to escape & for shell)
        # Find the first argument that's not a switch (-)
       $in = ( grep( !/^-/, @ARGV )) [0];
       $in =~ s/\\&/&/g;
     }
               
     @in = split(/&/,$in);
               
     foreach $i (0 .. $#in) {
         # Convert plus's to spaces
        $in[$i] =~ s/\+/ /g;
               
         # Split into key and value.
        ($key, $val) = split(/=/,$in[$i],2); 
         # splits on the first =.
               
         # Convert %XX from hex numbers to alphanumeric
        $key =~ s/%(..)/pack("c",hex($1))/ge;       
        $val =~ s/%(..)/pack("c",hex($1))/ge;
               
         # Associate key and value. \0 is the multiple separator
        $in{$key} .= "\0" if (defined($in{$key})); 
        $in{$key} .= $val;

	$FORM{$key} = $val;        
         }
        return length($in);
}  

-======-
You can get the values
$FORM{'name as it comes from the html form'} = value


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

Date: Thu, 11 Feb 1999 11:20:04 -0500
From: John <john@inetpres.com>
Subject: newbie: hitcounter
Message-Id: <36C30334.753A3C93@inetpres.com>

I would like to use perl to create a hitcounter for a website. Does
anyone know of some documentation or examples that could get me started
and/or show me what to look out for?

thanks, John



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

Date: Thu, 11 Feb 1999 09:43:35 -0500
From: Tom Lynch <tlynch@cisco.com>
Subject: Non-greedy split
Message-Id: <36C2EC97.85A751B0@cisco.com>

Greetings:

	I have the following line:

/vob/project/testbench/include/project_ftq.v:67:1286:   function [31:0] ftq_get_cmd;

	I simply want to split on ":" but only 3
	times. I use the follwoing split syntax:

	@y = split(/:{1,2}?/);	

	However the line still gets broken up as follows:

/vob/cobalt/testbench/include/cobalt_ftq.v 67 1286    function [31 0] ftq_get_cmd;
							          ^-WRONG!

	What am I doing wrong here? I've tried:

	@y = split(/:{2}?/);
	@y = split(/:{3}?/);

	Neither of these even split the line up?

	Thanks for any help in advance!
   	   Tom											
	
-- 
#-----------------------+--------------------------+
# Tom Lynch             | Email: tlynch@cisco.com  |
# Cisco Systems         | Phone: 978-244-8765      | 
# 250 Apollo Drive      | FAX:   978-244-8039      |
# Chelmsford MA 01824   | MS:    CH1-2LF           |
#-----------------------+--------------------------+


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

Date: Thu, 11 Feb 1999 10:29:36 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Non-greedy split
Message-Id: <79usl5$s5q$1@camel18.mindspring.com>

Tom Lynch wrote in message <36C2EC97.85A751B0@cisco.com>...
:Greetings:
: I have the following line:
:/vob/project/testbench/include/project_ftq.v:67:1286:   function [31:0]
ftq_get_cmd;
: I simply want to split on ":" but only 3
: times. I use the follwoing split syntax:
: @y = split(/:{1,2}?/);


[snip]

You are barking up the wrong tree as it were.  split has its own parameter
to control the number of splits.

perldoc -f split

small ex:
my $foo = 'one:two:three:four:five';
my @y = split (/:/,$foo,3);
print "@y";

HTH

AmD




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

Date: 11 Feb 1999 10:28:49 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Non-greedy split
Message-Id: <x7btj1ot72.fsf@home.sysarch.com>

>>>>> "TL" == Tom Lynch <tlynch@cisco.com> writes:

  TL> Greetings:
  TL> 	I have the following line:

  TL> /vob/project/testbench/include/project_ftq.v:67:1286:   function [31:0] ftq_get_cmd;

  TL> 	I simply want to split on ":" but only 3
  TL> 	times. I use the follwoing split syntax:

  TL> 	@y = split(/:{1,2}?/);	

have you read the docs on split carefully? it has what you want in the
3rd argument. 

hth,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 11 Feb 1999 12:10:44 -0500
From: "Jon R" <yeah.Right@yourhost.com>
Subject: NT, IIS and Perl.exe
Message-Id: <79v336$lfc$1@ramp2.tir.com>

I have followed all the instructions. Perl is in the registry script maps.
the program runs fine from the command line. d:\perl\bin is in the system
path. Yet, when run from a browser, the browser times out. No error message,
nada.

This is totally annoying. Can anyone help me? I run NT 4.0, service pack 4,
FAT (so no individual file ownership, etc.) and the web server is the Peer
Web Server version of IIS 3.0. scripts from mickeysoft run fine. Only my
perl ones all fail with timeouts.

Jon Robison




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

Date: Thu, 11 Feb 1999 16:38:10 +0000
From: Diarmuid Collins <dcollins@s3two.ie>
Subject: PDA module...
Message-Id: <36C30772.EAC940C1@s3two.ie>

Hi
	I've been searching up and down for the PDA perl module
but I cannot find it anywhere. Was it dropped from the CPAN.
If so can someone mail it to me ? Any info would be 
appreciated
-- 
 Diarmuid Collins                |   +353-1-2185544    
 Silicon & Software Systems Ltd  |   dcollins@s3two.ie


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

Date: Thu, 11 Feb 1999 09:41:46 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Problem in writing the following expression in Perl
Message-Id: <36C2FA3A.66702BC2@us.ibm.com>

Larry Rosler wrote:
 
> 0600, James Ludlow <ludlow@us.ibm.com> says...
> > parenthesis
 
> If you're going to correct someone on terminology, you might want to be
> sure to get it right yourself.  'parenthesis' is singular; plural is
> 'parentheses'.

Oops, sorry.  Why can't the spell checker know what I _mean_?
 
> As for 'correcting' in the first place, 'brackets' (sometimes, 'round
> brackets') is perfectly normal British usage.  In fact, my Webster's-
> based dictionary has this:
> 
> bracket ...
> 3a: one of a pair of marks [ ] ... called also 'square bracket'
>  b: one of a pair of marks < > ... called also 'angle bracket'
>  c: PARENTHESIS
>  d: BRACE
> 
> So as far as this American dictionary is concerned, they are synonyms.

Ok, two things.
(1) I shouldn't have corrected it.  It was fine the way it was.
(2) The only reason I did correct it was because the difference between
(), [], and {} is such a big deal in Perl.  Ok, so they're synonyms. 
Would you really tell someone to use parentheses when they're trying to
access individual array elements?

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Thu, 11 Feb 1999 10:40:31 -0500
From: "George Saunders" <undefined@undefined.com>
Subject: Re: Problem with file creation
Message-Id: <79utjq$2k5@news1.snet.net>




Take this....
$filen = $FORM{filename};
open (RECORD,">$filen".".txt")||die"Cant create file";


and make it this.....
$filen = $FORM{'filename'};
open (RECORD,">$filen.txt") || die"Cant create file";

Considering that the rest of the script is correct, you should be all set.

Best of luck to you.


>here is an abstract of my code
>
>$filen = $FORM{filename};
>open (RECORD,">$filen".".txt")||die"Cant create file";
>
>and for sequential pages
>open (RECORD,">>$filen".".txt")||die"Cant create file";






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

Date: Wed, 10 Feb 1999 23:14:10 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Problem with file creation
Message-Id: <MPG.112c2313968dc3df989a1e@nntp.hpl.hp.com>

In article <79utjq$2k5@news1.snet.net> on Thu, 11 Feb 1999 10:40:31 -
0500, George Saunders <undefined@undefined.com> says...
> Take this....
> $filen = $FORM{filename};
> open (RECORD,">$filen".".txt")||die"Cant create file";
> 
> and make it this.....
> $filen = $FORM{'filename'};
> open (RECORD,">$filen.txt") || die"Cant create file";
> 
> Considering that the rest of the script is correct, you should be all set.

What possible difference can that make?  They are identical!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 11 Feb 1999 10:37:19 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Running script locally in browser
Message-Id: <79ut3k$s2h$1@camel18.mindspring.com>

Brian Dean Swan wrote in message <79upbk$e50$1@msunews.cl.msu.edu>...
: I am trying to view a script in my browser using Linux 2.0.36 from my
machine.  The problem is that I just get the actual script showing up in the
browser instead of the output.  I know the script works, because I can run
it from the command line and also after I ftp it up to my ISP.  Is there a
setting that I need to set on my system?  Permissions are set correctly
(chmod o+x file.cgi).  Do I need a "cgi-bin" server?  I have a good grasp on
the OS basics, but I will need more detail when dealing with any
:thing deeper.  Thank you in advance, and please reply to
swanbria@pilot.msu.edu



You need to install and configure a server on your system.  Many of the
Linux distributions provide one by default.  If you don't already have it,
check out the very popular Apache server: www.apache.org

HTH

AmD




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

Date: 11 Feb 1999 16:44:47 GMT
From: Janko Dimitroff <janko@cs.tu-berlin.de>
Subject: Serialline
Message-Id: <79v1dv$738$1@news.cs.tu-berlin.de>

Hi folks, I have a problem.

I just want to check the serial line constantly. It should go something 
like this :

while(..) {

<look what comes in>

}

The problem why i cant just make

$someinput = <SERIALIN>;

is that this would wait until something comes in.
And it can be that there is no input.
So I just want to look awhile.

If anyone knows how to solve my problem, please tell me !!!

Mail to janko@cs.tu-berlin.de


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

Date: 11 Feb 1999 07:06:53 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: strict
Message-Id: <m1zp6lhtde.fsf@halfdome.holdit.com>

>>>>> "Ronald" == Ronald J Kimball <rjk@linguist.dartmouth.edu> writes:

Ronald> James Ludlow <ludlow@us.ibm.com> wrote:
>> I'll second that.  If you can't figure out 'man perldoc', you've got a
>> bit more to learn before you start digging into a programming language.

Ronald> Or you're not using Perl on a Unix platform.

In which case you type "perldoc perldoc", or if you're on a
command-line-stricken GUI-face, then you read the docs that came with
your highly altered Perl and figure out how to read the docs that are
included with EVERY standard release of Perl.

Perhaps I'm preaching to the choir here, but I have a hard time
believing that people expect *no* usable docs to come with a tool, and
don't look there first to answer basic questions.  What next, typing
questions like "how do i press the shift key..." :)

print "Just another Perl hacker and documentor,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 11 Feb 1999 17:23:30 GMT
From: dave@mag-sol.com
Subject: Re: Unix to DOS linefeed conversion?
Message-Id: <79v3m8$5g5$1@nnrp1.dejanews.com>

In article <36c258ee.0@news.cgocable.net>,
  tekkin@hotmail.com (Ken Williams) wrote:
> I have some text coming from a unix server that is in normal linefeed format.
> How could I use perl to convert this text to have a linefeed & carrige return
> so when it is displayed on a windows95 computer it will look proper (text is
> in a variable called $string).  Right now I take the text and display in a
> visual basic text box, and I get a small square box for each linefeed and its
> all on one line - not good.

How are you transferring the files? If you're using FTP you can carry out the
transfer in ASCII mode and things should work out fine.

There's more about this problem and possible solutions at

<http://www.mag-sol.com/Articles/>

Dave...

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 11 Feb 1999 07:05:42 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Using PERL system call with MS IIS 4.0
Message-Id: <36c27336.524144494f47414741@radiogaga.harz.de>

Rolland Suh (rolland@MCS.COM) wrote:
: With PERL and MS IIS 4.0, how can I use "system" call to run a child process,
: and have the result go back through the parent, to the IIS and finally back
: to the browser? (All through the parent's STDOUT)

I/O redirection is broken in M$ IIS. For IIS 4, follow these
instructions to make it work (at the expense of some performance):

- Make sure that you've got Windows Scripting Host installed as part
  of Option Pack 4. You can verify this by looking for the file
  %system32%\cscript.exe. If it isn't there, run setup.exe from
  the Option Pack CD-ROM and install it.
- Using the CLI, go to %system32%\inetsrv\adminsamples.
- Run this:

        adsutil.vbs SET W3SVC/1/CreateCGIWithNewConsole 1

  (the number after "W3SVC/" may vary if you have multiple websites.
   If you have, repeat the procedure for all websites.)
  It'll say that CScript isn't set up to handle this. That's ok.
- Click Ok.
- Click yes, you want to register.
- Run it again.
- Using the ISM, restart all web sites.

Hope it helps,
  Martin
--
                        | Martin Vorlaender | VMS & WNT programmer
 VMS is today what      | work: mv@pdv-systeme.de
 Microsoft wants        |       http://www.pdv-systeme.de/users/martinv/
 Windows NT 8.0 to be!  | home: martin@radiogaga.harz.de


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

Date: Thu, 11 Feb 1999 10:36:28 -0500
From: Brian Widman <bwidman@aps.org>
Subject: Win32 & OLE Dialog box in Word
Message-Id: <36C2F8FB.57B5D725@aps.org>

All,

I need to pass a file location to a dialog box that pops up when my
script runs.  I don't want to get rid of the dialog box, but I do need a

way to pass a file location to it.  Has anyone any ideas on how to do
this?

--
Brian Widman
Authoring Tools Analyst - The American Physical Society
Mailto:bwidman@aps.org




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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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