[10656] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4248 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 18 14:07:27 1998

Date: Wed, 18 Nov 98 11:00:28 -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           Wed, 18 Nov 1998     Volume: 8 Number: 4248

Today's topics:
    Re: $ENV uninitialized error <uri@fastengines.com>
    Re: /g modifier: why not 'last' out of while loop? <rootbeer@teleport.com>
        ActiveState & Xitami <webmaster@topproducer.com>
    Re: CGI Problem is so far unsolvable any takers wanna t (Mike G.)
    Re: CHUNK Error (M.J.T. Guy)
    Re: COBOL to PERL translator <gellyfish@btinternet.com>
    Re: create variable name from a variable in perl <rgoeggel@atos-group.com>
        Dynalib - make problems on Activeperl <sridhar.krishnaswamy@mci.com>
    Re: Exec question! <rgoeggel@atos-group.com>
    Re: Exec question! (Clinton Pierce)
    Re: file type? <rgoeggel@atos-group.com>
    Re: Help needed: How to redirect output from STDOUT int <rootbeer@teleport.com>
    Re: Help needed: How to redirect output from STDOUT int (Ron)
    Re: Help on use strict please <jdporter@min.net>
    Re: how to get `date` in perl for win32 (newbie) (Larry Rosler)
        I/O to parallel port <msda+@andrew.cmu.edu>
    Re: Intermediate Perl questions <uri@fastengines.com>
        Log Munging <cici@erols.com>
    Re: MacPerl + Resource Fork (Rich Morin)
    Re: NT security + IIS + perl <jburley@uci.edu.NOSPAM>
    Re: Perl Array Question? Anybody... (Joergen W. Lang)
    Re: Perl Usage Survey - interpretations, anyone? (Adam Turoff)
        Q: bulk-assign associative array? (Apple-O)
    Re: Q: bulk-assign associative array? (Apple-O)
    Re: Q: bulk-assign associative array? (Andrew M. Langmead)
        required fields <softsci@eagle.ca>
    Re: required fields <burt.adsit@gte.net>
    Re: Scope question for Perl (Andrew M. Langmead)
    Re: substitute <rgoeggel@atos-group.com>
    Re: Two-Part RE question (Erik)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 18 Nov 1998 12:31:19 -0500
From: Uri Guttman <uri@fastengines.com>
Subject: Re: $ENV uninitialized error
Message-Id: <sariugcewm0.fsf@camel.fastserv.com>

>>>>> "BL" == Bart Lateur <bart.mediamind@ping.be> writes:

  BL> Uri Guttman wrote:
  >> in general don't use
  >> defined on hashes since the key may exist and have a value of undef.

  BL> The reverse. :-)

  BL> If $ENV{PATH_INFO} exists, but it's not defined, you'll STILL get the
  BL> warning. AS a prevention of that warning, this sucks (to paraphrase
  BL> B&B).

you can't have an ENV value that is undefined from the parent
process. the standard form is VAR=VAL is in memory set from the exec in
the parent. perl converts those strings to the ENV hash, so you would a
least get a null string as a value if it exists as VAR= . so for ENV
either defined or exists would work.

but as i said before in GENERAL i use exists to make sure i have a legal
hash key. if i know the value must be defined (as in when i set up the
hash that way), i can used defined.

> export FOO=
> env | grep FOO
FOO=
> perl -w -e 'print "$ENV{FOO}\n"'

>


uri


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Wed, 18 Nov 1998 17:14:36 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: /g modifier: why not 'last' out of while loop?
Message-Id: <Pine.GSO.4.02A.9811180911310.27321-100000@user2.teleport.com>

On Wed, 18 Nov 1998, J.D. Laub wrote:

> I don't understand something in the Cookbook.  From pg. 170:
> 
> [To find the Nth match in a string,]
> Use the /g modifier in a while loop, keeping count of matches:
> 
> $WANT = 3;
> $count = 0;
> while (/(\w+)\s+fish\b/gi) {
>     if (++$count == $WANT) {
>         print "The third fish is a $1 one.\n";
>         # Warning: don't `last' out of this loop
>     }
> }
> 
> Why can't a 'last' be used to bail out of the loop?

I may be mistaken about the authors' intentions, but I think they're just
being cautious. The string ($_ in this case) holds an iterator to remember
the current search position. If you did another match on the same string
later, the pos()ition would be left in the middle, rather than at the
start. By looping until the match fails, the iterator is reset.

Of course, the iterator could be reset by assigning to pos() directly, if
you really did want to use last. Hope this helps!

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



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

Date: Wed, 18 Nov 1998 09:59:17 -0800
From: "Alistair Calder" <webmaster@topproducer.com>
Subject: ActiveState & Xitami
Message-Id: <72v1tc$a8r$1@supernews.com>

Has anyone tried ActiveState's Perl setup with Xitami Web Server?  I am
running a very busy Intranet that is using up loads of processor time for
all the Perl scripts that are going on.  I want to use ActiveState, but I am
a little wary of installing it if it isn't going to work.

Has anyone had any experiences they can share?

Thanks,
Alistair

"Uh, do you want that to go?"
- recently heard at a fast-food drive thru window




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

Date: 18 Nov 1998 17:52:27 GMT
From: mike@www.intrig.com (Mike G.)
Subject: Re: CGI Problem is so far unsolvable any takers wanna try to solve...
Message-Id: <72v1gr$3s5m@yuma.ACNS.ColoState.EDU>

Use the . [period] to denote when one sentence ends and the other begins.

Mike


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

Date: 18 Nov 1998 18:43:53 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: CHUNK Error
Message-Id: <72v4h9$iju$1@pegasus.csx.cam.ac.uk>

kelly woodhead  <kwoodhead@kenan.com> wrote:
>
>Im new to looking at perl and wondered if anybody could let me know what
>the folowing error indicates:
>
>CHUNK ERROR 274.
>
>I guess that it is an internal perl error but can anybody actualoly tell
>me what this is?.

That's not a Perl error message.   All Perl error messages should be
listed (with explanations) in

    perldoc perldiag


Mike Guy


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

Date: 17 Nov 1998 22:50:49 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: COBOL to PERL translator
Message-Id: <72suk9$1ba$1@gellyfish.btinternet.com>

On Mon, 16 Nov 1998 19:00:52 +0100 Oliver Muthig <oliver.muthig@ubs.com> wrote:
> Hi,
> 
> is there anything like a COBOL to PERL translator ?
> 

Yeah, generally they look and smell bad and charge far too much for their
services :)

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


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

Date: Wed, 18 Nov 1998 16:28:38 +0100
From: "Ronald Gvggel" <rgoeggel@atos-group.com>
Subject: Re: create variable name from a variable in perl
Message-Id: <72uqha$4mk$2@news.pop-stuttgart.de>

Brian Jackson schrieb:
> 
perldoc -f eval


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

Date: Wed, 18 Nov 1998 18:02:53 GMT
From: "Sridhar Krishnaswamy" <sridhar.krishnaswamy@mci.com>
Subject: Dynalib - make problems on Activeperl
Message-Id: <hZD42.2152$8G5.694@news.cwix.com>

When I try to run "perl Makefile.PL" - I get the following error. It seems
to be building a "testtest.c" file and is unable to find windows.h include
file. I am running Activeperl - release  version 5.005_02 built for
MSWin32-x86-object.

Here is output from makemaker.

 ------------------------------
testtest.c
D:\perl\lib\CORE\win32.h(57) : fatal error C1083: Cannot open include file:
'win
dows.h': No such file or directory
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 11.00.7022 for 80x86
Copyright (C) Microsoft Corp 1984-1997. All rights reserved.

testtest.c
D:\perl\lib\CORE\win32.h(57) : fatal error C1083: Cannot open include file:
'win
dows.h': No such file or directory
Writing conv.xsi
Writing cbfunc.c
Writing Makefile for C::DynaLib
[D:/perl/cgi-stuff/C-DynaLib-0.53]
---------------------------------------------

Since makemaker seemed to run to completion, I tried to continue and run
"nmake" on the Makefile. I get the follow error from xsubpp.

----------------------------
Microsoft (R) Program Maintenance Utility   Version 1.62.7022
Copyright (C) Microsoft Corp 1988-1997. All rights reserved.

Too many parameters - &&
        D:\PERL\BIN\PERL.EXE -ID:\perl\lib -ID:\perl\lib
D:\perl\lib\ExtUtils/xs
ubpp  -typemap D:\perl\lib\ExtUtils\typemap DynaLib.xs >DynaLib.tc &&
D:\PERL\BI
N\PERL.EXE -ID:\perl\lib -ID:\perl\lib -MExtUtils::Command -e mv DynaLib.tc
Dyna
Lib.c
Usage: xsubpp [-v] [-C++] [-except] [-prototypes] [-noversioncheck]
[-nolinenumb
ers] [-s pattern] [-typemap typemap]... file.xs
NMAKE : fatal error U1077: 'D:\PERL\BIN\PERL.exe' : return code '0xff'
Stop.
----------------------------------
Appreciate help in getting this figured...

Sridhar K




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

Date: Wed, 18 Nov 1998 16:22:55 +0100
From: "Ronald Gvggel" <rgoeggel@atos-group.com>
Subject: Re: Exec question!
Message-Id: <72uqgr$4mk$1@news.pop-stuttgart.de>

jesper kempe schrieb:
> 
> Hi
> I4ve got a problem:

read 
perldoc -f exec
perldoc -f system
perldoc perlfunc        - backtick

Ronald


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

Date: Wed, 18 Nov 1998 17:40:01 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Re: Exec question!
Message-Id: <366105bf.524958337@news.ford.com>

On Wed, 18 Nov 1998 16:22:55 +0100, "Ronald Gvggel"
<rgoeggel@atos-group.com> wrote:

>jesper kempe schrieb:
>> 
>> Hi
>> I4ve got a problem:
>
>read 
>perldoc -f exec
>perldoc -f system
>perldoc perlfunc        - backtick
>
>Ronald

Actually, the original poster said he was using Win95--these
aren't much help at all in Win32 perl.

To the original poster: Go to www.activestate.com and read through the
Win32 perl FAQ.  There are issues when trying to do process
creation-type things in Perl under Windows.  (For example, there is no
fork/exec combo...But Win32::Process::Create works in the Windows
environment.)




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

Date: Wed, 18 Nov 1998 16:32:08 +0100
From: "Ronald Gvggel" <rgoeggel@atos-group.com>
Subject: Re: file type?
Message-Id: <72uqhi$4mk$3@news.pop-stuttgart.de>

ycliang@hidomain.hinet.net schrieb:
> 
> Hi,
>    Under UNIX, we can get a file's type by using "file" command.
>    How can I get file's type in a Perl script? Need special modules?
>    Thanks a lot!

You can check the existence of file/directory/socket/... by the file
test operators.

see
perldoc perlfunc
expecially -e, -f, -z, ...

If you want to check several attriutes, use stat or _ (IYKWIM)
HTH
Ronald


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

Date: Wed, 18 Nov 1998 17:06:53 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Help needed: How to redirect output from STDOUT into list?
Message-Id: <Pine.GSO.4.02A.9811180906210.27321-100000@user2.teleport.com>

On Wed, 18 Nov 1998, Ron wrote:

> Would I be able to redirect the output of a subroutine (that prints to
> STDOUT) into a list?

Presumably, you mean without re-writing the subroutine. You probably want
a tied filehandle; see the perltie manpage. Hope this helps!

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



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

Date: Wed, 18 Nov 1998 19:36:47 +0200
From: macron.nospam@casema.net (Ron)
Subject: Re: Help needed: How to redirect output from STDOUT into list?
Message-Id: <macron.nospam-1811981936470001@5dyn18.utr.casema.net>

Tom

Thanks. Indeed without rewriting. Better formulated question was: Can I
tie to STDOUT without strange behavior?

Ron

In article <Pine.GSO.4.02A.9811180906210.27321-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:

> On Wed, 18 Nov 1998, Ron wrote:
> 
> > Would I be able to redirect the output of a subroutine (that prints to
> > STDOUT) into a list?
> 
> Presumably, you mean without re-writing the subroutine. You probably want
> a tied filehandle; see the perltie manpage. Hope this helps!
> 
> -- 
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/

-- 
macron(a)casema.net (change (a) to @ when replying; vervang (a) door @ bij antwoorden)


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

Date: Wed, 18 Nov 1998 13:58:21 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Help on use strict please
Message-Id: <365318CD.A8778B1@min.net>

Rusty Williamson wrote:
> 
> I think I
> understand the distinctions between global, my, and local variable
> scope, but Im having trouble implementing it when the use strict pragma
> is enabled.

Yes, you're suffereing from a very common misunderstanding about the
relationships between global and local variables, and between 'my' and 
'local'.

First, truly local variables -- the kind that use strict 'vars' never
complains about -- are introduced with the 'my' keyword.

Any other variables are global.  Doesn't matter if you declare them
'local' or not; they're global.  And use strict 'vars' is very
particular about global variables.  Namely, they must always be
fully qualified, e.g. $main::foo.  Using 'local' does not change this
one bit.  (There is a way to exempt some variables from this requirement,
but that's a secondary topic.)

It is best to think of 'local' as an operator on a variable.
(It "localizes" the value of the variable.)
As it happens, 'local' can only be used on global variables, but
theoretically it could also be used on lexical ('my') variables.
(But don't expect this feature any time soon.)

So you're better off simply declaring all your variables with 'my',
at the top or wherever (before first use, of course).
Then use strict will be happy.  Don't use 'local', because 'local'
indicates global variables, and those must be fully qualified.

hth,
John Porter


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

Date: Wed, 18 Nov 1998 10:49:55 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to get `date` in perl for win32 (newbie)
Message-Id: <MPG.10bcb6aab48b56a198987a@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <3652D8E4.74879F97@houston.Geco-Prakla.slb.com> on Wed, 18 
Nov 1998 08:25:40 -0600, Dave Barnett <barnett@houston.Geco-
Prakla.slb.com> says...
> [courtesy cc to cited author]
> Bill Hogsett wrote:
> > I have a question about strftime formatting.  I want to format the date as
> > "Month Day, Year" with days 1 through 9 shown as single digits.  Is there a
> > way to do it strftime?
> > 
> > Any suggestions?
> 1.  Do it yourself, via localtime.

'strftime' provides the unabbreviated strings for month, weekday, and 
timezone;  'localtime' doesn't.

> 2.  man strftime
> 	%e replaces leading 0 with leading <space>

POSIX.pod (perl 5.005_02) says, "Consult your system's C<strftime()> 
manpage for details about these and the other arguments."  The '%e' 
format specifier isn't in the ANSI/ISO Standard C version of strftime, 
which is what one should rely on.  Can you point me at documentation of 
extended capabilities for Perl?
 
> use POSIX;
> $testdate = 841851694;
> $day = strftime "%B %e, %Y", localtime($testdate);
> print "$day\n";
> 
> Generates:
> September  4, 1996
> 
> $day =~ s/\s+/ /g;
> 
> will cut all spaces down to one space.

  $day =~ s/\s+(?:0(\d)(?!:))?/ $1/g;

will also remove superfluous leading zeros, but leave 'hours' alone.  So 
one can run the above program with the standard '%d' instead of '%e' and 
get the desired result.

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


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

Date: Wed, 18 Nov 1998 12:59:59 -0500
From: Michael D Sohn <msda+@andrew.cmu.edu>
Subject: I/O to parallel port
Message-Id: <0qIkgT200YUg07LHM0@andrew.cmu.edu>


I am doing some reading and writing to the parallel (printer) port on a
PC.  I've been using the Forth language but would prefer to run it in
Perl.  Can someone tell me how to send and read a hexadecimal number to
the parallel port in Perl?

thanks,
Mike




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

Date: 18 Nov 1998 12:41:50 -0500
From: Uri Guttman <uri@fastengines.com>
Subject: Re: Intermediate Perl questions
Message-Id: <saremr0ew4h.fsf@camel.fastserv.com>

>>>>> "MK" == Markus Kaiser <m.kaiser@sz-sb.de> writes:

  MK> while( substr($_, -1, 1) eq "\x11" )

you don't need the last 1, as substr will go to the end of the string by
default.

  MK> {
  MK>     $_ = substr( $_, 0, length($_) -1 );

this is better as:

	substr( $_, 0, 1 ) = '' ;

it removes the first char. i think it is faster as it doesn't copy
anything but it increments the internal pointer. and it is cleaner
reading code too.

  MK> }

  MK> So, the idea of using chop() sounds good.  How would you use it
  MK> (keep the EXPR in while() statement and cut off the trailing char
  MK> w/ chop() or chop() first, examine the resulting char and put it
  MK> back (at the end) if it's not "\x11" ?

i think this would work. i don't fully know what your goal is so it may
not be perfect.

	$foo = $string ;

	while( $foo ) {

		last if substr( $foo, -1 ) ne "\x11" ;

		chop $foo ;
	}

but all that does is trim "\x11"'s from the end of the string. if you
need a loop though do do more work it is fine.

uri


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Wed, 18 Nov 1998 13:40:03 -0500
From: "Ci-Ci Mills" <cici@erols.com>
Subject: Log Munging
Message-Id: <72v467$rh3$1@autumn.news.rcn.net>

I am TRYING to write some custom web server log statistic scripts.  The
first one is supposed the report the top 20 searches per day.  I built a
hash that contains the date, keyword and the count for that keyword.  To get
the top 20 keywords, I need to sort by the count....this is where I am
running into problems.

This is how I am populating the hash:

if ($url =~ m|.*?query\=?(.*?)\&|) {
  $keyhash{$dt} = $1 unless (($keyhash{$dt}) || ($1 eq ""));
  $keyhash{$dt}{$1} = $keyhash{$dt}{$1} + 1;
}

This is how I am printing out the hash:

foreach $datetime (sort keys %keyhash) {
    print "$datetime\n";
    foreach $wd (sort keys %{$keyhash{$datetime}}) {
       print "$title\t$keyhash{$datetime}{$wd}\n";
    }
}

I would greatly appreciate any suggestions.

C. Mills
cici@erols.com






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

Date: Wed, 18 Nov 1998 08:52:27 -0800
From: rdm@cfcl.com (Rich Morin)
Subject: Re: MacPerl + Resource Fork
Message-Id: <rdm-1811980852420001@140.174.42.30>

The MacPerl email list - available via Prime Time Freeware's
MacPerl Pages (http://www.ptf.com/macperl) is a good place
to get answers to arcane MacPerl questions.

-r

-- 
Canta Forda Computer Laboratory       | Prime Time Freeware - quality 
UNIX consulting, training, & writing  | freeware at affordable prices
+1 650-873-7841                       | +1 408-433-9662   -0727 (Fax)
Rich Morin, rdm@cfcl.com              | www.ptf.com, info@ptf.com


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

Date: Wed, 18 Nov 1998 10:02:55 -0800
From: "Josh Burley" <jburley@uci.edu.NOSPAM>
Subject: Re: NT security + IIS + perl
Message-Id: <72v238$8ub@news.service.uci.edu>

Yea, I looked there already. Unfortunately, that particular FAQ deals almost
primarily with a UNIX-based webserver. I'm using IIS. The first thing I
thought of was that the user that perl.exe or perlIs.dll runs as a user that
does not have read permissions... the problem is, it seems to work fine when
anonymous access is allowed. I need people to log in to the section first,
and then be able to run the programs.

I give my user/group "Full Control" to the directory and the files, but it
just won't execute the files.

 .josh

And, hey! I _like_ Python!


Tom Phoenix wrote in message ...
>When you're having trouble with a CGI program in Perl, you should first
>look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
>such problems. It's available on CPAN.
>
>   http://www.perl.com/CPAN/
>   http://www.perl.org/CPAN/
>   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
>   http://www.perl.org/CPAN/doc/manual/html/pod/
>
>Hope this helps!
>
>--
>Tom Phoenix       Perl Training and Hacking       Esperanto
>Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>




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

Date: Wed, 18 Nov 1998 17:18:18 +0100
From: jwl@worldmusic.de (Joergen W. Lang)
Subject: Re: Perl Array Question? Anybody...
Message-Id: <1dioyt6.23037y1y3gha8N@host013-210.seicom.net>

<shazad@my-dejanews.com> wrote:

> Hi perl people....
> 
> Well, I am trying to compare two files which arrive randomly.  Both file have
> the name harry common, but object and rules are different.(example below:)
> 
> Subject: harry object  # File1
> 
> Subject: harry rules   # File2

> WHen I run my perl script, I need to store:
> @myarray=("harry","object");
> 
> After, the second file comes, I need to APPEND rules into @myarray, when it
> matches harry as the common field.
> 
> But each time the second file parses...it overwrites
> @myarray=("harry","object");
> with
> @myarray=("harry","rules");
> 
> How can I APPEND the second file "rules", so that
> @myarray=("harry","object","rule");

Use a hash:

#!/usr/bin/perl -w

while (<DATA>)
{
    @temp = split /\s/, $_;
    # split on whitespace

    shift @temp;
    # get rid of "Subject:" (first element of @temp)

    foreach $element (@temp) {
        $all{ $element }++;
    }
}

# use the elements of @temp as keys to a
# hash %all. Thus each element gets stored
# only once. Little extra magic:
# The value to each key holds a counter for
# the number of times a word is found. 
# Thus you can say:

foreach $key (keys %all) { 
    print "Found $key $all{ $key } time(s).\n"; 
}

# If you really wanted your own array, simply assign the
# keys of %all to it:

# @myarray = keys %all;

__END__
Subject: harry object
Subject: harry rules

> I have tries pop(@mtarray,$a), unshift(@mtarray,$a)...but nothing seems to
> work!!  Anybody!!!
> 
> IN SIMPLE ENGLISH!! How can I restore the context of @myarray each time I run
> my script.

Uhmmm - 
Write the contents of %all to a file. 
Load that file. 
Parse its contents into a hash.
Reuse.

hope this helps,

Joergen
-- 
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"
-------------------------------------------------------------------


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

Date: 18 Nov 1998 13:27:41 -0500
From: ziggy@panix.com (Adam Turoff)
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <72v3it$2cr@panix.com>

Uri Guttman  <uri@sysarch.com> wrote:
>i am not as anti-linux or pro-solaris as you think i am. 

Describing linux users as unprofessional or less professional than
SCO/Solaris/etc. users comes off as a little harsh, I think.

>the bottom line is that i think the average sun user will more likely
>use perl than the average linux user. i think there are many more linux
>boxes out there than suns, but there were almost equal numbers of perl
>users in the survey. that means a higher percentage of sun users use
>perl than linux users. this correlation is the gist of my argument.

Seems like a valid correlation, and more clearly stated.  Either that,
or I'm getting less dense or more caffeinated as the week progresses...

>that is what i have been trying (unsuccessfully) to say. the sun numbers
>were very high and i feel rightly so. sun users know a good tool when we
>see one!

Uh, yeah.  Run http://www.ora.de/german/perl/einperl2/autor.html through
babelfish if you want to talk about sun users knowing a good tool when
they see one.  :-) :-)

Z.



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

Date: 18 Nov 1998 12:19:27 -0500
From: appleo@cybercomm.net (Apple-O)
Subject: Q: bulk-assign associative array?
Message-Id: <72uviv$uq4$1@raven.cybercomm.net>

Could someone explain how to bulk-assign values to 
an associative array? The following would work
but the script would get really big & ugly when
you have something like 300 values to assign:

#!/usr/bin/perl
@arr2{"a"}="1"; # assign values to assoc array
@arr2{"b"}="2";
@arr2{"c"}="4";
print "arr2{\"a\"}:".$arr2{"a"}."\n"; # print value
print "arr2{\"b\"}:".$arr2{"b"}."\n";
print "arr2{\"c\"}:".$arr2{"c"}."\n";

Is there a way to assign values to an assoc array 
all in one line like you can for a regular 1-D array?:

@arrFile = ("a","1","b","2","c","3");
print "arrFile[0]:".$arrFile[0]."\n";
print "arrFile[1]:".$arrFile[1]."\n";
print "arrFile[2]:".$arrFile[2]."\n";
print "arrFile[3]:".$arrFile[3]."\n";
print "arrFile[4]:".$arrFile[4]."\n";
print "arrFile[5]:".$arrFile[5]."\n";

I thought this might somehow be referencable
as an assoc array, like so, but it didn't work:

@arr2 = {"a","1","b","2","c","3"};
print "arr2{\"a\"}:".$arr2{"a"}."\n";
print "arr2{\"b\"}:".$arr2{"b"}."\n";
print "arr2{\"c\"}:".$arr2{"c"}."\n";

Any help would be most appreciated. 



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

Date: 18 Nov 1998 12:47:19 -0500
From: appleo@cybercomm.net (Apple-O)
Subject: Re: Q: bulk-assign associative array?
Message-Id: <72v177$12t$1@raven.cybercomm.net>

Here is the answer (I was using the wrong array prefix (should be % for assoc array) and you need to use parentesis not brackets or curly braces when assigning values:

%arr2 = ("a","1st","b","2nd","c","3rd");
print "arr2{\"a\"}:".$arr2{"a"}."\n";
print "arr2{\"b\"}:".$arr2{"b"}."\n";
print "arr2{\"c\"}:".$arr2{"c"}."\n";


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

Date: Wed, 18 Nov 1998 18:29:32 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Q: bulk-assign associative array?
Message-Id: <F2MrD9.224@world.std.com>

appleo@cybercomm.net (Apple-O) writes:

>Could someone explain how to bulk-assign values to 
>an associative array? 

>@arr2{"a"}="1"; # assign values to assoc array

I think you mean "$arr2{a} = 1". You're making a hash slice of one
element. (See the perldata man page for a deeper explaination.)

[stuff deleted]
>Is there a way to assign values to an assoc array 
>all in one line like you can for a regular 1-D array?:

>@arrFile = ("a","1","b","2","c","3");
>@arr2 = {"a","1","b","2","c","3"};

You are so close to your solution that it is not even funny!

%arrFile = ("a","1","b","2","c","3");

Hashes, when used in a list context, flatten themselves out into a
list of key/value pairs. Again, a read of the perldata man page may be
helpful.

-- 
Andrew Langmead


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

Date: Wed, 18 Nov 1998 12:00:52 -0500
From: "Kumar Sundaram" <softsci@eagle.ca>
Subject: required fields
Message-Id: <72uuld$oku$1@mur2.odyssey.on.ca>

I want to able to make some required fields for the user in the html file
with a comma to separate them.
for eg:
<input type="hidden" name="require" value="field1,field2,field3">
Can someone provide me the part  of the cgi/perl script to do this!!
Thanks in advance!!
Kumar




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

Date: 18 Nov 1998 18:09:28 GMT
From: Burt Adsit <burt.adsit@gte.net>
Subject: Re: required fields
Message-Id: <72v2go$8el$0@205.138.137.53>

Get with the program Kumar. Send money, get mods.

Kumar Sundaram wrote:
> 
> I want to able to make some required fields for the user in the html file
> with a comma to separate them.
> for eg:
> <input type="hidden" name="require" value="field1,field2,field3">
> Can someone provide me the part  of the cgi/perl script to do this!!
> Thanks in advance!!
> Kumar

-- 
Burt Adsit
Earthenware
http://www.featurefarm.com
lat n43.10' lon w86.2'


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

Date: Wed, 18 Nov 1998 18:21:54 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Scope question for Perl
Message-Id: <F2Mr0I.Euw@world.std.com>

xaqtnr@my-dejanews.com writes:

>Is there any documentation that will explain in detail how Perl handles the
>variables in relation to their scope and persistence. Or maybe someone can
>give me a general run-down. I know you can use local/my to declare variables,
>but how does this affect their scope? 

I think the documentation you want is the sections on local() and my()
in the perlfunc man page, and the "Private Variables via my()" in the
perlsub man page.

Basically, my() creates lexical scopes like you are familiar with C or
C++. When my() is used on a variable inside of a block, it scope is
until the end of that block (including any blocks contained within the
it.) When outside of a block, its scope is the entire file. (Notice
this the file, not the package.)

The function local() on the otherhand creates dynamically scoped
variables. It hides any global variable with the same name and
replaces it with a new one that will remain globally visible until the
interpreter has finished executing the current block. Once the block
has finished executing, the former global variable is restored.


>For example in C:
[stuff deleted]
>  cout << x;

That's not C!!!
-- 
Andrew Langmead


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

Date: Wed, 18 Nov 1998 16:17:36 +0100
From: "Ronald Gvggel" <rgoeggel@atos-group.com>
Subject: Re: substitute
Message-Id: <72uood$3mk$1@news.pop-stuttgart.de>

Todd Kempf schrieb:
> 
> Hi,
> 
> I'm trying to change a list of characters into their hex counterparts.
> For example, to make a valid filename I have tried something like:
> 
> $vfn =~ s/\*\?\\\//%[A..F]/g;
> 
> and so on. I know, the above is just chicken scratch of what I've been
> trying to do. So the question is, how does one take a string such as
> "f*len?me" and turn it into something such as "f%3Elen%17me"? Any help
> is appreciated.
> 
> Todd

In HTML::Entities there ist a function encode_entities that does
something similar.


Ronald


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

Date: 18 Nov 1998 18:53:17 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Two-Part RE question
Message-Id: <72v52t$5ab$1@news.cyberhighway.net>

[Posted and mailed]

In article <365244A5.33609DA8@hotmail.com>,
	sara starre <nospam.gear4u@hotmail.com> writes:
> OK, this is a two-part question. The first part is only for the perl
> newsgroup hoseheads who flame everyone who asks a question. Here is your
> part, put your might brain to work on it and post your solution to
> alt.whocares:

Great idea...alienate the most knowledgeable members of the group before
you even start.  And your "special" RE isn't even syntactically correct.

> I wish to extract a string between two different characters from a
> larger
> string. For example, I want to extract everything between "[" and "]",
> such as extract man from cat[man]dog.

Okay...
You didn't specify whether the stuff between these can be nothing.
If it can, then:
$var = "cat[man]dog";
$var =~ s/^.*?\[(.*?)\].*?$/$1/;
print $var;

Otherwise, change the RE to s/^.*?\[(.*+)\].*?$/$1/

Or, let's be a little more creative, and allow for nested []'s.
Here's one that takes a string from STDIN, and prints each level of
nested brackets.  So, entering "Just [Another [Perl] Hacker]" would
output:
Another [Perl] Hacker
Perl

Here's the code for that:
while(<>){
        print while(s/^.*?\[(.*?)\](?!.*?\]).*$/$1/)
}

Notice the ultra-fancy zero-width negative lookahead assertion.  They
don't cover incredibly complex stuff like this until well into the
second chapter of the blue camel.

> Now, I brute (in my case brute-ette?) forced a solution:

Well, your solution doesn't appeal to my aesthetic sensibilities, but
TMTOWTDI.

> I read my Tom C book- I think this is a little advanced for that text.

I seriously doubt it...this is a relatively simple regular expression
problem, once you recognize it as being a RE problem.

Next time, consider just getting straight to the problem at hand, and
skip the insulting part.

-- 
Erik Nielsen, Cyberhighway Internet Services NOC
I was trying not to mention backtracking.  Which, of course, means that
yours is "righter" than mine, in a theoretical sense.
             -- Larry Wall in <199710211624.JAA17833@wall.org>


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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