[13612] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1022 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 8 12:10:26 1999

Date: Fri, 8 Oct 1999 09:10:18 -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: <939399017-v9-i1022@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Oct 1999     Volume: 9 Number: 1022

Today's topics:
    Re: Parsing through Multiple text lines <escudero@securities.cl>
        PDFlib size settings <krajzewicz@inx.de>
    Re: Question about alarm and run away processes <ilya@speakeasy.org>
    Re: Read email through web <dave@dave.org.uk>
    Re: sendmail help <dave@dave.org.uk>
    Re: tool to convert BMPs to GIFs programatically? (J. A. Mc.)
    Re: What is THE book for PERL? <dave@dave.org.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 08 Oct 1999 09:41:51 -0400
From: Ricaro Escudero <escudero@securities.cl>
Subject: Re: Parsing through Multiple text lines
Message-Id: <37FDF49E.4FAF3AFE@securities.cl>


--------------35EECA7E1FDCC1FB7552BC27
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This code is operating:

#!/usr/bin/perl

while (<>) {                      #while reading in each line?
          #print "Line $. = <$_>\n";        #print out each line of file
          if (m/Elapsed Time = / || m/Elapsed Time:/) {
             print "Found\n";
             if (/([0-9]+)\s*\:\s*([0-9]+)\s*\:\s*([0-9]+)/) {
                ## better than [0-9]+ is to use \d+
                #does this match hr : min : sec ?
               print "found time\n";
               $hour=$1;
               $min=$2;
               $sec=$3;

               print "TIME= $1:$2:$3\n";
               print "TIME= " . sprintf("%02d:%02d:%02d",$1,$2,$3). "\n";
            }
         }
}


Your very first problem was that your text files contains two spaces
between
the digit and the semicolon  "0__:__9__:__3". That is why your regexp
don't matched it.

If you look the code above,  I replaced your 1 space by \s*, but if you
like
you can put two hardcoded spaces too.

 ...and your original code was missing some curly braces.
:)
bye..

jtgr8guy@my-deja.com wrote:

> Hi there,
> I'm new to perl and I havent' been able to find answers specific
> to my questions..
> Any and all help would be greatly appreciated..
> I have this below as part of a text file..
>
> Elapsed Time =  0  :  9  :  4
>
>  Total Tests  =  13
>  Total Passed =  13
>
>      Microsoft Upgrade 2000 for the Test Passed !
> *
> -------------------------------------------------------
> I read in the file and matched "Elapsed Time = ". This should move the
> cursor right before the 0 : 9 : 4, but as I tried to match the time and
> use parentheses to group the hr, min,and sec. It didnt' seem to match
> the time even if it's in this format that I specified (hr : min : sec)
> to match. Please take a look at this code and see if I'm matching this
> correctly...  Also, how would I read in each line one at a time? (while
> <>)?  Should I read each line into an associative array starting at
> Elapsed Time and then parse it?
>
> while (<INFILE>) {                      #while reading in each line?
>       #print "Line $. = <$_>\n";        #print out each line of file
>                 if (m/Elapsed Time = / || m/Elapsed Time:/) {
>                    print "Found\n";       #need to start reading line
> by line and parse thru..
>                    if (m/([0-9+]) : ([0-9]+) : ([0-9]+)/) {
>                       #does this match hr : min : sec ?
>                         print "found time";
>                         $hour=$1;
>                         $min=$2;
>                         $sec=$3;
>                         print "$1";
>                    }
>             #How do I go to the next line to parse thru?
> I want to eventually output :
> Microsoft Upgrade 2000, 13, 13, 0hrs 9min 4secs,
> so I want to parse thru these lines and store the field data into
> scalars.  Once again, thanx in advance for all the suggestions.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

--------------35EECA7E1FDCC1FB7552BC27
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
This code is operating:
<p><tt>#!/usr/bin/perl</tt><tt></tt>
<p><tt>while (&lt;>) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#while reading in each line?</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #print "Line
$. = &lt;$_>\n";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #print out each
line of file</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (m/Elapsed
Time = / || m/Elapsed Time:/) {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "Found\n";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (/([0-9]+)\s*\:\s*([0-9]+)\s*\:\s*([0-9]+)/) {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
## better than [0-9]+ is to use \d+</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#does this match hr : min : sec ?</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "found time\n";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$hour=$1;</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$min=$2;</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$sec=$3;</tt><tt></tt>
<p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "TIME= $1:$2:$3\n";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "TIME= " . sprintf("%02d:%02d:%02d",$1,$2,$3). "\n";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>}</tt>
<br>&nbsp;
<p>Your very first problem was that your text files contains two spaces
between
<br>the digit and the semicolon&nbsp; "0__:__9__:__3". That is why your
regexp
<br>don't matched it.
<p>If you look the code above,&nbsp; I replaced your 1 space by \s*, but
if you like
<br>you can put two hardcoded spaces too.
<p>...and your original code was missing some curly braces.
<br>:)
<br>bye..
<p>jtgr8guy@my-deja.com wrote:
<blockquote TYPE=CITE>Hi there,
<br>I'm new to perl and I havent' been able to find answers specific
<br>to my questions..
<br>Any and all help would be greatly appreciated..
<br>I have this below as part of a text file..
<p>Elapsed Time =&nbsp; 0&nbsp; :&nbsp; 9&nbsp; :&nbsp; 4
<p>&nbsp;Total Tests&nbsp; =&nbsp; 13
<br>&nbsp;Total Passed =&nbsp; 13
<p>&nbsp;&nbsp;&nbsp;&nbsp; Microsoft Upgrade 2000 for the Test Passed
!
<br>*
<br>-------------------------------------------------------
<br>I read in the file and matched "Elapsed Time = ". This should move
the
<br>cursor right before the 0 : 9 : 4, but as I tried to match the time
and
<br>use parentheses to group the hr, min,and sec. It didnt' seem to match
<br>the time even if it's in this format that I specified (hr : min : sec)
<br>to match. Please take a look at this code and see if I'm matching this
<br>correctly...&nbsp; Also, how would I read in each line one at a time?
(while
<br>&lt;>)?&nbsp; Should I read each line into an associative array starting
at
<br>Elapsed Time and then parse it?
<p>while (&lt;INFILE>) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#while reading in each line?
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #print "Line $. = &lt;$_>\n";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#print out each line of file
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (m/Elapsed Time = / || m/Elapsed Time:/) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "Found\n";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #need to start reading
line
<br>by line and parse thru..
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if (m/([0-9+]) : ([0-9]+) : ([0-9]+)/) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#does this match hr : min : sec ?
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "found time";
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$hour=$1;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$min=$2;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$sec=$3;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$1";
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#How do I go to the next line to parse thru?
<br>I want to eventually output :
<br>Microsoft Upgrade 2000, 13, 13, 0hrs 9min 4secs,
<br>so I want to parse thru these lines and store the field data into
<br>scalars.&nbsp; Once again, thanx in advance for all the suggestions.
<p>Sent via Deja.com <a href="http://www.deja.com/">http://www.deja.com/</a>
<br>Before you buy.</blockquote>
</html>

--------------35EECA7E1FDCC1FB7552BC27--



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

Date: Fri, 08 Oct 1999 16:05:26 +0200
From: Daniel Krajzewicz <krajzewicz@inx.de>
Subject: PDFlib size settings
Message-Id: <37FDFA26.51DFD78D@inx.de>

Hello there !!!

Has someone already worked with the PDF-library ??
If yes : in which pysical units is the size specified ?
Is it centimer, inch or what ?
Do someone know how to encode the german DIN A4-norm ?

thanks,
Daniel Krajzewicz


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

Date: Fri, 08 Oct 1999 15:38:31 GMT
From: Ilya <ilya@speakeasy.org>
Subject: Re: Question about alarm and run away processes
Message-Id: <rvs3vnvh1s13@corp.supernews.com>

In comp.lang.perl.misc M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
> Start with the FAQ entry, which I found in seconds with
> 'perldoc -q timeout':

> perlfaq8:  How do I timeout a slow event?

> and then the references therein.


Thanks, but you are making a bad assumption that I haven't already looked at
the entry.  I even got the Sys::AlarmCall module. I did not find it clear
enough, that's why I asked here.


	==============================================================
	Paper money eventually returns to its intrinsic value -- zero.
                 				  -Voltaire
	==============================================================


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

Date: Fri, 08 Oct 1999 16:46:54 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Read email through web
Message-Id: <xRH+N27+PaqhTRKbTt47J9y3jfiJ@4ax.com>

On Fri, 08 Oct 1999 09:04:08 GMT, xyptilon@my-deja.com wrote:

>Can somebody help me on how i should write a program that can
>connect to a mailserver and read the mail from there ?
>
>Can somebody please point me in the right direction ?

Try looking at the Mail::POP3Client.pm module avaialbe from CPAN
<http://seach.cpan.org>.

hth,

Dave...
--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>


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

Date: Fri, 08 Oct 1999 16:44:29 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: sendmail help
Message-Id: <oQ=+N6ZZcqdcQ5SgWdTukkyqmsnu@4ax.com>

On 08 Oct 1999 08:35:20 GMT, ghml@aol.com (GHML) wrote:

>I need some help with forms and sendmail. I would like to tweak my cgi mail
>script so that it does MORE than just the following:
>
>foreach $key (keys(%FORM)) {
>print MAIL "$key = $FORM{$key}\n"; }
>
>That basically prints out whatever form elements you have specified in your
>HTML code. This is very basic and very annoying. If a line is left blank, it
>prints that line. For example, say the user leaves the comments section blank.
>We get this:
>
>Name: Johnny Smith
>State: New York
>Comments:
>
>I'm sure there's some way to specify in the cgi script for it to omit blank
>entries. Something like:
>
>while $FORM{$key} is not equal to " " or zero or null, then don't print.

Do you mean something like

foreach $key (keys(%FORM)) {
print MAIL "$key = $FORM{$key}\n" if $FORM{$key};
}


>I am unclear as to what the exact syntax would be, but I'm sure there is a way.
>Also, do you know of any way to present the email form data in exactly the same
>order as it appeared on the HTML page? I know you can type in the cgi script
>exactly what you want to appear like:
>
>print MAIL "$somestring"
>print MAIL "$someotherstring"
>
>But that is very confining. I have one HTML page set up like so:
>
>#1 Checkbox...then a TextField
>#2 Checkbox...then a TextField
>Name
>Email Address
>#3 Checkbox...then a TextField
>#4 Checkbox...then a TextField
>Submit Button
>
>The generated email looks insane. For some reason the email address comes
>first, then the #3 (blank) text field, then the name, then the #1 checkbox,
>etc. There is no order whatsoever.

Hashes are unordered by nature. Perhaps you could do something like
this:

my @fields = q/CheckBox1 TextField1 CheckBox2 TextField2/;  # etc...

foreach (@fields) {
  print MAIL "$key = $FORM{$_}\n" if $FORM{$_};
}

>Can anyone help me with this? Or at least refer me to a website that deals with
>precise email/sendmail formatting? Thanks in advance!

hth,

Dave...

--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>


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

Date: Fri, 08 Oct 1999 15:48:17 GMT
From: xxxxx@cris.com (J. A. Mc.)
Subject: Re: tool to convert BMPs to GIFs programatically?
Message-Id: <3804117b.1528519@news2.lvdi.net>

On Thu, 7 Oct 1999 18:00:02 +0200, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:

>On Thu, 7 Oct 1999, J. A. Mc. wrote:
>
>> On 7 Oct 1999 04:05:01 -0500, abigail@delanet.com (Abigail) wrote:
>> 
>> >Scott McMahan (scott@aravis.softbase.com) wrote on MMCCXXVI September
>> >MCMXCIII in <URL:news:EDpK3.1178$H32.71815@newshog.newsread.com>:
>> >__ 
>> >__ But GIFs are patent-protected, or something, and require a license
>> >__ from whoever has the legal rights to them, aren't they? Can you
>> >__ make freeware that supports GIFs without having to pay
>> >__ for the rights to them?
>> >
>> >Yes.  But you cannot make everything.
>
>> Wanna bet? <G>
>
>I can't help suspecting that there has been a failure of information
>transfer here.  I interpreted Abigail's comment as referring back the 
>earlier point made, that there is nothing preventing you from creating
>GIF format, since the patent claims refer to a specific compression
>algorithm, and you don't have to use that algorithm.  (I'm sure Abigail
>will be quick to correct me if I misinterpreted the message ;-)
>
>> Seriously, there is a suite of programs from a JPEG group that will
>> convert any jpg to a bmp or V.V. - on the fly. 
>
>An amusing party trick, but what use in this context?  Images that are
>good for GIF or PNG representation are usually very unsuitable as JPEGs,
>and vice versa (see Tom Lane's JPEG FAQ). 
>
This 'context' as you put it, is the original question of:

"I want to convert some BMPs to GIFs using code, without any user
interaction.
Is there a utility that is scriptable, or batchable, or supports
automation
to do this?
Ideally it would be freeware and re-distributable...
Thank you,

- Colin Reinhardt"

My thought was thay perhaps he could use the .jpg form instead, and
explained one such usage.

No, it's NOT a party trick, just because _you_ have no use for it.



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

Date: Fri, 08 Oct 1999 16:23:42 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: What is THE book for PERL?
Message-Id: <TAz+N4EFBqOTEJqjQJKSMFrjCMQs@4ax.com>

On Fri, 08 Oct 1999 08:03:04 +0100, Johnny 'Loopy' Ooi
<jjyooi@dcs.qmw.ac.uk> wrote:

>Can anyone in the know tell me the _best_ book to read/buy for research
>and reference into PERL?

I wrote an article about Perl books in Issue 4 of PerlMonth
<http://www.perlmonth.com>. You might find that interesting.

Dave...

--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>


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

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


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