[16663] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4075 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 21 00:06:05 2000

Date: Sun, 20 Aug 2000 21:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966830710-v9-i4075@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 20 Aug 2000     Volume: 9 Number: 4075

Today's topics:
        ANNOUNCE: Parse::RecDescent 1.79 (Damian Conway)
    Re: DBI has me stumped... maybe OO problem? <dale@emmons.dontspamme.com>
        driver <troyr@vicnet.net.au>
    Re: driver <troyr@vicnet.net.au>
    Re: Forking sub{}'s and selective SIG{CHLD} responses <unixgod@jacksonville.net>
    Re: Forking sub{}'s and selective SIG{CHLD} responses (Martien Verbruggen)
    Re: Getting rid of extra spaces and returns <aqumsieh@hyperchip.com>
    Re: Getting rid of extra spaces and returns <bob3434@excite.com>
    Re: Help! Perl wont even run from DOS prompt. (Malcolm Dew-Jones)
        HELP: TEXTAREA field and newlines <perryw@newsguy.com>
    Re: HELP: TEXTAREA field and newlines <mauldin@netstorm.net>
    Re: HELP: TEXTAREA field and newlines <timewarp@shentel.net>
        How to know what perl modules have been installed in my <weiguo@263.net>
        join on two arrays <pilsl@goldfisch.atat.at>
    Re: join on two arrays <philipg@atl.mediaone.net>
    Re: join on two arrays <tina@streetmail.com>
    Re: join on two arrays <mauldin@netstorm.net>
    Re: join on two arrays <tina@streetmail.com>
    Re: join on two arrays (Martien Verbruggen)
    Re: Need some quick help.. (Malcolm Dew-Jones)
    Re: Perl - Blinking Text (Abigail)
    Re: Perl - Blinking Text (Abigail)
    Re: Perl jobs? <gbrunt@rocketmail.com>
    Re: perl's -T switch. (Abigail)
    Re: perl's -T switch. (Abigail)
    Re: PERL/TK AND WIDGETS <aqumsieh@hyperchip.com>
    Re: Script skipping a section!?!? <musicfan@punitiveart.com>
    Re: Script skipping a section!?!? <mauldin@netstorm.net>
    Re: Script skipping a section!?!? <philipg@atl.mediaone.net>
        Setup suid <brianlk@pacific.net.hk>
    Re: Wildcards in DOS 'dir' command (Malcolm Dew-Jones)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 21 Aug 2000 01:29:07 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Parse::RecDescent 1.79
Message-Id: <sq1773rv87v65@corp.supernews.com>
Keywords: perl, module, release

==============================================================================
                 Release of version 1.79 of Parse::RecDescent
==============================================================================


NAME

    Parse::RecDescent - generate recursive-descent parsers


DESCRIPTION

    RecDescent incrementally generates top-down recursive-descent text
    parsers from simple yacc-like grammar specifications. It provides:

        * Regular expressions or literal strings as terminals (tokens),

        * Multiple (non-contiguous) productions for any rule,

        * Repeated, optional and alternate subrules within productions,

	* Late-bound (run-time dispatched) subrules

        * Full access to Perl within actions specified as part of the grammar,

        * Simple automated error reporting during parser generation and parsing,

        * The ability to commit to, uncommit to, or reject particular
          productions during a parse,

        * Incremental extension of the parsing grammar (even during a parse),

	* Precompilation of parser objects,

	* User-definable reduce-reduce conflict resolution via
	  "scoring" of matching productions.

    See the file "RecDescent.pod" for excruciating detail on all of this.


LIMITATIONS

    * There's no support for parsing directly from an input stream.

    * The generator doesn't handle left-recursion.


PREREQUISITES

    Parse::RecDescent requires Text::Balanced, which is included in the
    distribution.


INSTALLATION

    It's all pure Perl, so just put the .pm files in their appropriate
    local Perl subdirectories.


CHANGES AND FUTURE DEVELOPMENT

    This readme refers to versions 1.XX.
    For details of changes, refer to the file Changes.

    Version 2.00 will provide a cleaner interface and better
    parsing performance.


AUTHOR

    Damian Conway (damian@csse.monash.edu.au)


COPYRIGHT

     Copyright (c) 1997-2000, Damian Conway. All Rights Reserved.
     This module is free software. It may be used, redistributed
     and/or modified under the terms of the Perl Artistic License
          (see http://www.perl.com/perl/misc/Artistic.html)


==============================================================================

CHANGES IN VERSION 1.79


	- Pod tweak (thanks Abigail)

	- Documented need to use do{..} within some <reject:...>
	  directives (thanks Paul)

	- Added Save method

	- Fixed bug that was preventing precompiled parsers being 
	  subsequently extended (thanks Jeff).

	- Changed keys used by %item. Now uses "named positionals"
	  rather that simple positionals for non-subrule items
	  (see documentation)

	- Added trimmer for surrounding whitespace in matchrules.

	- Squelched bug in (not) handling invalid directives (thanks John)


==============================================================================

AVAILABILITY

Parse::RecDescent has been uploaded to the CPAN
and is also available from:

	http://www.csse.monash.edu.au/~damian/CPAN/Parse-RecDescent.tar.gz

==============================================================================




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

Date: Sun, 20 Aug 2000 20:11:10 -0500
From: "Dale Emmons" <dale@emmons.dontspamme.com>
Subject: Re: DBI has me stumped... maybe OO problem?
Message-Id: <sq103sk987v152@corp.supernews.com>

oh my god... I can't believe I'd do something this dumb.

While looking through the code for the 176th time, I noticed that I had a
$dbh->disconnect; statement within the each day loop which was killing my db
object.

Now I feel stupid.

Thanks much for your trying to help me, and sorry about bothering you with
something so stupid!

-Dale




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

Date: Mon, 21 Aug 2000 13:01:37 +1000
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: driver
Message-Id: <o_0o5.3623$Vb.95618@ozemail.com.au>

does anyone know how i would connect a perl script to MSQL Database

Is it using DBD::mSQL or DBD::ODBC

where can i download these drivers from....

if they are the ones?

Thanks

--
----------------------------------------------------------------------------
----------------
Troy Rasiah
Database/Web Developer
Vicnet
troyr@vicnet.net.au
----------------------------------------------------------------------------
----------------




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

Date: Mon, 21 Aug 2000 13:05:15 +1000
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: Re: driver
Message-Id: <O11o5.3628$Vb.95602@ozemail.com.au>

Microsoft SQL Server even

--
----------------------------------------------------------------------------
----------------
Troy Rasiah
Database/Web Developer
Vicnet
troyr@vicnet.net.au
----------------------------------------------------------------------------
----------------
"Troy Rasiah" <troyr@vicnet.net.au> wrote in message news:...
> does anyone know how i would connect a perl script to MSQL Database
>
> Is it using DBD::mSQL or DBD::ODBC
>
> where can i download these drivers from....
>
> if they are the ones?
>
> Thanks
>
> --
> --------------------------------------------------------------------------
--
> ----------------
> Troy Rasiah
> Database/Web Developer
> Vicnet
> troyr@vicnet.net.au
> --------------------------------------------------------------------------
--
> ----------------
>
>




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

Date: Mon, 21 Aug 2000 01:43:19 GMT
From: "Mark Neill" <unixgod@jacksonville.net>
Subject: Re: Forking sub{}'s and selective SIG{CHLD} responses
Message-Id: <XO%n5.36302$56.149153@typhoon.jacksonville.mediaone.net>

I'll take both your posts at once....and sorry about the mail addresses,
they all work, I'm still working out all the kinks with my new and old
addresses.

You're right, it's not _really_ a perl problem, but I'm dealing with the
perl implementation, so rather than learn everything right now....

I've tried localizing the SIG, that doesn't seem to work right.

my $SIG{CHLD} = \&Callback();

I've also tried moving the update code to inside the fork, but the reference
to the Tk MainWindow gets clobbered in the fork and the widget refreshes
complain about bad X drawables - though I don't know why, the object is set
up as a global variable in the very beginning of the code and should
propagate through the fork, unless it's using relative memory addressing -
it shouldn't be though.

The update from the SIG works correctly as currently programmed - it's just
programmed wrong :)  The problem is, there are various system() and piped
open() calls that also exec children, and trip the handler.  Not a big deal,
but it's overhead I'd rather not have.

Perhaps push()ing and pop()ing an array of pid's for the SIG handler to
check against?


"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn8q0ndf.l5b.mgjv@martien.heliotrope.home...
> On Sat, 19 Aug 2000 02:19:52 GMT,
> Mark Neill <unixgod@jacksonville.net> wrote:
> >
> > What do I need to do to _selectively_ trap and respond to SIG{CHLD}?
>
> Just had another thought about this, although I don't know whether it
> will work:
>
> Have you tried setting $SIG{CHLD} globally to something else than
> locally? I am not sure whether that works at all, or whether the signal
> handlers in perl are installed per process. You could give that a try at
> least.
>
> local $SIG{CHLD} = \&foo;
>
> Martien
>
> PS. I really doubt it will work, but it would be interesting to see.
> Would be nice of you to report back to tell us whether or not this
> worked.
> --
> Martien Verbruggen              |
> Interactive Media Division      | Useful Statistic: 75% of the people
> Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
> NSW, Australia                  |




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

Date: 21 Aug 2000 03:00:16 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Forking sub{}'s and selective SIG{CHLD} responses
Message-Id: <slrn8q15gh.mss.mgjv@martien.heliotrope.home>

[reorganised order of post to respect the normal arrow of time]

On Mon, 21 Aug 2000 01:43:19 GMT,
	Mark Neill <unixgod@jacksonville.net> wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn8q0ndf.l5b.mgjv@martien.heliotrope.home...
> > On Sat, 19 Aug 2000 02:19:52 GMT,
> > Mark Neill <unixgod@jacksonville.net> wrote:
> > >
> > > What do I need to do to _selectively_ trap and respond to SIG{CHLD}?
> >
> > Have you tried setting $SIG{CHLD} globally to something else than
> > locally? I am not sure whether that works at all, or whether the signal
> > handlers in perl are installed per process. You could give that a try at
> > least.
> >
> > local $SIG{CHLD} = \&foo;
>
> I'll take both your posts at once....and sorry about the mail addresses,
> they all work, I'm still working out all the kinks with my new and old
> addresses.
> 
> You're right, it's not _really_ a perl problem, but I'm dealing with the
> perl implementation, so rather than learn everything right now....

[this was in response to my other post, suggesting comp.unix.programmer
as a good source for information on this]

I meant more that the problem is a generic unix programming problem,
regardless of the language. People in comp.unix.programmer might be able
to give you the general technique to do this sort of thing. I didn't
mean that you needed to learn a new language :). It's just more likley
that you find a few good experienced Unix programmers in that group. I
don't think that your question was offtopic for clp.misc though, since
there may be Perl specific answers.

> I've tried localizing the SIG, that doesn't seem to work right.
> 
> my $SIG{CHLD} = \&Callback();

Bummer. I was afraid of that.

> I've also tried moving the update code to inside the fork, but the reference
> to the Tk MainWindow gets clobbered in the fork and the widget refreshes
> complain about bad X drawables - though I don't know why, the object is set
> up as a global variable in the very beginning of the code and should
> propagate through the fork, unless it's using relative memory addressing -
> it shouldn't be though.

Ok... So you are trying to do something to your main window from within
the fork? I don't know how Tk communicates between process and windows,
but it is very well possible that only the process that creates the
window can work with it. In that case you have no choice but to use
threads, or set up IPC between parent and child.

> The update from the SIG works correctly as currently programmed - it's just
> programmed wrong :)  The problem is, there are various system() and piped
> open() calls that also exec children, and trip the handler.  Not a big deal,
> but it's overhead I'd rather not have.
> 
> Perhaps push()ing and pop()ing an array of pid's for the SIG handler to
> check against?

If you do a waitpid, or just a wait, you could do that, yes. It's
a little overhead, but it would probably be worth it. I'd probably use a
has, for faster lookup, but other than that...

Something like (adapted from some code fragments I had lying around):

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

my $waitedpid = 0;
my %process_these_kids;

sub REAPER
{
	$waitedpid = wait;
	$SIG{CHLD} = \&REAPER; # Grrrrr to SYSV
	logmsg("Reaped $waitedpid" . ($? ? " with exit $?" : ''));
	if (exists $process_these_kids{$waitedpid})
	{
		logmsg("Processing $waitedpid");
		delete $process_these_kids{$waitedpid};
	}
}

$SIG{CHLD} = \&REAPER;

for (my $i = 0; $i < 10; $i++)
{
	spawn(\&childproc, $i);
}

# Wait for all the children to finish
wait;

# Do post processing here
exit 0;

# Child procedure wrapper
sub childproc
{
	# This is what the children will actually do
	return 0;
}

# This is how we spawn
sub spawn 
{
	my $coderef = shift;

	unless ($coderef && ref($coderef) eq 'CODE')
	{
		confess "USAGE: spawn CODEREF";
	}

	my $pid;

	if (!defined($pid = fork))
	{
		logmsg("cannot fork: $!");
		return;
	}
	elsif ($pid)
	{
		# Only process even pids. 
		$process_these_kids{$pid}++ unless $pid%2;
		logmsg("Spawned child with pid $pid");
		return; # Parent
	}
	# else I'm the child, go ahead
	exit &$coderef( @_ );
}

# Routine to log some messages to stdout
sub logmsg
{
	print "$0 $$: @_ at ", scalar localtime, "\n";
}

The only problem you have here is that there is a race condition. When
adding the pid to the hash, you might already be too late. The child may
have exited and the signal may have been caught. If your children are
guaranteed to live for a while, you can probably ignore that
possibility, but it's there.

Of course, you probably don't want to wait (the one just before the exit
0, you will need the one in the SIG handler) and block your main process,
but the same sort of idea can probably be used in your application.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd.   | Then things get worse.
NSW, Australia                  | 


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

Date: Mon, 21 Aug 2000 01:39:06 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Getting rid of extra spaces and returns
Message-Id: <7avgwvie9u.fsf@merlin.hyperchip.com>


Unknown <bob3434@excite.com> writes:

> Basically I want to be able to parse the data so that addional spaces
> between words are eliminated and additional returns (more than one) are
> eliminated.  Any suggestions would be appreciated.

You can use the /s modifier for tr///:

	tr/\n //s;

--Ala


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

Date: Sun, 20 Aug 2000 20:23:28 -0700
From: Bob Tenor <bob3434@excite.com>
Subject: Re: Getting rid of extra spaces and returns
Message-Id: <200820002023288805%bob3434@excite.com>


Thanks for the reply - this got rid of extra spaces but it did not get
rid of extra returns

$name = $formdata{'name'};
$name =~ tr/\n //s;

Is their another function that I need to implement?

best,
Tim


In article <7avgwvie9u.fsf@merlin.hyperchip.com>, Ala Qumsieh
<aqumsieh@hyperchip.com> wrote:

> Unknown <bob3434@excite.com> writes:
> 
> > Basically I want to be able to parse the data so that addional spaces
> > between words are eliminated and additional returns (more than one) are
> > eliminated.  Any suggestions would be appreciated.
> 
> You can use the /s modifier for tr///:
> 
>         tr/\n //s;
> 
> --Ala


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

Date: 20 Aug 2000 20:14:19 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Help! Perl wont even run from DOS prompt.
Message-Id: <39a09e8b@news.victoria.tc.ca>

Mike (xdesmond@hotmail.com) wrote:
: - when i type SET at the dos prompt it says my PATH is
: C:\PERL\5.00502\BIN\MSWIN32-x86-OBJECT;
: C:\PERL\5.00502\BIN;

: this doesnt look right to me considering i installed
: active perl release 5.6.0.616. if anyone thinks this
: might be the cause of my problem, how can i change the
: path?

Well this is really a DOS/windows question, but...


in windows 95 (I assume 98 is the same) you can set your path in
autoexec.bat


If you don't have an autoexec.bat then create one using EDIT or notepad. 


You can use the current path that you see at the dos prompt as the basis
for the PATH statement in autoexec.bat if it doesn't already have the
PATH.

Edit the path to include the correct directory.  You can find the
correct directory from the dos command line by typing (e.g.)

	C:> dir /s/b perl.exe

The dir command should find perl and display its path.  Use that path as
its path for autoexec.bat.  (Leave off the perl.exe part of course). 

There may be another directory that should also be in the path, but two
DOSish systems that I use only have one perl related path (...\BIN). 


You should end up with a line that looks something like the following in
your autoexec.bat

	PATH C:\PERL\5.xxx\BIN;C:\WINDOWS;C:\WINDOWS\COMMAND


Now reboot and perl should be in the path.



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

Date: Sun, 20 Aug 2000 18:10:48 -0800
From: Perry Winkle <perryw@newsguy.com>
Subject: HELP: TEXTAREA field and newlines
Message-Id: <200820001810480095%perryw@newsguy.com>

I've got a TEXTAREA field into which users may unfortunately type
newlines. I need to get rid of the newlines so that I can get
everything onto a single line.

For some reaso, this is not working for me:

$textblock =~ s/\n\n/<P>/;
$textblock =~ s/\n/<BR>/;

$textblock (VALUE) still shows up as:

<INPUT TYPE=hidden NAME=bio_info VALUE="Here is line 1
<BR>
<BR>Here is line 2">

How can I get this on one line? I've tried the /m and /s modifiers, but
I'm not really sure how to set up the expression.

Thanks,
Nigel


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

Date: Mon, 21 Aug 2000 02:45:34 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: HELP: TEXTAREA field and newlines
Message-Id: <39A0971C.9EFAD6F5@netstorm.net>

Perry Winkle wrote:
> 
> I've got a TEXTAREA field into which users may unfortunately type
> newlines. I need to get rid of the newlines so that I can get
> everything onto a single line.
> 
> For some reaso, this is not working for me:
> 
> $textblock =~ s/\n\n/<P>/;
> $textblock =~ s/\n/<BR>/;
> 
> $textblock (VALUE) still shows up as:
> 
> <INPUT TYPE=hidden NAME=bio_info VALUE="Here is line 1
> <BR>
> <BR>Here is line 2">
> 
> How can I get this on one line? I've tried the /m and /s modifiers, but
> I'm not really sure how to set up the expression.

I don't know what your data looks like, but that should work as long as
you use the /g modifier to catch them all:

$textblock =~ s/\n\n/<P>/g;
$textblock =~ s/\n/<BR>/g;

You could also do it in one step:

$textblock = "Here is some information that I entered in a textbox
but then I scrolled off the screen and decided to enter some
newlines so that I could read what I've written.

Now I want to start a new idea so I enter two newlines to
really set it off from the previous paragraph";

$textblock =~ s/(\n)(\1?)/$2?"<p>":"<br>"/eg;
print $textblock;  # all on one line

-- Jim


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

Date: Sun, 20 Aug 2000 23:47:39 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: HELP: TEXTAREA field and newlines
Message-Id: <39A0A65B.EBCFC80C@shentel.net>

Code from a site I recently made to do just this -

 ## Remove the line returns and carriage feeds from the description and
replace them with '<br>'
 $cr = chr(13).chr(10);
 $Description =~ s/$cr/\<br\>/g;

Trust me - it works.

Albert Dewey

Perry Winkle wrote:

> I've got a TEXTAREA field into which users may unfortunately type
> newlines. I need to get rid of the newlines so that I can get
> everything onto a single line.
>
> For some reaso, this is not working for me:
>
> $textblock =~ s/\n\n/<P>/;
> $textblock =~ s/\n/<BR>/;
>
> $textblock (VALUE) still shows up as:
>
> <INPUT TYPE=hidden NAME=bio_info VALUE="Here is line 1
> <BR>
> <BR>Here is line 2">
>
> How can I get this on one line? I've tried the /m and /s modifiers, but
> I'm not really sure how to set up the expression.
>
> Thanks,
> Nigel



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

Date: Mon, 21 Aug 2000 10:54:53 +0800
From: "weiguo" <weiguo@263.net>
Subject: How to know what perl modules have been installed in my system?
Message-Id: <8nq5lj$1nim$1@news.cz.js.cn>






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

Date: Mon, 21 Aug 2000 01:19:21 GMT
From: peter pilsl <pilsl@goldfisch.atat.at>
Subject: join on two arrays
Message-Id: <MPG.140aa21f3695b50398984d@news.chello.at>


what I have:
@fruits=('apple','cherry');
@color=('green','red');

And I want the following output:

'The apple is green. The cherry is red'

Possible without an explicit loop ?

thanks,
peter


-- 
pilsl@
goldfisch.at


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

Date: Mon, 21 Aug 2000 01:30:39 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: join on two arrays
Message-Id: <3D%n5.53242$rd1.9909300@typhoon-news1.southeast.rr.com>

> @fruits=('apple','cherry');
> @color=('green','red');
>
> And I want the following output:
>
> 'The apple is green. The cherry is red'
>
> Possible without an explicit loop ?
>

print join( ". ", map { "The $fruits[$_] is $color[$_]" } (0..$#fruits));

HTH,
Philip




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

Date: 21 Aug 2000 01:50:20 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: join on two arrays
Message-Id: <8nq1ss$95jp3$14@ID-24002.news.cis.dfn.de>

hi,
peter pilsl <pilsl@goldfisch.atat.at> wrote:

> @fruits=('apple','cherry');
> @color=('green','red');

> And I want the following output:
> 'The apple is green. The cherry is red'
> Possible without an explicit loop ?

print map {"The $_ is $color[$c++]. "} @fruits;

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Mon, 21 Aug 2000 02:17:40 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: join on two arrays
Message-Id: <39A09092.CC27B2EF@netstorm.net>

Philip Garrett wrote:
> 
> > @fruits=('apple','cherry');
> > @color=('green','red');
> >
> > And I want the following output:
> >
> > 'The apple is green. The cherry is red'
> >
> > Possible without an explicit loop ?
> >
> 
> print join( ". ", map { "The $fruits[$_] is $color[$_]" } (0..$#fruits));


No need to join, even.

  print map "The $fruits[$_] is $color[$_]. ", 0..$#fruits;

-- Jim


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

Date: 21 Aug 2000 03:00:13 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: join on two arrays
Message-Id: <8nq5vt$95jp3$15@ID-24002.news.cis.dfn.de>

hi,
Jim Mauldin <mauldin@netstorm.net> wrote:
> Philip Garrett wrote:
>> 
>> > @fruits=('apple','cherry');
>> > @color=('green','red');
>> > And I want the following output:
>> >
>> > 'The apple is green. The cherry is red'
>> 
>> print join( ". ", map { "The $fruits[$_] is $color[$_]" } (0..$#fruits));
> No need to join, even.

>   print map "The $fruits[$_] is $color[$_]. ", 0..$#fruits;

well, if you look at what the output should be,
join would actually be the more correct way. =)
but i didn't use it, either, because I assumed
there should be a dot at every end of senetence.

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: 21 Aug 2000 03:00:19 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: join on two arrays
Message-Id: <slrn8q16ec.mss.mgjv@martien.heliotrope.home>

On Mon, 21 Aug 2000 01:19:21 GMT,
	peter pilsl <pilsl@goldfisch.atat.at> wrote:
> 
> what I have:
> @fruits=('apple','cherry');
> @color=('green','red');
> 
> And I want the following output:
> 
> 'The apple is green. The cherry is red'
> 
> Possible without an explicit loop ?

Yes... With a map. But to call that 'not an explicit loop' is stretching
it a bit. Why do you want to avoid an 'explicit' loop anyway? Or do you
mean without a loop that involves a counter? In that case even map
becomes hard. Maybe your data structure is just not what you need...

@colored_fruits{@fruits} = @color;
print "The $_ is $colored_fruits{$_}\n" for (keys %colored_fruits);

or if you care about order

print "The $_ is $colored_fruits{$_}\n" for (@fruits);

The thingy above is called a hash slice, and information on that can be
found in the perldata documentation:

# perldoc perldata

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.   | cynical. It's perfectly easy to be
NSW, Australia                  | cynical.


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

Date: 20 Aug 2000 20:48:30 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Need some quick help..
Message-Id: <39a0a68e@news.victoria.tc.ca>

Abigail (abigail@foad.org) wrote:
: DS (snakeman@kc.rr.com) wrote on MMDXLIV September MCMXCIII in
: <URL:news:6ijn5.2564$H5.32745@typhoon.kc.rr.com>:
: ^^ Hello-
: ^^    I am wanting to print the last modified date to the html page. For
: ^^ example using
: ^^     <!--#flastmod file="default.html" -->
: ^^ 
: ^^ but I don't want to edit it everytime I add it to a page. I know that
: ^^ DOCUMENT_NAME will return the current filename but it wont work like this :
: ^^ 
: ^^ <!--#flastmod file="DOCUMENT_NAME" -->
: ^^ 
: ^^ due to the fact it is looking for an actual document called "DOCUMENT_NAME".


: And your Perl issue is..... ?

Well it's clear that his(?) current setup doesn't do what he needs, so
surely its obvious that he needs help understanding how perl will solve
his problems. 


	something like this (totally untested, time formatting and
	template calls are bogus, look up relevent documentation to find
	correct calls).  There are various template packages available
	these days.


#!perl
use CGI qw/:standard/;

$filename = 'default.html';

if ( my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
         $atime,$mtime,$ctime,$blksize,$blocks) 
           = stat($filename)
   )
{
	$last_mod_str = some_time_format_function($mtime);
}else
{
	$last_mod_str = 'Unknown';
}


use YourFavouriteTemplatePackage;

print header;	# HTTP headers, function from CGI


# merge template with variable data
TemplatePrint($filename,$last_mod_str);



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

Date: 21 Aug 2000 01:24:49 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl - Blinking Text
Message-Id: <slrn8q115q.tj3.abigail@alexandra.foad.org>

BUCK NAKED1 (dennis100@webtv.net) wrote on MMDXLII September MCMXCIII in
<URL:news:15349-399A299A-42@storefull-242.iap.bryant.webtv.net>:
%% Oh NO! I accidentally hit "Send" instead of "Remove HTML". Sorry, again.


Get a real newsreader then.



Abigail
-- 
 :;$:=~s:
-:;another Perl Hacker
 :;chop
$:;$:=~y:;::d;print+Just.$:


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

Date: 21 Aug 2000 01:27:41 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl - Blinking Text
Message-Id: <slrn8q11b6.tj3.abigail@alexandra.foad.org>

Drew Simonis (care227@attglobal.net) wrote on MMDXLII September MCMXCIII
in <URL:news:399A9828.B17DE3FD@attglobal.net>:
 .. Russ Jones wrote:
 .. > 
 .. > Dear Einstein:
 .. > 
 .. > Stop including embedded web pages in your posts. You cause my mail
 .. > reader to try and display god knows what kind of a URL that's
 .. > somewhere on the other side of the proxy server. I'm trying to keep a
 .. > low profile in the audit logs.


That's silly. If you're using a newsreader that's automatically
downloading all embedded URLs, and you get in problem with that, it's
your own fault. Don't use such a newsreader then.



Abigail
-- 
perl -e 'for (s??4a75737420616e6f74686572205065726c204861636b65720as?;??;??) 
             {s?(..)s\??qq \?print chr 0x$1 and q ss\??excess}'


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

Date: Mon, 21 Aug 2000 02:28:05 GMT
From: "JoBlo" <gbrunt@rocketmail.com>
Subject: Re: Perl jobs?
Message-Id: <Vs0o5.171285$Gh.3035877@news20.bellglobal.com>

Wow you seem to be a step in front of me. I am also teaching myself Perl and
shall also be starting a Java course through Athabasca University.  How do
you like it so far is it what you expected, do you easily see some good
applications in the real world for Java?

peter <peterp100@hotmail.com> wrote in message
news:kre4os899d2g278fl1i22bfeoj59ipmg0h@4ax.com...
> I'm teaching myself perl and I'm taking a Java class this fall. But,
> I'm thinking about dropping the Java class and concentrating on Perl.
> Are there any jobs out there for perl programmers?  When I look in the
> paper everything says "Java and C ++" ???




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

Date: 21 Aug 2000 01:22:15 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perl's -T switch.
Message-Id: <slrn8q110v.tj3.abigail@alexandra.foad.org>

Jordan Katz (katz@underlevel.net) wrote on MMDXLIV September MCMXCIII in
<URL:news:m3n1iaz5kf.fsf@underlevel.underlevel.net>:
[] Hi,
[] 
[] I have the following function to retrieve the source of a given URL:
[] 
[]   #!/usr/bin/perl -w
[] 
[]   use LWP::UserAgent;
[]   use HTTP::Request;
[]   use strict;
[] 
[]   sub get_url {
[]       my $url = shift;
[]       my $ua  = new LWP::UserAgent;
[]       my $req = new HTTP::Request 'GET', $url;
[]       $ua->timeout(30);
[]       my $src = $ua->request($req);
[] 
[]       return $src->content unless (!$src->is_success);
[]       return 0;
[]   }
[] 
[] Which works fine, but if I add Perl's -T switch, which adds extra
[] checking as I understand from perlrun, get_url fails everytime.  I was
[] hoping someone could clarify why.


I find that hard to believe. -T does some runtime checks, and your
program does exactly *NOTHING* at runtime.

I expect there's more to this program, but unless you tell us, we'll
never know.



Abigail
-- 
:$:=~s:$":Just$&another$&:;$:=~s:
:Perl$"Hacker$&:;chop$:;print$:#:


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

Date: 21 Aug 2000 01:23:25 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perl's -T switch.
Message-Id: <slrn8q1136.tj3.abigail@alexandra.foad.org>

Drew Simonis (care227@attglobal.net) wrote on MMDXLIV September MCMXCIII
in <URL:news:399DAB51.8D5DF8A0@attglobal.net>:
][ Jordan Katz wrote:
][ > 
][ >       my $url = shift;
][ 
][ Tainted.

Probably. But not because of this statement. In the posted program, the
above line never gets executed.



Abigail
-- 
BEGIN {my $x = "Knuth heals rare project\n";
       $^H {integer} = sub {my $y = shift; $_ = substr $x => $y & 0x1F, 1;
       $y > 32 ? uc : lc}; $^H = hex join "" => 2, 1, 1, 0, 0}
print 52,2,10,23,16,8,1,19,3,6,15,12,5,49,21,14,9,11,36,13,22,32,7,18,24;


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

Date: Mon, 21 Aug 2000 01:26:44 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: PERL/TK AND WIDGETS
Message-Id: <7aya1rieug.fsf@merlin.hyperchip.com>


Jeffrey Scott Dunfee II <dunfeeje@pilot.msu.edu> writes:

> Well, I guess it would seem alittle confusing. Here is the picture. I am
> writing a program to sort through some files in a directory, the files change
> so there might be 5 at one point and there might be 2.  According to the
> number of files in the directory to I dynamically create and display buttons
> in a frame, when I create them I use this code
> 
>    foreach (sort @good_agents)
>    {
>  my $_b = $dynamic_button_fr->Button(-text=>$_, -command=> sub{$agent_text
>  ->insert('end',"name of button here
                  ^^^^^^^^^^^^^^^^^^^^
                  ^^^^^^^^^^^^^^^^^^^^
You can use $_ here.

> \n");})->pack(side=>'top',-fill=>'both',-anchor=>'ne');
>    }
> 
> @good_agents - holds all the file names that I need to display (like I said
> earlier the count changes)
> $dyanmic_button_fr  - is a frame on a toplevel
> $_b - is the name of each file with the letter b appended, b for button

No it is not. $_b is a scalar whose name is '_b'. Maybe you should use a
hash?

	$buttons{$_} = $dynamic_button_fr->....

> $agent_text - is a text widget where I want to insert the name of the button
> when I press the button.
> 
> The code spits the buttons out fine, but since I use a loop even if I used a
> variable name for the hold variable on the loop (i.e foreach $some_variable
> (@good_agents)) the variable would not be unique for each button. 

It will be if you use lexicals:

	for my $some_variable {
		....
	}

--Ala


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

Date: Sun, 20 Aug 2000 18:37:07 -0700
From: musicfan <musicfan@punitiveart.com>
Subject: Re: Script skipping a section!?!?
Message-Id: <ep11qs8k94ndf38njq928o73okkfjvjstb@4ax.com>

Hmmm, I'm not going to worry about the security issue just yet, I want
to make it work first ;)

I've modified the file as follows, and now it goes through everything
(I watch it go line by line through the debugger, it goes through the
proper conditionals in the proper order) and overwrites the whole
database as a blank file.  I know I'm missing something obvious, but
I'm teaching myself Perl as I do this!

The code indentation is bizarre in the newsreader, it looks normal in
my IDE, however.


#!/usr/local/bin/perl
use strict;
# run sub to grab form input
&GetFormInput;

$datafile  = 'c:/Inetpub/Scripts/people.db';
$username = $field{'username'} ;	 

# open db, search recs to find matching username
open(PEOPLE, ">$datafile") or die "HELPFUL MESSAGE GOES HERE: $!\n";;
@PEOPLE=<PEOPLE>;
close(PEOPLE);
			 foreach $rec(@PEOPLE){

($name,$password,$clickthrough)=split(/\|/,$rec);
			 	if ($name eq $username){
			 	   print DATABASE
"$username|$password|1\n";
			 	}else{
			 	   print DATABASE
"$name|$password|$clickthrough\n";	
				}
			 }


print "Location: http://localhost/default.asp\n\n";


#subs
sub GetFormInput {

	(*fval) = @_ if @_ ;

	local ($buf);
	if ($ENV{'REQUEST_METHOD'} eq 'POST') {
		read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
	}
	else {
		$buf=$ENV{'QUERY_STRING'};
	}
	if ($buf eq "") {
			return 0 ;
		}
	else {
 		@fval=split(/&/,$buf);
		foreach $i (0 .. $#fval){
			($name,$val)=split (/=/,$fval[$i],2);
			$val=~tr/+/ /;
			$val=~ s/%(..)/pack("c",hex($1))/ge;
			$name=~tr/+/ /;
			$name=~ s/%(..)/pack("c",hex($1))/ge;

			if (!defined($field{$name})) {
				$field{$name}=$val;
			}
			else {
				$field{$name} .= ",$val";
				
				#if you want multi-selects to goto
into an array change to:
				#$field{$name} .= "\0$val";
			}


		   }
		}
return 1;
}






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

Date: Mon, 21 Aug 2000 01:27:12 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Script skipping a section!?!?
Message-Id: <39A084C0.D15F7A2B@netstorm.net>

musicfan wrote:

> open(PEOPLE, ">$datafile") or die "HELPFUL MESSAGE GOES HERE: $!\n";;

This opens $datafile for write, thus wiping out the contents.

-- Jim


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

Date: Mon, 21 Aug 2000 01:55:50 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Script skipping a section!?!?
Message-Id: <G_%n5.53251$rd1.9920198@typhoon-news1.southeast.rr.com>

musicfan <musicfan@punitiveart.com> wrote in message
news:ep11qs8k94ndf38njq928o73okkfjvjstb@4ax.com...
> Hmmm, I'm not going to worry about the security issue just yet, I want
> to make it work first ;)

Your prerogative, but using CGI.pm will make your life easier.

> #!/usr/local/bin/perl

Add "-w" to your #! line, e.g. #!/usr/local/bin/perl -w
This turns on warnings to help you find potential mistakes.

> use strict;

Have you actually tried to run this script?  It won't even compile.  "use
strict" requires you explicity declare every variable that you use, but I
don't see a "my", "our", or "use vars" anywhere.  Try perldoc strict

> # run sub to grab form input
> &GetFormInput;
>
> $datafile  = 'c:/Inetpub/Scripts/people.db';
> $username = $field{'username'} ;
>
> # open db, search recs to find matching username
> open(PEOPLE, ">$datafile") or die "HELPFUL MESSAGE GOES HERE: $!\n";;

If you want to read a file, you have to open it in either read("<") or
read-write("+<") mode.  You're currently opening it for truncate-write,
effectively emptying your file.  Try perldoc -f open

> @PEOPLE=<PEOPLE>;
> close(PEOPLE);
> foreach $rec(@PEOPLE){
>
> ($name,$password,$clickthrough)=split(/\|/,$rec);
> if ($name eq $username){
>    print DATABASE
> "$username|$password|1\n";

Have you opened a file for the DATABASE handle anywhere?

Philip




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

Date: Mon, 21 Aug 2000 11:46:46 +0800
From: Brian Leung <brianlk@pacific.net.hk>
Subject: Setup suid
Message-Id: <39A0A626.96857362@pacific.net.hk>

Hello,
I want to use suid of a perl cgi script.  How can I do? Any web site can
teach me?
Thanks

--
Regards,

Brian Leung
Pacific Supernet NOE




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

Date: 20 Aug 2000 20:20:08 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Wildcards in DOS 'dir' command
Message-Id: <39a09fe8@news.victoria.tc.ca>

jblatz2@my-deja.com wrote:
: I'm using ActivePerl on a Windows NT 4.0 platform.  I'm trying to use
: the 'dir' command with the '*' wildcard and it won't work.  I'm trying
: something like:

: @dirlist=`dir /b ..\*.log`;


In addition to other points someone else made, I wonder if `dir` can run
at all.


It's possible you need `cmd /c dir`.


I can't try it out right now to be sure.



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4075
**************************************


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