[19099] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1294 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 12 18:05:38 2001

Date: Thu, 12 Jul 2001 15:05:14 -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: <994975513-v10-i1294@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 12 Jul 2001     Volume: 10 Number: 1294

Today's topics:
    Re: =?ISO-8859-1?Q?=D5=EE=F2=E8=F2=E5 =EF=EB=E0=F2=E8=F <uri@sysarch.com>
    Re: Active State <mischief@velma.motion.net>
    Re: Active State <wsegrave@mindspring.com>
    Re: Causing a slow page delivery (on purpose) (Scott Porter)
    Re: easy multi-file find & replace? (Craig Berry)
        enum <joe@benburb.demon.co.uk>
    Re: enum <uri@sysarch.com>
        Example needed for Win32::OLE and Excel (Ross)
        FAQ: Perl in Magazines <faq@denver.pm.org>
    Re: forking ChangeNotify's <neil@alaweb.com>
        newbeeeeeee question <dwhite@icimail.com>
        newbie problem with dbm (S_Moles)
        Printing Everything After A Certain Point (Josh Geller)
    Re: Printing Everything After A Certain Point (Eric Bohlman)
    Re: Problems moving from an Apache server to a Windows  <aaronb@ukans.edu>
    Re: Recommendations for a 2nd book on Perl (JR)
    Re: Recommendations for a 2nd book on Perl (JR)
    Re: Recommendations for a 2nd book on Perl (JR)
    Re: Sending Attachments Via Sendmail <trashay1@hotmail.com>
    Re: sendmail based on a state <andras@mortgagestats.com>
    Re: Text variable containing '$' <mjcarman@home.com>
    Re: Using a variable in a regular expression <gnarinn@hotmail.com>
    Re: Using a variable in a regular expression <uri@sysarch.com>
    Re: Using a variable in a regular expression (Tad McClellan)
    Re: Using a variable in a regular expression (Jay Tilton)
    Re: Where is MD5 (Otto Wyss)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Jul 2001 18:40:26 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: =?ISO-8859-1?Q?=D5=EE=F2=E8=F2=E5 =EF=EB=E0=F2=E8=F2=FC =E7=E0  =EC=EE=E1?= 	=?ISO-8859-1?Q?=E8=EB=FC=ED=FB=E9  =CC=C5=CD=DC=D8=C5=3F!=3F!=3F!?=
Message-Id: <x766cyxa79.fsf@home.sysarch.com>


and your perl question is?

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Thu, 12 Jul 2001 18:59:08 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Active State
Message-Id: <tkrsrsspu9mff4@corp.supernews.com>

Tim Schmelter <tschmelter@statesman.com> wrote:
> Drew wrote:

>> "Adam Stewart" <Stewy@Chartermi.net> wrote in message news:<tkoose7di0467d@corp.supernews.com>...
>> > For a while now I have been interested in learning perl. So I recently

That's good.

>> > installed Active State Perl on my computer. My operating system is Windows
>> > 98, just so you know. First thing is it says to run there example program to

That's, um, passable.

>> > make sure it is working correctly. Now the problem is where do I run this
>> > program from? It says to type <perl example.pl> at the command line, but it
>> > doesnt say where this command line is, and i've looked all over with out
>> > success.

Perhaps before you learn Perl you should learn how to use the OS on your
computer. No, I'm not insulting you. I'm just saying life's going to be
easier and much more pleasant if you learn how to use software before
learning to write it.

>> >
>> > Does anyone understand what I am saying? Your help is appreciated. Actualy I
>> > would prefer for you to email me than to respond here as I may not get back
>> > here for a few days.

If the question is here, the answer is here. This is a public discussion
group, not a private tutoring service for your benefit.


>> "Command line" refers to does command prompt.  click "start" -> "run"
>> -> type "command".  use the CD command to get the directory where the
>> file is.  then type "perl example.pl".

This should help the OP, but I don't think it will help much. It's difficult
to learn to program if you don't know how to use the tools given.

> I don't know about anyone else, but I actually *felt* myself lock into a generation gap reading this
> thread. :-(>>>~ (Which is the emoticon for "I've got a long gr[ea]y beard", I'm going to say.)

Generation gap? I'm not sure about that... I'm only 25, and my first computer
had 48k of RAM and built-in BASIC. My first PC compatible came with a 20Mhz
processor, 1 meg of RAM, a 40-meg hard drive, 5 1/4" and 3 1/2" floppies,
and an EGA video system. It ran DOS 5.0 and eventually 6.2 rather well,
but no Windows. I think maybe it's more of a geekiness gap than anything.
All these newcomers just weren't interested in computers before the
Pretty Picture Revolution made it the PCs.

Chris

-- 
Where there's a will, there's a lawyer.



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

Date: Thu, 12 Jul 2001 13:58:26 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Active State
Message-Id: <9iksfl$rqe$1@slb1.atl.mindspring.net>

"Adam Stewart" <Stewy@Chartermi.net> wrote in message
news:tkoose7di0467d@corp.supernews.com...
> For a while now I have been interested in learning perl. So I recently
> installed Active State Perl on my computer. My operating system is Windows
> 98, just so you know. First thing is it says to run there example program
to
> make sure it is working correctly. Now the problem is where do I run this
> program from? It says to type <perl example.pl> at the command line, but
it
> doesnt say where this command line is, and i've looked all over with out
> success.
>
> Does anyone understand what I am saying? Your help is appreciated. Actualy
I
> would prefer for you to email me than to respond here as I may not get
back
> here for a few days.
>
> Thank you,
> Stewyyyyyyyy
>
>

In Win9X, (Click on) "Start + Program + MS-DOS Prompt" will start up a
window with the command line you need.

Bill Segraves
Auburn, AL




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

Date: Thu, 12 Jul 2001 20:17:25 GMT
From: scott@nospamthankx.javascript-games.org (Scott Porter)
Subject: Re: Causing a slow page delivery (on purpose)
Message-Id: <3b4dffe8.2075328@news.freeserve.co.uk>

On Wed, 11 Jul 2001 17:39:59 -0400, Benjamin Goldberg <goldbb2@earthlink.net> wrote:

>Scott Porter wrote:
>> 
>> I'm using the apache server on Linux; my goal is to delivery a page
>> incrementally to the browser, so it can delivery constantly changing
>> data as a "stream". While this works fine with a java app, bypassing
>> apache, it doesn't give the required results under apache. The page
>> shows no data until the perl script exits. Is it possible to send
>> content that forces apache to flush whatever the perl script has
>> passed on to the browser, or is it impossible?
>> 
>> The reason for having to serve via apache is because my web host
>> doesn't allow java servlets, or "persistant" scripts (which kind of
>> rules out writing a daemon!)
>
>There are a number of possible reasons.
> * Consider is $|, which controlls buffering.  Turn it off if you want
>to avoid buffering.
> * If you are ending lines with \n, and the browser is reading lines
>split on \r\n, it will not display until it either sees a \r\n or an
>EOF.
> * If you have some piece of html which your browser can't display until
>it's recieved all of it.  Tables are one of the most common sources of
>this problem -- to fix it, you need a COL or COLGROUP tag.  Images are
>similar -- add a width and a height.
> * A proxy may be present, possibly doing some buffering itself.  How to
>turn off buffering there depends on the proxy.

Still no joy... There's no proxy in the way, as I'm testing via a linux server on my
home network. I just tried viewing the page using lynx (for anyone unfamiliar, it's a
text-mode web browser that runs from a shell prompt), and I can see the page IS being
delivered to the browser slowly; lynx shows bytes received as they come through; but
even lynx waits until it's all delivered before displaying the page! So it appears I
have to send out something else?

Here's my test script, as you can see, I'm adding full headers before the content.
I've also tried "Connection: close", sending a zero byte after every line, and
setting the content length to 2:

#!/usr/bin/perl -w

use strict;

$| = 1;
my $crlf = "\015\012"; # \r\n
print "Content-Length: 90000\n";
print "Connection: open\n";
print "Content-type: text/plain", $crlf x 2;
for( 1..5 ) {
        print "x" . "\012";
        sleep 1;
        print "y" . $crlf;
        sleep 1;
}

Any other thoughts? :-)

Anyone? :-))



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

Date: Thu, 12 Jul 2001 21:47:53 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: easy multi-file find & replace?
Message-Id: <tks6o9spcjt176@corp.supernews.com>

Frank Nospam (yahoo_com@francis.uy) wrote:
: I'm sure this is in an FAQ somewhere, but I haven't found it yet.
:  If someone just points me to the correct one, that would be great.
: 
: What's an easy way to do a find and replace (such as changing
:  /\bfoobar/ to /fubar/) on all text files in a folder hierarchy
:  (such as 'public_html' in an IRIX account)?

If you can identify the text files by pattern (say, they all end in
 .html), this should do it from the shell:

  find public_html -name '*.html' -exec perl -pi -e 's/foobar/fubar/' {} \;

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Brute force done fast enough looks slick."
   |             - William Purves


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

Date: Thu, 12 Jul 2001 18:56:02 +0100
From: Joe McCool <joe@benburb.demon.co.uk>
Subject: enum
Message-Id: <3B4DE4B2.26B560E@benburb.demon.co.uk>

Please,

how might I implement enum a la C, in perl ?

TIA

Joe



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

Date: Thu, 12 Jul 2001 18:21:21 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: enum
Message-Id: <x78zhuxb31.fsf@home.sysarch.com>

>>>>> "JM" == Joe McCool <joe@benburb.demon.co.uk> writes:

  JM> how might I implement enum a la C, in perl ?

cpan has one. search it.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 12 Jul 2001 13:54:27 -0700
From: swan@peakpeak.com (Ross)
Subject: Example needed for Win32::OLE and Excel
Message-Id: <7288d820.0107121254.1b2d2537@posting.google.com>

Hi,

I've been spending the morning reading FAQ's
but haven't found a example where a existing
excel file is openned and the row column contents
of the spread sheet are read by the Perl program.

Thanks,
Ross


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

Date: Thu, 12 Jul 2001 18:17:02 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Perl in Magazines
Message-Id: <yQl37.66$T3.191778816@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  Perl in Magazines

    The first and only periodical devoted to All Things Perl, *The Perl
    Journal* contained tutorials, demonstrations, case studies,
    announcements, contests, and much more. *TPJ* had columns on web
    development, databases, Win32 Perl, graphical programming, regular
    expressions, and networking, and sponsored the Obfuscated Perl Contest.
    Sadly, this publication is no longer in circulation, but should it be
    resurrected, it will most likely be announced on http://use.perl.org/ .

    Beyond this, magazines that frequently carry high-quality articles on
    Perl are *Web Techniques* (see http://www.webtechniques.com/),
    *Performance Computing* (http://www.performance-computing.com/), and
    Usenix's newsletter/magazine to its members, *login:*, at
    http://www.usenix.org/. Randal's Web Technique's columns are available
    on the web at http://www.stonehenge.com/merlyn/WebTechniques/ .

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           02.12
-- 
    This space intentionally left blank


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

Date: Thu, 12 Jul 2001 13:15:14 -0500
From: "Neil" <neil@alaweb.com>
Subject: Re: forking ChangeNotify's
Message-Id: <tkrqao1nrp11fc@corp.supernews.com>

Thanks ! I will dig out my IO::Select docs and see what I can get
accomplished !

I am not entirely sure what the code you supplied does  - so that is my
first task....

The second is to see if I can use it for other "watcher" events as I have
some that watch a directory for any new files (messages) and then processes
those....

I guess what I am trying to say is that I am attempting to "spawn" a number
of seperate autonamous processes - that I want to be able to interact, at
the least by a gracious shutdown, at the most by "message" passing. They
don't need to share variables etc with the parent. The "message passing" can
be accomplished by dropping a file in the msg directory, if I can spawn a
"message watcher".

All of the watcher segments work perfectly as stand alone scripts - I would
just like to create a "manager script" that can start a "bunch" of "
watchers - except they seem to wait indefinitely on each other, as expected,
or I can set the timeout, and create a change that an event occurs between
"lookups".

I do appreciate the help - thanks !

Thanks,
Neil


"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3B4BA75F.878EA8E8@earthlink.net...
> Neil wrote:
> >
> > I have a piece of code below that "watches" to see if  a log file on a
> > certain machine on our network changes size and outputs (to the
> > screen) what the changes are.  Basically a "poor mans tail -f".
> >
> > This is great as I *can* output it to  HTML format so I can track this
> > log from home etc.
> >
> > However - I want to track several logs and while I *can* write several
> > scripts - I would like to incorporate all "watching" into one script.
> > I was thinking if I had a process that "fork"ed each of the watchers -
> > and can kill them when the main script was called to exit. Each
> > "watcher" is responsible for carrying out it's own actions (ie
> > creating an HTML page, sending an e-mail etc.) and resuming watching.
> >
> > I am on a Win32 system. I have not attempted forking yet - but have
> > read as much as I can about fork in the docs and several O'Reilly
> > books - I am just trying to avoid any heartache and lost time before I
> > get there ...LOL
> >
> > Any ideas about the "best way" to handle this ?
>
> Win32 does not support real forking, but does manage to simulate it
> pretty durn well.  So if you want to use a forking solution, then go
> ahead and do it.
>
> #! perl.exe -w
> use strict;
> use IO::Select;
> for my $filename (@ARGV) {
> if( my $pid = fork ) {
> push @children, $pid;
> next;
> }
> die "Couldn't fork: $!\n" unless defined $pid;
> open my $fh, "<", $filename or
> die "Couldn't open $filename: $!";
> seek $fh, my $size = -s $fh;
> my $select = IO::Select->new $fh;
> while( $select->can_read ) {
> $size += read $fh, my $contents, (-s $fh) - $size;
> print $contents;
> }
> die "Error in select: $!\n";
> }
> while( -1 != my $pid = wait ) {
> for( 0 .. $#children ) {
> next unless $children[$_] == $pid;
> print "Tail on file $ARGV[$_] died: $?\n";
> }
> }
>
> Or, you could use the full functionality of select, and avoid forking:
>
> #! perl.exe -w
> use strict;
> use IO::Select;
>
> my %size;
> my $select;
> for my $filename (@ARGV) {
> open my $fh, "<", $filename or
> die "Couldn't open $filename: $!";
> seek $fh, $size{$fh} = -s $fh;
> $select->add $fh;
> }
> while( my @ready = $select->can_read ) {
> for my $fh (@ready) {
> $size{$fh} +=
> read $_, my $contents, (-s $fh) - $size{$fh};
> print $contents;
> }
> }
> die "Error in select: $!\n";
>
> --
> The longer a man is wrong, the surer he is that he's right.




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

Date: 12 Jul 2001 10:08:17 -0700
From: Dan White <dwhite@icimail.com>
Subject: newbeeeeeee question
Message-Id: <9ikli10srd@drn.newsguy.com>

Hello all, 

what I am trying to achieve is to take a group of file (ie log file from a
directory and get the head -7 and tail -20 from each log file. and place that
file into a tmp file in another directory. anot sure how to do this in perl.
where is what I have so far bit it dosent work hangs on the systemn commands

thanks 
Dan 

#!/usr/local/bin/perl -w
@filenames = <*.log>;
foreach $a (@filenames) {
                        system('head -7  $a > $a.tmp');
                        system('tail -20 $a >> $a.tmp');
                        print "$a\n";
                        }

Dan White
programmer/analyst



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

Date: Thu, 12 Jul 2001 18:04:03 +0000 (UTC)
From: S_Moles@brown.edu (S_Moles)
Subject: newbie problem with dbm
Message-Id: <9ikoqj$7lh$1@saturn.services.brown.edu>

I have ActiveState Perl 5.6.1 installed on two machines, a networked 
machine running Win98 (work) and a nonnetworked machine running Win95 
(home).  I am having trouble creating/using a dbm hash on the Win98 
machine.  It seems to be related to access permissions, but I don't know 
what in particular is wrong.  Any help would be appreciated.

I have a small test script "testDBMOpen.pl."  Here's the entire thing:

  #!c:/perl/bin/perl -w

  dbmopen (%dbmHash, "myDB", 0666) || 
      warn "Could not open DBM database: $!";

  $dbmHash{"Apple"} = "Red";

  dbmclose(%dbmHash);
    

In order to test the script on both of my machines, I put it on a Zip 
disk.  When I run it on the Win95 machine at home, it works fine.  When I 
run it on my Win98 machine at work (from the Zip disk), I get the 
following:

  (538) d:/perlScripts/test @ 13:18:59 ->perl testDBMOpen.pl 
  Could not open DBM database: Permission denied at testDBMOpen.pl line 3.

  (539) d:/perlScripts/test @ 13:19:15 ->ls -l
  drw-rw-rw--      0 Thu Jul 12 13:53:02 2001  .
  drw-rw-rw--      0 Thu Jul 12 13:53:02 2001  ..
  -rw-rw-rw-a    167 Thu Jul 12 13:50:54 2001  testdb~1.pl
  -rw-rw-rw-a   3114 Thu Jul 12 14:19:16 2001  mydb.pag

The myDB,dir file is not created.
                                                   
I get the same results whether I am run it from the Zip drive or whether I 
copy it over to my local hard drive and run it there.

If I change the script to accept an input file redirected to STDIN and 
also tie the hash to files on a server (drive mapped to a file server), I 
get different but still bad results.  The script looks like this:

   #!c:/perl/bin/perl -w

   dbmopen(%dbmHash, "i:/TestStuff/myDB2", 0666) || die "cannot open DBM 
myDB2: $!";

   while (<>) {
       ($key, $value) = split/\t/;
       $dbmHash{$key} = $value;
   }

   dbmclose(%dbmHash);

   exit 0;

The result is this:

  (567) d:/perlScripts/test @ 13:49:58 ->perl testDBM2.pl < testDBM2.dat
        0 [main] perl 630197 open_stackdumpfile: Dumping stack trace to 
        PERL.EXE.stackdump
  bash: [478225: 1] tcsetattr: Not a character device
  Segmentation fault (core dumped)
  (568) d:/perlScripts/test @ 13:50:31 ->cd i:/testStuff/
  (569) i:/testStuff @ 13:50:36 ->ls -l
  drw-rw-rw--      0 Sun Feb 06 01:28:15 2106  .
  drw-rw-rw--      0 Sun Feb 06 01:28:15 2106  ..
  -rw-rw-rw-a   3114 Thu Jul 12 14:50:30 2001  mydb2.pag
  -rw-rw-rw-a   3114 Thu Jul 12 14:50:12 2001  mydb2.dir


If anyone really wants to see it, here is the content of 
PERL.EXE.stackdump:

Exception: STATUS_ACCESS_VIOLATION at eip=6A9C39A3
eax=00000000 ebx=045B909C ecx=000033EB edx=045B909C esi=04570258 
edi=045B9098
ebp=0253F76C esp=0253F734 program=C:\CYGWIN\BIN\PERL.EXE
cs=017F ds=0187 es=0187 fs=5497 gs=0000 ss=0187
Stack trace:
Frame     Function  Args
0253F76C  6A9C39A3  (0000000A, 045B909C, 045B9098, 0000001D)
0253F79C  6A9C3518  (04570258, 0000000A, 0253F7FC, 6064F58F)
0253F7FC  6A9C218A  (04570258, 04578328, 00000005, 04578728)
0253F82C  6A9C157A  (04570258, 04578328, 00000005, 04578728)
0253F89C  6BF81BB3  (045A3558, 00000080, 0253F91C, 606119C9)
0253F91C  60611BE7  (0457F468, 61090284, 0253F93C, 605C3DCE)
0253F92C  6060BF62  (04572938, 6060EB3C, 0253FABC, 605C3976)
0253F93C  605C3DCE  (0253FA9C, 00000000, 0253FABC, 605C3872)
0253FABC  605C3976  (0457F468, 00000042, 0253FB0C, 6060440D)
0253FADC  605C37BE  (60605C93, 00000002, 0457116C, 60618626)
0253FB0C  60605A92  (0457116C, 0457DF28, 60605C93, 00000002)
0253FB4C  60605D51  (0457116C, 0457DF28, 04574014, 00000000)
0253FB7C  606041A4  (0457116C, 0457E63C, 00000002, 00000000)
0253FBAC  6060C326  (00000000, 610903E8, 0253FBCC, 605C353D)
0253FBBC  6060BF62  (00000000, 00000002, 0253FCFC, 605C3277)
0253FBCC  605C353D  (00000001, 00000000, 0253FCE4, 605FFD6B)
End of stack trace (more stack frames may be present)
                                                                   

Thanks!!



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

Date: Thu, 12 Jul 2001 18:30:59 GMT
From: dclxvi@best.com (Josh Geller)
Subject: Printing Everything After A Certain Point
Message-Id: <D1m37.10957$Up.329360@sea-read.news.verio.net>

What I am trying to do is print out everything in a filehandle after a
certain point.

What I am getting is:

Use of uninitialized value at ./Build/cdiffer.pl line 141, <INPIPE>
chunk 41.


Here's a code fragment:

___

open(INPIPE, "$firstpipe|") || die "Cannot open pipe $firstpipe: $! \n";
chdir($workdir);
foreach (<INPIPE>) {
    if(m/^description:.*$/) {
        undef $/;
        $log = <INPIPE>;
        print $log;
    } else {
        next;
    }
}
$/ = $dollarslash;
close(INPIPE);

___


Any thoughts?







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

Date: 12 Jul 2001 18:42:27 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Printing Everything After A Certain Point
Message-Id: <9ikr2j$h4q$1@bob.news.rcn.net>

Josh Geller <dclxvi@best.com> wrote:
> What I am trying to do is print out everything in a filehandle after a
> certain point.

> What I am getting is:

> Use of uninitialized value at ./Build/cdiffer.pl line 141, <INPIPE>
> chunk 41.


> Here's a code fragment:

> ___

> open(INPIPE, "$firstpipe|") || die "Cannot open pipe $firstpipe: $! \n";
> chdir($workdir);
> foreach (<INPIPE>) {

At this point, you've read everything from INPIPE into a temporary list 
which you're now iterating over.  INPIPE has reached EOF.

>     if(m/^description:.*$/) {
>         undef $/;
>         $log = <INPIPE>;

And here you're trying to read past EOF.

>         print $log;
>     } else {
>         next;
>     }
> }
> $/ = $dollarslash;
> close(INPIPE);

Your main problem is that you're reading everything into an array rather 
than going on line at a time; changing your foreach to a while will fix 
that.  I don't quote understand your logic, though: once you set $log, 
you'll still have read the entire file, so why aren't you explicitly 
breaking out of the loop?



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

Date: Thu, 12 Jul 2001 13:34:59 -0500
From: "Aaron Brown" <aaronb@ukans.edu>
Subject: Re: Problems moving from an Apache server to a Windows server
Message-Id: <9ikqbl$dqo$1@news.cc.ukans.edu>

"Kerry Shetline" <kerry@shetline.com> wrote in message
news:tgN17.4128$Pf6.2118870@typhoon.ne.mediaone.net...
> I tried an experiment, and reduced every CGI to this one line of code:
>
> print "***";
>
> Even this didn't always work. [ snip ]

Ouch.  Aside from this situation you mention, one other thing to pay
attention to is variable declaration.  Try 'use strict' - most of the times
I've had web server scripts that sometimes worked and sometimes didn't, it's
because my variables weren't properly localalized, and they were bleeding
all over each other.  IIS and Apache may very well handle instantiation
differently, causing code with the declaration problem to work on Apache but
not in IIS.

Just another thing to check.

 - Aaron

--
Aaron Brown
aaronb@sunflower.com
http://www.ku.edu/~aaronb





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

Date: 12 Jul 2001 13:37:11 -0700
From: tommyumuc@aol.com (JR)
Subject: Re: Recommendations for a 2nd book on Perl
Message-Id: <319333f5.0107121237.15c622d8@posting.google.com>

gnari <gnarinn@hotmail.com> wrote in message news:<994955013.394353818148375.gnarinn@hotmail.com>...
> In article <319333f5.0107120647.42e8c42e@posting.google.com>,
> JR <tommyumuc@aol.com> wrote:
> >  I've read many times that DBI
> >shouldn't be used for production--so that may be out
> 
> this is nonsense.
> what database are you using?
> 
> gnari


I'm going to have to create a large database (I haven't created it
yet).  So, what I've read about DBI is incorrect apparently.  DBI can
be used in a production environment.  I suppose I've read incorrect
information, which is one reason I asked the question--it didn't seem
correct to me either that DBI was created without production in mind. 
Thanks for letting me know that it is nonsense.


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

Date: 12 Jul 2001 13:43:52 -0700
From: tommyumuc@aol.com (JR)
Subject: Re: Recommendations for a 2nd book on Perl
Message-Id: <319333f5.0107121243.48b1d3da@posting.google.com>

usted@cyberspace.org (dave) wrote in message news:<e2c00ae.0107120809.16c877f4@posting.google.com>...
> > (I won't be able to use DBI, because the intranet database must be put
> > on an intranet production server and I've read many times that DBI
> > shouldn't be used for production--so that may be out, but I have
> > confidence somebody out there has a good idea how to handle large
> > intranet databases without DBI).
> 
> DBI shouldn't be used for production?  Really? What are the reasons
> behind this?
> 
> 
> I would recommend reading Programming the Perl DBI by Oreilly (strange
> that they devoted a whole book on a toy), actually reading every page
> of Programming Perl, Learning Perl, and the Perl Cookbook.  They are
> all really good books, written in most cases by the people who have
> developed what they are describing.
> 
> dave

I don't know exactly what the reason is behind why DBI shouldn't be
used for production (security and unstability are two words that come
to mind, though).  These "accusations," as may be, aren't necessarily
correct.  I didn't suggest that DBI was a toy--but I can understand
how you may feel that I suggested that it was if you've used DBI
extensively (I didn't intend any insult).  Thanks for letting me know
that DBI can indeed be used in a production environment.  I haven't
read every page of Programming Perl because it is a reference book and
the Perl Cookbook has plenty of good code that has given me some
ideas, but I don't have the time to read every page of that book right
now.  I'll look for Programming the Perl DBI by Oreilly on
bookpool.com.  Thanks for the suggestion.


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

Date: 12 Jul 2001 13:51:38 -0700
From: tommyumuc@aol.com (JR)
Subject: Re: Recommendations for a 2nd book on Perl
Message-Id: <319333f5.0107121251.787a1f9e@posting.google.com>

usted@cyberspace.org (dave) wrote in message news:<e2c00ae.0107120809.16c877f4@posting.google.com>...
> > (I won't be able to use DBI, because the intranet database must be put
> > on an intranet production server and I've read many times that DBI
> > shouldn't be used for production--so that may be out, but I have
> > confidence somebody out there has a good idea how to handle large
> > intranet databases without DBI).
> 
> DBI shouldn't be used for production?  Really? What are the reasons
> behind this?
> 
> 
> I would recommend reading Programming the Perl DBI by Oreilly (strange
> that they devoted a whole book on a toy), actually reading every page
> of Programming Perl, Learning Perl, and the Perl Cookbook.  They are
> all really good books, written in most cases by the people who have
> developed what they are describing.
> 
> dave

Dave--Other than the time factor, another reason that I haven't read
every page of Programming Perl is that it is too advanced for me.  I'm
relatively new to the language (and to programming, for that matter),
so many of the concepts presented in Programming Perl are beyond my
current level, which is why I need a good second book.  I think there
must be some mid-ground between Learning Perl and Programming Perl (I
bought Programming Perl based upon the stellar reviews it received at
bookpool.com--I should have read them more carefully).

Thanks.


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

Date: Thu, 12 Jul 2001 14:35:59 -0400
From: "Trash Holly" <trashay1@hotmail.com>
Subject: Re: Sending Attachments Via Sendmail
Message-Id: <3b4deb5c$1@post.newsfeeds.com>

*** post for FREE via your newsreader at post.newsfeeds.com ***

I am a lurker here on occasion, and I have posted helpful stuff for people -
but not lately.

Anyway, I want to give you EXTRA THANKS for this particular suggestion. The
way I had been doing this was ridiculous. I wrote a script that actually
went into a console based software package known as SCO MAIL, with a
redirected input that contained the needed escape commands, so that the
software did the actual attaching.

This is MUCH MUCH better.

THANK YOU AGAIN!!

PW/pw

"keng" <keng@spinalfluid.com> wrote in message
news:9g6lh1$eqh$1@dahlia.singnet.com.sg...
> one short way is to try this unix command
> uuencode filename.ext recieved_filename.ext | sendmail userid@company.com
>
>
> --
> regards
>
> "Antoine Hall" <AHALL5@nc.rr.com> wrote in message
> news:uVzV6.89650$e34.12231665@typhoon.southeast.rr.com...
> > Is there a way to attach files to an email when using Sendmail?  I want
to
> > be able to send an email to someone and attach log files but have the
> > process automatic using sendmail.  Can it be done?
> >
> > ==
> > 'Toine
> >
> >
> >
>
>




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 90,000 Newsgroups - 16 Different Servers! =-----


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

Date: Thu, 12 Jul 2001 15:43:57 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: sendmail based on a state
Message-Id: <3B4DFDFD.694E84D4@mortgagestats.com>



Eric Bohlman wrote:

> Andras Malatinszky <andras@mortgagestats.com> wrote:
>
> > Probably the best way is to use a hash to associate the states/regions with the
> > reps'  e-mail addresses, sort of like this
>
> > %reps={'Arizona' => 'joe.schmoe@arizonaisp.com',
> > 'Michigan' => 'bill@me.com',
> > 'Northeast' => 'jeff_waters@yankee.net'};
>
> Not with those curly braces, though.  You use curly braces when assigning
> to a hash *reference*; you use parentheses when assigning to a *hash*.  If
> warnings are enabled, your code will generate a complaint about assigning
> an odd number of elements to a hash.

Right, my bad.




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

Date: Thu, 12 Jul 2001 15:22:08 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Text variable containing '$'
Message-Id: <3B4E06F0.27AEC995@home.com>

"E.Chang" wrote:
> 
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
> <9ii2jd$igj$2@mamenchi.zrz.TU-Berlin.DE>:
> 
> >Perl lets you choose the delimiters in s/// expressions:
> >
> >    $in =~ s'\$'\$';
>
> I didn't realize that using a single quote for the delimiter changes
> the interplation behaviour of the right part of the substitution
> expression.

Don't feel bad -- neither did I. I know I've read that section of the
docs before, but for some reason that one sentence didn't stick. However
much you think you know about Perl, there's always another nugget of
wisdom out there.

> Thanks, mjc, for showing the solution with \\\$.  I tried two
> backslashes, thinking the first would escape the second, and
> discovered it did not but didn't have the sense to keep going.

The first did escape the second, the third one is to escape the $. Did
your test have warnings enabled?

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

$_ = 'my$table';
s/\$/\\$/;
print "$_\n";

__END__

Final $ should be \$ or $name at foo.pl line 5, within string
syntax error at foo.pl line 5, near "s/\$/\\$/"
Execution of foo.pl aborted due to compilation errors.

> Can you point me to the section of documentation so I can read
> more on this?

Er, well, not really. It's just a matter of how things behave in
double-quoted strings. Because \ is an escape char, you need to use \\
to get a literal \. But Perl expects $ to begin a variable name, so you
need to escape that, too, as \$. That's how we get the ugly \\\$. I like
the version using s''' much better, but the special case behavior forms
a trap for the novice.

-mjc


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

Date: Thu, 12 Jul 2001 17:49:26 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Using a variable in a regular expression
Message-Id: <994960166.512868074234575.gnarinn@hotmail.com>

In article <3b4dde5b.289465678@news.btinternet.com>,
Pete <Peter@angeltec.fsnetNOTTHIS.co.uk> wrote:
>Hi,
>
>I think I'm close with this but obviously not close enough!!
>
>This works :
>if($psk =~ m"(\d\d[A-Z][A-Z]\d\d\d\d)")
>	# 12AB3456 passes
>
>I'm trying to use a variable to represent the matching string:
>
>$pskformat = "m\"\(\\d\\d[A-Z][A-Z]\\d\\d\\d\\d\)\""
>
>This produces m"(\d\d[A-Z][A-Z]\d\d\d\d)" when I print it out but:
>if($psk =~ $pskformat)
>	# never passes
>

try 
  $pskformat = "(\\d\\d[A-Z][A-Z]\\d\\d\\d\\d\)" ;
  if($psk =~ m"$pskformat")
  
also look at docs:
perldoc perlop
look for qr

gnari


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

Date: Thu, 12 Jul 2001 18:20:56 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Using a variable in a regular expression
Message-Id: <x7bsmqxb3q.fsf@home.sysarch.com>

>>>>> "P" == Pete  <Peter@angeltec.fsnetNOTTHIS.co.uk> writes:

  P> Hi,
  P> I think I'm close with this but obviously not close enough!!

  P> This works :
  P> if($psk =~ m"(\d\d[A-Z][A-Z]\d\d\d\d)")

why use an alternate delimiter when you have no / in there?

also use quantifiers when you have more than 2 repeats of something

	$psk =~ /(\d\d[A-Z][A-Z]\d{4})/ 

  P> I'm trying to use a variable to represent the matching string:

  P> $pskformat = "m\"\(\\d\\d[A-Z][A-Z]\\d\\d\\d\\d\)\""

the m is not a part of the regex nor is the quotes inside. they are part
of the syntax of the match operator.

and use single quotes to eliminate the need for the backwhacking. but
even better, use the qr// operator.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Thu, 12 Jul 2001 14:58:30 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using a variable in a regular expression
Message-Id: <slrn9krsqm.jbi.tadmc@tadmc26.august.net>

gnari <gnarinn@hotmail.com> wrote:


>  $pskformat = "(\\d\\d[A-Z][A-Z]\\d\\d\\d\\d\)" ;


Yuck!


   $pskformat = '(\d\d[A-Z][A-Z]\d\d\d\d\)' ;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 12 Jul 2001 20:11:03 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Using a variable in a regular expression
Message-Id: <3b4e0101.240101547@news.erols.com>

On Thu, 12 Jul 2001 17:38:02 GMT, Peter@angeltec.fsnetNOTTHIS.co.uk (Pete)
wrote:

>I think I'm close with this but obviously not close enough!!
>
>This works :
>if($psk =~ m"(\d\d[A-Z][A-Z]\d\d\d\d)")
>	# 12AB3456 passes
>
>I'm trying to use a variable to represent the matching string:
>
>$pskformat = "m\"\(\\d\\d[A-Z][A-Z]\\d\\d\\d\\d\)\""

Not that it has anything to do with the solution, but you could skip all
that BS with escaping chars if you stuff the string between single quotes.

qr// is what you want.

  $pskformat = qr"(\d\d[A-Z][A-Z]\d\d\d\d)";
  if($psk =~ $pskformat) { #do something }



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

Date: Thu, 12 Jul 2001 23:01:14 +0200
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Re: Where is MD5
Message-Id: <1ewgfan.1uylxjh49fmeqN%otto.wyss@bluewin.ch>

> >perldoc MD5
> 
> actually , on my system this says (among other things):
> 
>   The MD5 module is depreciated.  Use Digest::MD5 instead.
> 
>   The current MD5 module is just a wrapper around the Digest::MD5
>   module.  It is provided so that legacy code that rely on the old
>   interface still work and get the speed benefit of the new module.
> 
> I guess you have not installed it.
It is/was installed (libdigest-md5-perl) but on Debian (testing) with
perl 5.6.1 => "No documentation..."

> >perldoc *MD5*
> 
> personally, i often use lthe command locate for this purpose.
> for example:  locate MD5.pm
> on your system you may have something different, but most have
> some way of searching for files
> 
That does not help if the name isn't exactly known. That is one of the
biggest problem a nonexpert has to face.

> >perldoc *
> >
> >to show any related modules? How can I see what modules are currently
> >installed?
> 
> perldoc perllocal
> 
I get => "No documentation..."

O. Wyss


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1294
***************************************


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