[13407] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 817 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 16 10:07:36 1999

Date: Thu, 16 Sep 1999 07:05:12 -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: <937490712-v9-i817@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 16 Sep 1999     Volume: 9 Number: 817

Today's topics:
        ... same program, but shorter <pantau@zedat.fu-berlin.de>
    Re: ... same program, but shorter <donotspam@me.ca>
        ? about bare word. <scmpoper@scmp.com>
    Re: Abigail, Abigail, wherefore art thou, Abigail? a.k. (Anno Siegel)
        Candidate for UNCRAP? (was Re: Critique/comments for we (Kragen Sitaker)
    Re: CGI cannot open relative path (Kragen Sitaker)
    Re: CGI cannot open relative path <krajzewicz@inx.de>
    Re: cookbook: nonforker (Gabor)
    Re: Critique/comments for web board? <fty@hickory.engr.utk.edu>
        Encrypting (and decrypting) password <steve.button@nl.origin-it.com>
        Formating disk under Windows <Roger.Tillmann@extern.rwso.de>
    Re: Formating disk under Windows jkloos@bischof.mz.rp.schule.de
    Re: Formating disk under Windows <gellyfish@gellyfish.com>
    Re: HELP PARSE EMAIL ADDRESSES PLEASE (Kragen Sitaker)
        Help: No pipe output. <linyong2000@990.net>
    Re: Help: No pipe output. (Kragen Sitaker)
        help: read only a char without echo? <A.Urban@alcatel.de>
    Re: help: read only a char without echo? <gellyfish@gellyfish.com>
        How to access Linux/MySQL from ASP? bgmahesh@my-deja.com
    Re: How to access Linux/MySQL from ASP? <gellyfish@gellyfish.com>
    Re: how to hide secured info? (Kragen Sitaker)
    Re: IIS 3.0 - CGI - @INC - problem finding libraries <alain.borgo@ratp.fr>
        Novice Question - skipping input <kennedyd@bireh010.europe.nortel.com>
    Re: Parsing Tab Delimited File <tchrist@mox.perl.com>
    Re: PERL (cgi) and Databases -> How To? <steve.button@nl.origin-it.com>
        perl mail automatically processing? weiq@cs.dal.ca
    Re: Perl SYstem Functions Problem (Kragen Sitaker)
    Re: Please help a newbie! (Anno Siegel)
    Re: Please help a newbie! <flavell@mail.cern.ch>
    Re: Please help a newbie! (Kragen Sitaker)
    Re: Procedure result inheritance (Kragen Sitaker)
    Re: Splitting a line and honoring "strings" (Kragen Sitaker)
    Re: Unix Trouble (Kragen Sitaker)
        unpack("%32C*", $text) andy_muscat@my-deja.com
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Sep 1999 13:39:45 +0200
From: Hans-Georg Thien <pantau@zedat.fu-berlin.de>
Subject: ... same program, but shorter
Message-Id: <37E0D701.35905303@zedat.fu-berlin.de>

 ... the same program, somewhat shorter ...

use strict;
my @buf=();
my $bufsize=4;

while (<>)
{
  push (@buf, $_);

  #if buffer is full, then remove the first bufferitem and print it
  print shift(@buf) if @buf > $bufsize;

  #delete buffer if pattern found
  @buf=() if /pattern/; 
}

#some lines maybe left in buffer, - print them out
print while $_=shift(@buf);


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

Date: Thu, 16 Sep 1999 13:59:06 GMT
From: "Mike" <donotspam@me.ca>
Subject: Re: ... same program, but shorter
Message-Id: <KI6E3.232$P4.14438@news1.frmt1.sfba.home.com>

Larry, Hans, et al.,

Thanks for the help!  Should've thought of doing it this way in the first
place...

Mike

(and yeah, Outlook isn't my preferred newsreader either!)




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

Date: Thu, 16 Sep 1999 21:50:32 +0800
From: scmpoper <scmpoper@scmp.com>
Subject: ? about bare word.
Message-Id: <37E0F5A8.47FBEB19@scmp.com>

Hello:
Do anyone know what's wrong with the code below:
print "\${\"value\"} is ${"value"}\n";

With -w option, found error message:
Missing right bracket at cd-ref line 25, within string
syntax error at cd-ref line 25, at EOF
Execution of cd-ref aborted due to compilation errors.

Many Thank.......



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

Date: 16 Sep 1999 11:11:38 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Abigail, Abigail, wherefore art thou, Abigail? a.k.a. Re: Error in  "Learning Perl, 2nd Edition"
Message-Id: <7rqj9a$k4v$1@lublin.zrz.tu-berlin.de>

Cameron Dorey  <camerond@mail.uca.edu> wrote in comp.lang.perl.misc:

>The same thing happens to me, although I used to see Abigail's posts all
>the time (until April, anyway, don't ask me to figure out the September
>MCMXCIII date). Thought it was something uniquely wrong with my feed,

perl -MRoman -le 'print arabic "MCMXCIII"'

Anno


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

Date: Thu, 16 Sep 1999 13:30:41 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Candidate for UNCRAP? (was Re: Critique/comments for web board?)
Message-Id: <5i6E3.14417$N77.1065619@typ11.nn.bcandid.com>

In article <7rqpls$a42$1@gaia.ns.utk.edu>,
Jay Flaherty  <fty_no_spam@utk.edu> wrote:
>Your code is definitely a level up from most CGI scripts I have seen, especially
>from someone who considers themselves a beginner. Just remember to use strict, 
>which forces you to scope your variables (among other things). Your next step is
>to generisize it and create a OO module to upload to CPAN :-)

Perhaps the script could be added to CRAP/UNCRAP/mattright.com/whatever
it's called this week?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 13:13:38 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: CGI cannot open relative path
Message-Id: <626E3.14409$N77.1063678@typ11.nn.bcandid.com>

In article <7rqav3$4sd$1@minus.oleane.net>,
JduPayrat <jdupayrat@webraska.com> wrote:
>That's exactly my problem. I don't see any solution that don't need a change
>in each script.

I don't either -- but you could at least limit it to one line in each
script.  :)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 15:58:53 +0200
From: Daniel Krajzewicz <krajzewicz@inx.de>
Subject: Re: CGI cannot open relative path
Message-Id: <37E0F79D.C406A00B@inx.de>

Hello !!!

Uh, yes I recently had to solve this problem, too. Zou can determine the
name of the HTML-File and the users (page-owners) name from the
%ENVIROMENT variable and determine
the users home-directory by the use of his name. Then simply attach the
name of the file.
This may only cause problems, if a server uses SOMETIMES the
/public_html-Preference and SOMETIMES not.

see ya,
Daniel Krajzewicz


Kragen Sitaker wrote:
> 
> In article <7rqav3$4sd$1@minus.oleane.net>,
> JduPayrat <jdupayrat@webraska.com> wrote:
> >That's exactly my problem. I don't see any solution that don't need a change
> >in each script.
> 
> I don't either -- but you could at least limit it to one line in each
> script.  :)
> --
> <kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
> Tue Sep 14 1999
> 55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>

-- 
 __________________________
<     Daniel Krajzewicz    >
 >------------------------<
<     krajzewicz@inx.de    >   
 >------------------------<
< http://www.art-so-far.de >
 >------------------------<
<__________________________>


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

Date: 16 Sep 1999 08:21:45 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: cookbook: nonforker
Message-Id: <slrn7u1o6p.nao.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Benjamin Schweizer <SternSZ@gmx.de> wrote :
# +-->Rick Delaney <rick.delaney@home.com>:
# | Benjamin Schweizer wrote:
# | > 
# | > I´ve got a non forking daemon which is pretty nice. If I mark the
# | > following code as a comment it runs pretty nice, else Perl reports
# | > that IO::Select has no method has_exception.
# | 
# | If you want that method then you should upgrade your version of
# | IO::Select to the one that has that method.  Better yet, upgrade your
# | perl since this is a standard module.
# 
# Are you sure? My distribution is only a few months old.
# Perl is relase 5.005_2 from May 1999.
# Which release do I need?

That release definitely has it since I am looking at it right now.


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

Date: 16 Sep 1999 13:00:44 GMT
From: Jay Flaherty <fty@hickory.engr.utk.edu>
Subject: Re: Critique/comments for web board?
Message-Id: <7rqpls$a42$1@gaia.ns.utk.edu>

David Wall <darkon@one.net> wrote:

:>3) You could use here-document syntax in a lot more places than you 
:>presently are.

: Yeah, I sure could.  More false laziness, I guess.  I'm never sure which is 
: uglier, here-documents, or all those backslashes in print statements.  I like 
: here-documents, but they screw up the indenting of my code.  I suppose I could 
: always space them over, but I want to keep whatever HTML I generate as minimal 
: as possible (within reason);  I want pages to load *quickly*, none of this 
: "scatter a half-dozen comments and useless tags everywhere" like some 
: so-called wysiwyg HTML editors do.

You could use qq(...) to avoid backslashes instead of here docs. This allows
you to maintain indentation in your code. You could also use CGI.pm's syntax
to generate the html. For example instead of:

print "<html><body $bodyattr>\n";
      print "<ul>\n";
      print "<li><a href=\"$url\">Go to the message index</a><p>\n";
      print "<li><a href=\"$url?action=read&id=$id\">Read the message you just posted</a>\n";
      print "</body></html>\n";

you could do:

print
    $query->start_html("Darkboard"),
    $query->ul($query->li([$query->a({-href=>$url},
                                     "Go to the message index"),
                           $query->a({-href=>$url?action=read&id=$id},
                                     "Read the message you just posted")
                          ])
              ),
    $query->end_html;

as you can see, the object oriented syntax is a bit busy. You can get around 
this by using the function oriented interface as long as you create only one 
object. Like so:

use CGI qw(:standard);
print
    start_html("Darkboard"),
    ul(li([a({-href=>$url}, "Go to the message index"), 
           a({-href=>$url?action=read&id=$id}, "Read the message you just posted")
           ])
       ),
    end_html;

You could also use CGI::Pretty to pretty print the html source if thats important.

Your code is definitely a level up from most CGI scripts I have seen, especially
from someone who considers themselves a beginner. Just remember to use strict, 
which forces you to scope your variables (among other things). Your next step is
to generisize it and create a OO module to upload to CPAN :-)


--
**********************************************************************  
Jay Flaherty                                               fty@utk.edu
"Once in awhile you get shown the light, in the strangest of places if
you look at it right" - R. Hunter
**********************************************************************



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

Date: Thu, 16 Sep 1999 15:39:48 +0200
From: "Steve Button" <steve.button@nl.origin-it.com>
Subject: Encrypting (and decrypting) password
Message-Id: <0E16861EE7BCD111BE9400805FE6841F0B6DB403@c1s5x001.cor.srvfarm.origin-it.com>

Hello,

I've read the FAQ (...well most of it {...well SOME of it  :-) }  )

I've searched on dejanews (which doesn't look like it used to last time I
used it, so it took a while to figure it out)

I've lurked.

I've had a look around CPAN and perl.com.

Have I done enough?

Well, I still couldn't find the answer to my question, so finally I post it
here.

I'm trying to encrypt a password that a user types in, so that I can pass it
from program to program without it being intercepted inbetween. I can see
that there are lots of modules on CPAN that can sort of do things like this,
but I'm not sure of the best thing to use. I had a look at crypt, but that
is something quite different (may be useful for other things though, as I'm
also a Unix sysadm).

I confess that it is for a CGI program, so that I can pass the password as
part of the URL (is that POST or GET, I can never remember*) when soneone
has "logged in" to my web site. I know that this is not ideal, but we're not
dealing with money or credit card numbers or anything (yet) I just don't
want people messing around with other peoples adverts.

Any pointers, help would be much appreciated. If you could reply to me
directly, that would be nice as I don't often get time to check usenet (got
a lot of real work to do :-(  ) but please post to the group too.

Thanks,

Steve

* Please don't answer that one, as it's a rhetorical question and should be
directed to another newsgroup.
--
HuntAHome      http://www.huntahome.com
Properties throughout the UK and Europe
You can subscribe to receive a free daily email of all properties that match
your requirements (location, price, bedrooms)
You can advertise your property, with photograph, for free.




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

Date: Thu, 16 Sep 1999 11:24:29 GMT
From: Roger Tillmann <Roger.Tillmann@extern.rwso.de>
Subject: Formating disk under Windows
Message-Id: <7rqk14$51b$1@nnrp1.deja.com>

Hello ...

I just tried to write a script to format a disk under Windows NT with
Perl. I have a few problems controlling the external format commando
with Perl. Is there some (other) solution?

Thanx

Roger


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 16 Sep 1999 11:37:44 GMT
From: jkloos@bischof.mz.rp.schule.de
Subject: Re: Formating disk under Windows
Message-Id: <7rqkq8$4fg$1@news.rhein-zeitung.DE>

a) Get Linux (or *BSD; or Solaris; or Unix; or another Real OS (TM))
b) Maybe you could use IPC::Open2 for this.



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

Date: 16 Sep 1999 12:50:00 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Formating disk under Windows
Message-Id: <37e0d968_1@newsread3.dircon.co.uk>

Roger Tillmann <Roger.Tillmann@extern.rwso.de> wrote:
> Hello ...
> 
> I just tried to write a script to format a disk under Windows NT with
> Perl. I have a few problems controlling the external format commando
> with Perl. Is there some (other) solution?
> 

Not as far as I know.  You could write an XS component that talks to the
Formatting API I suppose (if there is such a thing :).

Perhaps  if you told us what your problem was then we might be able to
suggest an easier approach ...

/J\
-- 
"Tony Blair. Make it so" - Patrick Stewart


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

Date: Thu, 16 Sep 1999 13:22:59 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: HELP PARSE EMAIL ADDRESSES PLEASE
Message-Id: <Ta6E3.14413$N77.1064942@typ11.nn.bcandid.com>

In article <MPG.1249b2b369cc16f989f73@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>Why the quotes aound $_?  For that matter, why $_?

That's the way it was in his original script.  :)

I probably should have changed it.

>But why all the superfluous capturing parentheses and anchors and .*'s 
>and escapes and substitutions?

I have no idea.  I probably shouldn't have responded to the post if I
wasn't willing to do a thorough job.

Thanks for the corrections.  :)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 21:29:23 +0800
From: "Daniel Y.L." <linyong2000@990.net>
Subject: Help: No pipe output.
Message-Id: <7rqrcc$80c$1@news.ntu.edu.sg>

Hi,

I met a problem when I execute a C program in my Perl/CGI program.  I cannot
capture the output from the C program in my Perl/CGI program through web
browser.

My Perl/CGI program seems as following:

#$glim is a correct command: glim -i -F 'a.dat' '{artist;title}';
open (PIPEGLIM, "$glim|") || die "Cannot open pipe";

print "glim begins output:\n";
while (<PIPEGLIM>) {
  print "glim result:$_\n";
}
close (PIPEGLIM);

The C program is located in the same directory as my Perl/CGI program and
changed mode to 5755 (chmod 5755 glim).  When I use web browser to run my
CGI program, there is no output from glimpse (but, I can see the string
before the while loop).  Could you give me any help?  Thank you very much.

Best regards






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

Date: Thu, 16 Sep 1999 13:44:55 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Help: No pipe output.
Message-Id: <rv6E3.14433$N77.1067283@typ11.nn.bcandid.com>

In article <7rqrcc$80c$1@news.ntu.edu.sg>,
Daniel Y.L. <linyong2000@990.net> wrote:
>#$glim is a correct command: glim -i -F 'a.dat' '{artist;title}';
>open (PIPEGLIM, "$glim|") || die "Cannot open pipe";
>
>print "glim begins output:\n";
>while (<PIPEGLIM>) {
>  print "glim result:$_\n";
>}
>close (PIPEGLIM);
>
>The C program is located in the same directory as my Perl/CGI program and
>changed mode to 5755 (chmod 5755 glim).  When I use web browser to run my
>CGI program, there is no output from glimpse (but, I can see the string
>before the while loop).  Could you give me any help?  Thank you very much.

My guess: glim isn't in your path when running as a CGI script.  Why
don't you close (PIPEGLIM) or die "problem with glim: $!" instead of
just close(PIPEGLIM)ing, and why don't you also check your server error
logs.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 13:54:59 +0200
From: Alexander Urban <A.Urban@alcatel.de>
Subject: help: read only a char without echo?
Message-Id: <37E0DA93.C39CFC1@alcatel.de>

Hi,

I'd like to read only one character without echo under UNIX-System.
How can I do that?

No echo:
system("stty -echo");
But reading only one character whithout waiting for newline? (like press
anykey).

thanks

Alexander Urban
eMail: A.Urban@alcatel.de


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

Date: 16 Sep 1999 13:40:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: help: read only a char without echo?
Message-Id: <37e0e55a_1@newsread3.dircon.co.uk>

Alexander Urban <A.Urban@alcatel.de> wrote:
> Hi,
> 
> I'd like to read only one character without echo under UNIX-System.
> 

In the first instance please see perlfaq5:

  How can I read a single character from a file?  From the keyboard?

/J\
-- 
"Malcolm, what have I told you about putting chocolate near your
crotch?" - Mrs Merton


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

Date: Thu, 16 Sep 1999 12:18:16 GMT
From: bgmahesh@my-deja.com
Subject: How to access Linux/MySQL from ASP?
Message-Id: <7rqn5v$74p$1@nnrp1.deja.com>
Keywords: ASP, MySQL, Linux, Redhat

hi

I am using MySQL on Linux. I want our ASP applications on NT
to access this MySQL database. Can this be done? If so, where
can I get some reference material?

--
B.G. Mahesh
http://www.indiainfo.com/


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 16 Sep 1999 14:16:17 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to access Linux/MySQL from ASP?
Message-Id: <37e0eda1_1@newsread3.dircon.co.uk>

In comp.lang.perl.misc bgmahesh@my-deja.com wrote:
> hi
> 
> I am using MySQL on Linux. I want our ASP applications on NT
> to access this MySQL database. Can this be done? If so, where
> can I get some reference material?
> 

The Perl content of this eludes me.

Once and once only there is an ODBC Driver for MySQL.

/J\
-- 
"Tony Blair is reported to be detained indefinitely under plans unveiled
by the Home Secretary" - Corrupt Teletext Page


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

Date: Thu, 16 Sep 1999 13:17:47 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: how to hide secured info?
Message-Id: <%56E3.14412$N77.1064156@typ11.nn.bcandid.com>

In article <937456459.841877@diddley.primus.com.au>,
Nick Read <nickread@primus.com.au> wrote:
>I suggest you take up writing JAPH's, only in your case, you'd be writing
>JAOL's (Just Another Oricle Login)

JAPHs can be decoded by running them through Perl.  So could JAOLs; in
the worst case, you'd just have to write a fake DBD module that just
prints out the username and password and exits.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 13:43:02 +0100
From: Alain BORGO <alain.borgo@ratp.fr>
Subject: Re: IIS 3.0 - CGI - @INC - problem finding libraries
Message-Id: <37E0E5D6.64FA00F2@ratp.fr>

Hello,

Wessel van Alphen a écrit:
> 
> Beginners question :
> 
> At first, I builded an intranet on a winnt client with apache webserver,
> using Perl 5.0 for CGI scripts and everything worked fine.
> These scripts are freeware scripts, modified to my needs.
> I have very little Perl-experience.
> 
> Now I'v installed the whole thing on our companies server and
> I have to use Winnt IIS server (3.0).
> Whenever I try to execute a script, I get the message that
> my own libraries can't be found in the @INC path, even if I
> use the absolute pathname, e.g. http//pathname/faq.pl.
> @INC only contains the paths that were created during
> the installation of Perl. (d:/perl/lib and d:/perl).
> Where is @INC build and how do I append my own directories to @INC ?
> (And why did it worked fine on my on p.c.?)
> 
> Thanks,
> 
>     Wessel.

This is not a beginner question. It is just a IIS problem !

Normally, when your script is launched, the working directory is the
directory where the script resides. Unfortunatly, with IIS, the
working directory is ALWAYS the root directory of your scripts.

Examples :
URL = /cgi-bin		PHYSICAL PATH : c:\somewhere\else\cgi-bin
When you call /cgi-bin/myscript.pl, the current directory is
c:\somewhere\else\cgi-bin and the require "mylib.pl" requires that
mylib.pl is in this directory. That's normal.

URL = /cgi-bin/survey		PHYSICAL PATH :
c:\somewhere\else\cgi-bin\survey
When you call /cgi-bin/survey/mysurvey.pl, the current directory is
c:\somewhere\else\cgi-bin (the same as before !) and the require
"mysurveylib.pl" requires that mysurveylib.pl is in this directory.
And then your script failed !

In the last case, you have to say  :
require "/somewhere/else/cgi-bin/survey/mysurveylib.pl";

Another solution is to add /somewhere/else/cgi-bin/survey to @INC by :
push(@INC,"/somewhere/else/cgi-bin/survey");
In this case, you have to do this for all your scripts that are in a
sub-directory of the root scripts directory.

-- 
A bientôt.
---------------------------------------------------------------------------------
Je ne suis pas sûr d'avoir raison mais je suis sûr d'avoir essayé
d'avoir raison.


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

Date: 16 Sep 1999 12:50:13 GMT
From: David Kennedy <kennedyd@bireh010.europe.nortel.com>
Subject: Novice Question - skipping input
Message-Id: <7rqp25$fsu$2@bcrkh13.ca.nortel.com>

I'm trying to force myself to migrate to perl from sh scripting
but am having trouble with my first attempt.

THE PROBLEM (which sed isn't good at):
   Debug output from a piece of C++ code produces a million
   line log of function call traces. Most of these are fine.
   We'd like to remove many of the trivial calls.
   In particular, I'd like to remove this pattern from the
   log:

GosServer::handle_timeout()
{
  GosServer::readMessage()
  {
    No messages.
  }
  NM timer_id is 2
}

My naive approaches don't work...  How should I go about this?

Ideally I'd like a sed like approach where I can have a data file
of regular expression based pattern to cut out - I'll release
this file to a few developers and their data needs are different.

(Email appreciated)
-- 
David Kennedy,                      | kennedyd@nortelnetworks.com
Northern Ireland Telecommunications | ESN:   6 751 2678 
  Engineering Centre (NITEC),       | Phone: 01232 362678
Nortel Networks                     | Fax:   01232 363170


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

Date: 16 Sep 1999 07:49:56 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Parsing Tab Delimited File
Message-Id: <37e0f584@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    "Samuel Kilchenmann" <skilchen@swissonline.ch> writes:
:Neither regexps nor split are particularly useful for simple things like
:parsing csv files, so this extension module is exactly the right thing
:to use.

You misstate yourself. Regexps and split certainly are 
useful for simple data parsing, as seen in 

    @fields = split(' ', $line);
    @pwent  = split(/:/, $line, -1);

Or even for complex files like termcap:

    while (<>) {
	next if /^(#.*)?\s*$/;			# comments
	$_ .= <> while s/\\$// && !eof;		# continuations
	@fields = split /:(?:\s*:)*/;		# colon-separated w/glitch
	printf "%d fields in %s\n", 0+@fields, $fields[0] =~ /^([^|]+)/;
    }


In a sane world, where "comma-separated values" actually happens to mean
the remarkably surprising "comma-separated values", this is all it takes:

    @fields = split(/,/, $line, -1);

You'll notice that this approach also suffices for the passwd file, etc. 
Those were designed for simplicity.

However, programmer-hostile systems seem riddled with programmer-hostile
files mis-designed by evil and stupid sado-masochistic programmers who
should have all their fingernails torn out, very slowly.  No thought
is given to simplicity of parsing, which means you get something
that is *not* simple to parse.  Do not call things so-called "CSV
files" simple, because if they were, then a split would suffice.
It doesn't, so they aren't.  And they're hardly "comma-separated".
They're "quasi-comma-separated with inane hacks and idiosyncrasies
bearing only a superficial and conquently deceptive resemblance to actual
comma-separated data".

--tom
-- 
The Unix Way of doing something [...] is to make it look as much like a filter
as possible.  (Richard O'Keefe)        


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

Date: Thu, 16 Sep 1999 15:16:17 +0200
From: "Steve Button" <steve.button@nl.origin-it.com>
Subject: Re: PERL (cgi) and Databases -> How To?
Message-Id: <0E16861EE7BCD111BE9400805FE6841F0B6D9674@c1s5x001.cor.srvfarm.origin-it.com>


LynchMan wrote in message <0b51f39f.f8b3f1be@usw-ex0102-012.remarq.com>...
>Hey,
>I am curently developing some PERL Cgi scripts, and I want
>to get into using a database with my scripts.  I was
>wondering where I should start.  I use my ISP to host my


You should probably start by looking at MySQL (www.mysql.com) which WILL run
on Linux, as that's what I do. It's probably free for you, but your ISP
should probably pay for it (if I remember the licence correctly)

I had this very same problem last year when designing my site (see .sig) and
it was really difficult to know where to start. Once you've got MySQL up and
running, you will need to install the correct DBD / DBI drivers. I did all
this and also had to upgrade my perl version to make the drivers work (it
was quite a big download for my little modem to handle, at ~ 56K).

Once you've got that far you will have to learn how to use the API calls,
but that is for another group to help you with (which you'll read about in
the MySQL install docs).  Unfortunately (for me anyway) it's a mailling
list.

Good luck, and keep at it. It's worth it in the end.

Steve
steve@huntahome.com

--
HuntAHome      http://www.huntahome.com
Properties throughout the UK and Europe
You can subscribe to receive a free daily email of all properties that match
your requirements (location, price, bedrooms)
You can advertise your property, with photograph, for free.




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

Date: Thu, 16 Sep 1999 12:41:34 GMT
From: weiq@cs.dal.ca
Subject: perl mail automatically processing?
Message-Id: <7rqohr$823$1@nnrp1.deja.com>

Hi All

I plan to write a program to check my mail automatically. If the mail
subject match certain string, the program should process the mail
automatically, saving the mail into a file or puting into database. My
program right now is that I do not know how to check the mail
automatically by using perl (the mail is in Unix Solaris).

I would be very grateful if anyone could give me some advise or
providing some sample perl code.

Thanks for you all.

Wei


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 16 Sep 1999 12:56:24 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Perl SYstem Functions Problem
Message-Id: <YN5E3.14400$N77.1062044@typ11.nn.bcandid.com>

In article <37e08063@news.asgard.net.au>,  <forseti78@hotmail.com> wrote:
>I am having difficulty gett (ps -aux | grep program) to run from perl and 
>store the output in a file or array.

open PS, "ps -aux | grep program |" or die "couldn't open pipe: $!";
my @psout = <PS>;  # store in array

or

system "ps -aux | grep program > outputfilename" or
	die "couldn't open pipe: $!";
# store in file

>Also could someone please help me out with the syntax for starting a program 
>from perl that will continue running after perl exits??

system "program &";
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 16 Sep 1999 11:29:54 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Please help a newbie!
Message-Id: <7rqkbi$k6g$1@lublin.zrz.tu-berlin.de>

 <makau@multimania.com> wrote in comp.lang.perl.misc:
>Seems some people are much too serious here :-)
>
>In fact, I did right an incorrect code on purpose! It was to test the
>reactivity of the group and to know if you would flame me or not...

[...]

Go where your experiments in group psychology are appreciated.  If
such a place exists...

Anno


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

Date: Thu, 16 Sep 1999 13:28:45 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Please help a newbie!
Message-Id: <Pine.HPP.3.95a.990916132546.13146B-100000@hpplus03.cern.ch>

On Thu, 16 Sep 1999, Kragen Sitaker wrote:

> >I for one have no way of knowing whether this will cause a problem or
> >whether '01/01/00' will be ambiguous (as to the year) within the context
> >of the dataset it comes from.
> 
> It's a trap.  Different people will write programs that will
> disambiguate the year in different ways.

Indeed, and it'll be even worse with e.g 03/02/01, which instead of
meaning two incompatible things (dd/mm/yy versus mm/dd/yy as today) will
mean at least three.




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

Date: Thu, 16 Sep 1999 13:05:10 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Please help a newbie!
Message-Id: <aW5E3.14406$N77.1062986@typ11.nn.bcandid.com>

In article <Pine.HPP.3.95a.990916132546.13146B-100000@hpplus03.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>On Thu, 16 Sep 1999, Kragen Sitaker wrote:
>> It's a trap.  Different people will write programs that will
>> disambiguate the year in different ways.
>
>Indeed, and it'll be even worse with e.g 03/02/01, which instead of
>meaning two incompatible things (dd/mm/yy versus mm/dd/yy as today) will
>mean at least three.

I suspect that *that* error will get caught very quickly, at least in
computer programs, because time periods in which different
interpretations are the same are rare and short.  But if two people
pick a different window year, their interpretations will agree most of
the time.  Only years between the two window years will be interpreted
differently -- a nasty bug.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 12:59:43 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Procedure result inheritance
Message-Id: <3R5E3.14404$N77.1062435@typ11.nn.bcandid.com>

In article <37E08880.B03B47AC@inx.de>,
Daniel Krajzewicz  <krajzewicz@inx.de> wrote:
>Well, actually I'm working for a biiiiiiiig internet company and write
>some basic perl-scripts, I hope you'll be able to see them in some days
>in action...
>Anyway, the purpose for returning the result and the rrorcode is the
>that I'll be able to collect all errors and give them out on a HTML-page
>if they occure...

So if there's an error, you want to continue normally, as if no error
had occurred, and save up all the errors in a list so you can output
them at some later point?

Maybe you should die and then use eval{} at the level you want to
continue at.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 12:50:31 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Splitting a line and honoring "strings"
Message-Id: <rI5E3.14398$N77.1061424@typ11.nn.bcandid.com>

In article <slrn7u1dur.95k.scarblac-spamtrap@flits104-37.flits.rug.nl>,
Remco Gerlich <scarblac-rt@pino.selwerd.cx> wrote:
>Lokesh Setia <nospam@hss.hns.com> wrote:
>> yellow brown black green blue
>> 
>> What I want is to honor the quotes "" and '' withing the user line
>> so that the user can embed spaces in the values: like,
>> 
>> blue "light pink" "dark blue" green 'navy blue'
>
>See perlfaq4, "How can I split a [character] delimited string except
> when inside [character]? (Comma-separated files)".

Not to dis the standard solution from the FAQ, which I have confidence
is quite good, but you can do this:

#!/usr/bin/perl -w
use strict;
my $str = q(blue "light pink" "dark blue" green 'navy blue' 'Hogan\'s color');
print $1, "\n" while $str =~ /
	([^\ "'\\]+|
	"(?:\\"|[^\\"]|\\\\)*"|
	'(?:\\'|[^\\']|\\\\)*')/gx;

This looks for either strings made of nonspace, nonquote, nonbackslash
characters; strings beginning and ending with " and containing inside
them only \", \\, or characters neither \ nor "; or analogous strings
with '.

It returns the whole strings, quotes, backslashes, and all.

It has the unfortunate disadvantage that unterminated strings will
simply be ignored.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 13:42:24 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Unix Trouble
Message-Id: <4t6E3.14429$N77.1062299@typ11.nn.bcandid.com>

In article <7r5ou1$e2a$1@nnrp1.deja.com>,
The Glauber  <theglauber@my-deja.com> wrote:
>That's one of the things that makes Perl fast. (Compare using find and
>rm to delete files older than X days, when you start rm once for each
>file you find. With Perl, you do everything in your program, without
>ever having to start rm.)

find . -mtime +10 -print0 | xargs -0 echo rm

(Remove 0 from print0 and -0 if you don't have GNU findutils.  Remove
echo if you really want to delete all the files older than 10 days.)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 13:50:44 GMT
From: andy_muscat@my-deja.com
Subject: unpack("%32C*", $text)
Message-Id: <7rqsje$b6t$1@nnrp1.deja.com>

Does anyone know what the C/C++ version of unpack("%32C*",$text) would
be?

I want to produce a checksum for a piece of text in C++ to mimic the way
it is done in a Perl script. The perl is

$checksum  = unpack ("%32C*",$text);


Andy



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

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

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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