[15683] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3096 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 19 06:10:51 2000

Date: Fri, 19 May 2000 03:10:15 -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: <958731015-v9-i3096@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 19 May 2000     Volume: 9 Number: 3096

Today's topics:
    Re: Newbie Question - find command in Perl <gellyfish@gellyfish.com>
    Re: Parse::RecDescent problem, $::RD_TRACE showing some <jeff@vpservices.com>
    Re: Parse::RecDescent problem, $::RD_TRACE showing some <ocschwar@NOSPAM.mit.edu>
    Re: Parse::RecDescent problem, $::RD_TRACE showing some <jeff@vpservices.com>
    Re: Parse::RecDescent problem, $::RD_TRACE showing some <ocschwar@NOSPAM.mit.edu>
    Re: Perl on 98 <gellyfish@gellyfish.com>
    Re: PerlIS printing out header info. <gellyfish@gellyfish.com>
    Re: Proxy authentication solution CPAN module <wall@bacon.ethz.ch>
    Re: Putting file's variable in a database.How? <zigouras@mail.med.upenn.edu>
    Re: Remove leading zero <gellyfish@gellyfish.com>
        Rename all files in a directory <risj5@hotmail.com>
        Socket Connect Timeout <dwishar1@ford.com>
    Re: sub redefined? <home@cordova.net>
        TNA <yamlimNOyaSPAM@tp.edu.sg.invalid>
        upgrading CPAN - ld problem? <newsletter@ozemail.com.au>
    Re: Using DBM for simple database? <home@cordova.net>
    Re: Windows on windows <gellyfish@gellyfish.com>
    Re: zen and the art of trolling [OT] <xah@xahlee.org>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 19 May 2000 07:16:57 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Newbie Question - find command in Perl
Message-Id: <8g2m8p$5h1$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 17:59:49 -0400 Kevin Bass wrote:
> How does the following Unix command translate into Perl:
> 
> find . -name 'samp*' -exec <command>
> 


#! /usr/bin/perl -w
    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
        if 0; #$running_under_some_shell

use strict;
use File::Find ();

# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.

# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name   = *File::Find::name;
*dir    = *File::Find::dir;
*prune  = *File::Find::prune;


# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '.');
exit;


sub wanted {
    /^samp.*\z/s &&
    &doexec(0, 'command');
}


BEGIN {
    require Cwd;
    my $cwd = Cwd::cwd();
}

sub doexec {
    my $ok = shift;
    for my $word (@_)
        { $word =~ s#{}#$name#g }
    if ($ok) {
        my $old = select(STDOUT);
        $| = 1;
        print "@_";
        select($old);
        return 0 unless <STDIN> =~ /^y/;
    }
    chdir $cwd; #sigh
    system @_;
    chdir $File::Find::dir;
    return !$?;
}

Of course I cheated and used find2perl - you will want to look at at
the File::Find module ...

As an aside when did find2perl get updated ?

/J\
-- 
Friendship is far more tragic than love. It lasts longer.
-- 
fortune oscar homer


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

Date: Thu, 18 May 2000 22:20:51 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Parse::RecDescent problem, $::RD_TRACE showing something very odd.
Message-Id: <3924CF33.A483B20C@vpservices.com>

Omri wrote:
> 
> Hi, everyone.
> 
> I'm still working on my long RecDescent grammar,
> and right now my script dies with
> 
>     ERROR (line 1264): Untranslatable item encountered: "}"
>                 (Hint: Did you misspell "}" or forget to comment it
> out?)
> Bad grammar!
> 

[snip]

>     'sizeof' | 'static' | 'typedef' | "union"
> }};

[snip]
> 
> The second closing curly brace is an experiment. If I delete it I get
> this error message:
> Can't find string terminator "}" anywhere before EOF at www/decss.pl
> line 33.

Hmm , but you don't show us what opening braces those ending braces
match up with.  Where do they open, and is it possible one of them
should be closed before there?

-- 
Jeff


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

Date: Fri, 19 May 2000 05:39:54 +0000
From: Omri <ocschwar@NOSPAM.mit.edu>
Subject: Re: Parse::RecDescent problem, $::RD_TRACE showing something very odd.
Message-Id: <3924D3AA.E6179B27@NOSPAM.mit.edu>

Jeff Zucker wrote:
> 
> Omri wrote:
> >
> > Hi, everyone.
> >
> > I'm still working on my long RecDescent grammar,
> > and right now my script dies with
> >
> >     ERROR (line 1264): Untranslatable item encountered: "}"
> >                 (Hint: Did you misspell "}" or forget to comment it
> > out?)
> > Bad grammar!
> >
> 
> [snip]
> 
> >     'sizeof' | 'static' | 'typedef' | "union"
> > }};
> 
> [snip]
> >
> > The second closing curly brace is an experiment. If I delete it I get
> > this error message:
> > Can't find string terminator "}" anywhere before EOF at www/decss.pl
> > line 33.
> 
> Hmm , but you don't show us what opening braces those ending braces
> match up with.  Where do they open, and is it possible one of them
> should be closed before there?

They open 1200 lines above with:

my $Grammar = q{
    { 
        my @cpp_ifs; # the conditional compilation stack
        my $defined_types = "";
        my $declared_global_vars = "";
    }
    startrule : startrule2(s)    

 .....


I've gone over the script several times to see if I left a closing brace
somewhere 
by mistake, but the RD_TRACE indicates that it didn't.

It was parsing the last rule correctly. This is what leaves me
mystified.


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

Date: Thu, 18 May 2000 22:50:20 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Parse::RecDescent problem, $::RD_TRACE showing something very odd.
Message-Id: <3924D61C.1691A4EF@vpservices.com>



Omri wrote:

> my $Grammar = q{

How about using a different delimiter for your string?  I still don't
see what the }}: is doing at the end of your last rule.  The second };
closes your string delimiter, ok got that, but why is the first one
there, after the rule definition?

-- 
Jeff


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

Date: Fri, 19 May 2000 06:26:09 +0000
From: Omri <ocschwar@NOSPAM.mit.edu>
Subject: Re: Parse::RecDescent problem, $::RD_TRACE showing something very odd.
Message-Id: <3924DE81.7B9FFC17@NOSPAM.mit.edu>

Jeff Zucker wrote:
> 
> Omri wrote:
> 
> > my $Grammar = q{
> 
> How about using a different delimiter for your string?  I still don't
> see what the }}: is doing at the end of your last rule.  The second };
> closes your string delimiter, ok got that, but why is the first one
> there, after the rule definition?

It's only there because if it isn't I get this error message:

Can't find string terminator "}" anywhere before EOF at www/decss.pl
line 33.


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

Date: 18 May 2000 21:09:33 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl on 98
Message-Id: <8g1ilt$qid$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 20:26:00 GMT Ummmzzzz wrote:
> Allan M. Due <Allan@due.net> wrote in message
> news:8fusfb$593$1@slb7.atl.mindspring.net...
>> <amerar@my-deja.com> wrote in message news:8fulgr$ju2$1@nnrp1.deja.com...
>> : Simple question.  I've never used Perl under Windows 98 before.  How the
>> : heck are you aupposed to get the system date?  Can't seem to figure that
>> : one out.......
>>
>> I do it the Perl way. <g>
>> perldoc -f localtime;
>>
>
> I dunno .. i used the same scripts using system time with linux NT and
> 98 ..  all worked the same and fine .. i just dont feel like copy +
> pasting the code .. but if ya look at www.wdvl.com and goto perl or
> cgi .. its somewhere in there ..
> 

I'm not quite sure what you think was wrong with Allan's answer.

 perldoc -f localtime
 perldoc -f gmtime

I am sure its easier than finding this on some dodgy website.

/J\
-- 
If this were really a nuclear war we'd all be dead meat by now.
-- 
fortune oscar homer


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

Date: 19 May 2000 07:10:35 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: PerlIS printing out header info.
Message-Id: <8g2lsr$4a5$1@orpheus.gellyfish.com>

On Thu, 18 May 2000 13:31:48 GMT Steve wrote:
> On Wed, 17 May 2000 14:48:20 -0700, Tom Phoenix <rootbeer@redcat.com>
> wrote:
> 
>>On Wed, 17 May 2000, Steve wrote:
>>
>>> When I try to run a perl script on my NT 4.0 SP5 IIS 4.o server with
>>> PERLIS, it prints out the header information like "HTTP/1.1 200 OK
>>> Date: Wed, xx 2000 20:22:30 GMT Server: Microsoft-IIS/4.0"
>>> 
>>> How can I turn this of?
>>
>>It sounds as if you want to make your webserver do something. Perhaps you
>>should search for the docs, FAQs, and newsgroups about webservers. But
>>those headers sound a lot like HTTP headers; if it didn't output those, it
>>wouldn't be a webserver, would it? :-)
>>
>
> It is HTTP headers put they actually print out like text on the wb
> page?  How can I hide this??
> 

As Tom said this sound like a problem with your web server - you will
want to ask in comp.infosystems.www.servers.ms-windows about this.

/J\
-- 
Oh no! What have I done? I smashed open my little boy's piggy bank,
and for what? A few measly cents, not even enough to buy one beer. Wait
a minute, lemme count and make sure...not even close.
-- 
fortune oscar homer


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

Date: 19 May 2000 11:16:08 +0200
From: Ernst-Udo Wallenborn <wall@bacon.ethz.ch>
Subject: Re: Proxy authentication solution CPAN module
Message-Id: <uibt22sxwn.fsf@bacon.ethz.ch>

Myself <rjbragg@my-deja.com> writes:

> After playing for a day or so I have got my Perl on Solaris to speak
> through an authenticating proxy.  Can't guarenttee if this is the best
> solution or will always work but it seems to for me.
> 
> You may have to manually pull down and install some stuff first.


Why so complicated? Maybe i'm missing something here, but on
our system, the following works out-of-the-box:


use LWP::UserAgent;
use URI::URL;

my $url       =  URI::URL->new($URL);
my $agent     =  LWP::UserAgent->new();
my $request   =  HTTP::Request->new(GET => $url)
my $response;

if ($HAVE_AUTHORIZATION) {
  $request->authorization_basic($USERNAME,$PASSWORD);
}
if ($HAVE_PROXY) {
  $agent->proxy('http', $PROXY_URL);
  if ($HAVE_PROXY_AUTHORIZATION) {
    $request->proxy_authorization_basic(
       $PROXY_USERNAME,$PROXY_PASSWORD
    );
  }
}

if ($SAVE_TO_FILE) {
  $response  = $agent->request($request,$FILE);
} else {
  $response  =  $agent->request($request)
}


without modification of .*\.pm. Again: am i missing something here? 


 


-- 
Ernst-Udo Wallenborn
Laboratorium fuer Physikalische Chemie
ETH Zuerich


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

Date: Fri, 19 May 2000 00:37:22 -0400
From: Nico Zigouras <zigouras@mail.med.upenn.edu>
To: kana_krishna <kana_krishna@netcel360.com>
Subject: Re: Putting file's variable in a database.How?
Message-Id: <Pine.OSF.4.21.0005190034140.31364-100000@mail.med.upenn.edu>

perldoc -f stat
perldoc Net::FTP

stat() will give an array of the attributes of a local file.

Net::FTP has various methods to get the file.
methods that you would be interested in from Net::FTP:
size()
mdtm() - modification time.
If you do not have Net::FTP go to cpan.org and download it.

hope that helps.

On Fri, 19 May 2000, kana_krishna wrote:

> Date: Fri, 19 May 2000 11:15:22 +0800
> From: kana_krishna <kana_krishna@netcel360.com>
> Newsgroups: comp.lang.perl.misc
> Subject: Putting file's variable in a database.How?
> 
>  I need to do script that gets a file from a server to a local PC through a
> ftp using 'expect' script .That I have already done but the problem is that
> I have to put the file's attribute (name,size,modified date,current date
> etc) into a database(Oracle or Access - if can both) each time I get a file
> . I got to know that this can be done writing a ftp client program in
>  perl that can extract the files attribute and put it into a database . I am
> new to perl .Can anybody help me.
> 
> 
> 
> 




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

Date: 18 May 2000 21:17:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Remove leading zero
Message-Id: <8g1j45$s1g$1@orpheus.gellyfish.com>

On 18 May 2000 13:06:31 +0100 nobull@mail.com wrote:
> "Koen Lesenne" <koen_lesenne@inseurop.com> writes:
> 
>> I'm new to perl.
> 
> In that case you can assume that most questions you have are likely to
> be common ones.  Please read the FAQ - all the way through.  You may
> not understand it all yet but one day you'll have a question and
> think "hey I saw something like this in the FAQ".
> 
>> I'm trying to find a way to remove one or more leading zero's of a string.
>> Can someone help me with this please ?
> 
> See FAQ: "How do I strip blank space from the beginning/end of a string?"
> 
> Make the obvious adjustments.
> 
>> Ex. 0123456 should become 123456
> 
> In this case you could also just add zero.
> 


#!/usr/bin/perl -w

use Benchmark;
use strict;


sub regex
{
   my $string = '000000000040';
   $string =~ s/^0+//;
}



sub number
{

  my $string = '0000000000040';
  $string += 0;

}




timethese(1000000,{
                  Regex    => \&regex,
                  Number   => \&number
                 });
           


Benchmark: timing 1000000 iterations of Number, Regex...
    Number:  6 wallclock secs ( 5.73 usr +  0.00 sys =  5.73 CPU) @ 174520.07/s (n=1000000)
     Regex:  4 wallclock secs ( 4.30 usr + -0.01 sys =  4.29 CPU) @ 233100.23/s (n=1000000)


Which is contrary to my intuition on the matter ...

/J\
-- 
We're laughing with her, Marge. There's a big difference. Ha ha
ha! ...with her.
-- 
fortune oscar homer


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

Date: Fri, 19 May 2000 09:06:55 +0200
From: "R" <risj5@hotmail.com>
Subject: Rename all files in a directory
Message-Id: <uM5V4.4272$JL6.12088@nntpserver.swip.net>

I'm trying to move all files in a directory to another.

First I have to read the old directory. Probably like this
opendir DIRECTORY, $file;
@directory = readdir DIRECTORY;

Then I must do a loop that renames all the files in the directory.
Anyone who can give me an example of this?

Many thanks in advance

Rikard




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

Date: Fri, 19 May 2000 09:55:22 +0100
From: "Dave Wishart" <dwishar1@ford.com>
Subject: Socket Connect Timeout
Message-Id: <8g2vi0$6fs1@eccws12.dearborn.ford.com>

I am having a small problem with sockets. The code section attached appears
to work fine i.e. the connections are closed correctly leaving no zombies.
However, if I increase the throughput to say 64 simultaneous transactions
the subroutine listed below generates a connection timeout at the line:-

connect(MQServer, $paddr) or die "Can not connect $!";

The subroutine is called from another subroutine earlier on in the program
which after accepting an incoming data packet, performs a fork(); and then
continues with various other sub's with the last one outlined below.

Having taken the basic calls from Steven's 'UNIX Network Programming' I
believe that the actual calls are ok but I'm just wondering if there's a way
of increasing the time before the connect will timeout.

The application is written in Perl 5 running on Solaris 2.6

Any thoughts/suggestions as to where to look would be appreciated.

Thanks in advance.

Dave



Code snippet follows:-

my $proto = getprotobyname('tcp');
my $port = 49171;

socket(MQServer, PF_INET, SOCK_STREAM,$proto) or die "Can not create socket:
$!";

my $paddr = sockaddr_in($port, inet_aton('localhost'));
connect(MQServer, $paddr) or die "Can not connect $!";
$bytes_sent=send(MQServer, $buffer_copy, 0);
send(MQServer, "\n", 0);
logmsg(1,"Number of bytes sent = $bytes_sent \n");
#wait for the return of the message from the socket
$rin = "";
$timeout=60; #set timeout to be 60 seconds for MQ Series message
vec($rin, fileno(MQServer),1)=1;
while (select($rout=$rin, undef, undef, $timeout))
    {
    recv(MQServer, $line,80,0);
    last if (not (length($line)));
    $buffer = $buffer.$line;
    }#end of while
$recvlength=length($buffer);
if ($recvlength == 0)
    {
    data_error("C070");
    }
agent_send($buffer, 1);
exit 1;


Regards,

David Wishart
Server And Interface Team
Dealer Applications
FCE Bank plc

Tel: +44-(0)-1277-692570 Fax: +44-(0)-1277-692124
SMTP: dwishar1@ford.com
Mail: GB-12/300, Jubilee House, The Drive, Brentwood, Essex, CM13 3AR






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

Date: Thu, 18 May 2000 23:39:31 -0600
From: Peter <home@cordova.net>
Subject: Re: sub redefined?
Message-Id: <3924D393.66A13F60@cordova.net>

"T. Alex Beamish" wrote:


> I have searched the man pages for more information on this one and
> have come up empty-handed. No help on the perl.com site FAQ either.
> 
> The error I get when compiling one of my mod_perl modules is
> 
> Subroutine main redefined at compare.pm line 16 (#1)

Have you looked here:

http://perl.apache.org/guide/troubleshooting.html#Constant_subroutine_XXX_redefine

Or try the very active modperl list which you can find via the above
link.  I too try to avoid anything written to my error log.

Peter


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

Date: Thu, 18 May 2000 18:16:56 -0700
From: yam <yamlimNOyaSPAM@tp.edu.sg.invalid>
Subject: TNA
Message-Id: <24089728.fae4698d@usw-ex0103-019.remarq.com>

Hi,

I'd like to know whether there is any perl module that
implements Training Needs Analysis (TNA) in human resource
management.

Any info will be greatly appreciated.

YAM
Email: yamlim@tp.edu.sg


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Fri, 19 May 2000 17:30:55 +1000
From: Chat City Newsletter <newsletter@ozemail.com.au>
Subject: upgrading CPAN - ld problem?
Message-Id: <3924EDAF.62F4@ozemail.com.au>

I'm trying to upgrade my cpan module on a new solaris 7 box.  I've just
had a c comiler installed, but it may not be working correctly and I
don't know much about c.  Unfortunately the cpan install messages are
verbose about success, but not very helpful with the errors.

"make test" seems ok: "All tests successful."
but then "make install" is telling me "Already tried without success"
(yeah, I did try once, now where's the log?)

If anyone has the patience to troll through my cpan session log, I'd
really appreciate it.  The logs at 
http://lucky.online.ozemail.net/boldra/install-cpan.txt

thanks

- BOLDRA
bakedbeans@boldra.com (baked beans are off, try paul instead)


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

Date: Thu, 18 May 2000 23:27:32 -0600
From: Peter <home@cordova.net>
Subject: Re: Using DBM for simple database?
Message-Id: <3924D0C4.71457456@cordova.net>

Jesse T Sheidlower wrote:

> I'm trying to design a relatively straightforward database, and
> I'm a bit unclear on just how DBM's work, or what makes them
> practical. Basically they just store a hash to disk. Now, I

Why don't you just use Mysql?  There is execellent support for this free
rdbms. You can use DBI for this.  You can use the rdbms (via SQL) to
perform a lot of functions that you would otherwise have to program your
self.  

Peter


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

Date: 18 May 2000 21:11:02 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Windows on windows
Message-Id: <8g1iom$qrp$1@orpheus.gellyfish.com>

On Wed, 17 May 2000 12:00:16 -0700 Lauren Smith wrote:
> 
> Luc-Etienne Brachotte <Luc-Etienne.Brachotte@wanadoo.fr> wrote in message
> news:3922E12D.28CFDB43@wanadoo.fr...
>> I would like to know if it is possible in Perl for win32, to develop a
>> graphic interface.
> 
> Look into the Tk modules.
> 

Or possibly the Win32::GUI module if a native look'n'feel is wanted.

/J\
-- 
The code of the schoolyard, Marge! The rules that teach a boy to be a
man. Let's see. Don't tattle. Always make fun of those different from
you. Never say anything, unless you're sure everyone feels exactly the
same way you do.
-- 
fortune oscar homer


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

Date: Thu, 18 May 2000 22:58:16 -0700
From: Xah <xah@xahlee.org>
Subject: Re: zen and the art of trolling [OT]
Message-Id: <B54A23D7.9EC3%xah@xahlee.org>

Paul Eckert <peckert@epicrealm.com> wrote:
> Great...  Now there's two trolls in this newsgroup...

Don't forget that P in Perl stands for Practical. So, from a pragmatic
school of thought, there're now really three trolls in this newsgroup. One
of them is inane.

The perl folks with their beads of little eyes, cannot see beyond their
perl-perl-land.

 Xah
 xah@xahlee.org
 http://xahlee.org/PageTwo_dir/more.html




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

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


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