[7384] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1009 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 11 00:07:17 1997

Date: Wed, 10 Sep 97 21:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 10 Sep 1997     Volume: 8 Number: 1009

Today's topics:
     Re: C++Builder means Future. (Steve Mading)
     Re: Can Perl call external programs? (Stephen Frost)
     Computing How Much time has past between two times (Ryan Moore)
     Re: flock() time (Lutz Albers)
     Re: How to open a file for both read and write <ajohnson@gpu.srv.ualberta.ca>
     LIBWWW -  Command Line vs Web Browser (John Steele)
     Re: Making a Swiss-Army Knife HTML tool in Perl (T. Wheeler)
     performance & memory usage (Yuval Peduel)
     Re: performance & memory usage (Ilya Zakharevich)
     Re: perl -Dr  regex_debugger (Ilya Zakharevich)
     perl 5.004 seg faults (Graeme Merrall)
     Pipes in perl (Mark Cervarich)
     Re: Print an Image <carl2@mcgees.com>
     Recursive sorting (Paul Fisher)
     Re: Regexp a Yes or No question? (Gabor Egressy)
     Re: Saving state with CGI.pm (Mike Stok)
     Re: Split operator (Jim Michael)
     Re: What does "regexp *+ operand could be empty" mean? (Ilya Zakharevich)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 10 Sep 1997 22:28:09 -0500
From: madings@earth.execpc.com (Steve Mading)
Subject: Re: C++Builder means Future.
Message-Id: <5v7og9$6m7$1@earth.execpc.com>

Christopher Browne (cbbrowne@hex.net) wrote:

: On 7 Sep 1997 12:03:20 -0700, kaz@helios.crest.nt.com (Kaz Kylheku)
: wrote:
: >In article <3411F49F.C90A6740@MStarMedia.com>,
: >John Palmieri  <JohnP@MStarMedia.com> wrote:
: >>  It will be on IBM's AS/400 which is a UNIX derivitive.  I think

: >AS/400 is a UNIX derivative? What are you smoking?

: You missed the news that OS/400 was made POSIX compliant.  :-)

: Which means that it, like OS/390 and Windows NT, are all "UNIX."  (And
: yes, I know that that statement is somewhat troll-bait-like.  Sensible
: people will leave it alone.)  Or, perhaps more precisely, it means
: that OS/400 is *as much like UNIX* as are Windows NT and OS/390, which
: is "Usefully? Hardly at all..."

Okay, so I'm not sensible and I can't leave it alone :-) ...

But it said "UNIX derivative", not "UNIX compatable".  I take UNIX
derivative to mean that its design has Unix parentage.  Clearly it
does not.  The POSIX compliance was an afterthought.  UNIX compatable
and UNIX derivative are not the same thing.  Even with POSIX
compliance, OS/400 is no more a "UNIX derivative" than WABI is a
"Windows derivative".

Had the statement been "OS/400 is UNIX compatable", instead of
"UNIX derivative", then your bringing up POSIX compliance would
have been relevant.

-- 
Steve Mading:  madings@execpc.com   http://www.execpc.com/~madings



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

Date: 11 Sep 1997 03:21:26 GMT
From: frostbyt@shell01.ozemail.com.au (Stephen Frost)
Subject: Re: Can Perl call external programs?
Message-Id: <5v7o3m$4o$1@reader1.reader.news.ozemail.net>

Kenny Owens (kowens@stride.doe.gov) wrote:
: Can Perl call external programs besides c??  I need to call a FoxPro
: program from within Perl and pass some parameters.  Can this be done? 
: Do I need to do anything "special" to handle the parameters or the
: FoxPro program?  

G'day,

I had to do this some time back ... I just used `backtics` if I recall
correctly. Something like this should work (under NT anyway):

if ($command eq 'refresh') {
   $foxpro = 'c:\office\foxpro\vfp.exe d:\refresh\programs\refresh.prg';
   $output = `$foxpro`;
}

Give it a try.  You probably ought to use a system() call I guess ...
I'm not a Perl guru by a long stretch.

Good luck

Steve

Please remove 'shellNN.' from address when emailing or your mail will bounce


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

Date: 10 Sep 1997 16:30:18 -0700
From: carenry1@airmail.net (Ryan Moore)
Subject: Computing How Much time has past between two times
Message-Id: <341727F9.4AFA@airmail.net>

I am wanting a simple algorithm (if there is one) to compute how much
time has past since one time till another time. For example, I am
needing to write a program that will tell me that 22 Hours and 10
minutes have past between 2:50 and 1:00.  I have looked through all the
Date and Time Libraies and if they cover this I can't find it. 


Thanks Much

Ryan Moore


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

Date: Wed, 10 Sep 1997 10:56:08 +0200
From: lutz@muc.de (Lutz Albers)
Subject: Re: flock() time
Message-Id: <lutz-ya023480001009971056090001@news>

In article <3411E6B6.65F90D67@oaktree.net>, Jerry <jfitz@oaktree.net> wrote:

>How long does a second process keep attempting to access a file that has
>been flocked by a previous process?
>
>Is there a default time length, or is there a way to control this length
>of time (i.e., tell the second process to try for only 10 seconds before
>erroring out)?
>
>I have looked in the docs, and this group, and the archives, but still
>couldn't find the answer.

That might depends on the system call, but usually it will be blocked till
the lock goes away.

Besides, the second process will not 'try to access the file'. Upon calling
the flock on a already locked file the process will be blocked (kind of
stopped) by the kernel until the lock goes away.
It will join the long, long queue of other blocked processes in the system :-)

ciao
  lutz
--
Lutz Albers, lutz@muc.de, pgp key available from <http://www.pgp.net>
Do not take life too seriously, you will never get out of it alive.


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

Date: Wed, 10 Sep 1997 21:14:14 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: How to open a file for both read and write
Message-Id: <341753F6.416F5670@gpu.srv.ualberta.ca>

Charlie wrote:
> 
> Songtao Chen <songtao@nortel.ca> wrote
> > Could anyone tell me how to open a file for both
> > read and write ?
> 
> open(FH,"+>filename") || die "Cannot open filename\n";
> 

unless you care about what was in the file, in which
case you want to use +< instead of +>:

   open(FH,"+<filename")|| die "can't open filename $!";

see, perldoc -f open

regards
andrew


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

Date: Wed, 10 Sep 1997 22:56:24 GMT
From: john.steele@insyte.com (John Steele)
Subject: LIBWWW -  Command Line vs Web Browser
Message-Id: <5v78mf$f64$1@news.netrunner.net>

I don't consider myself to be a "newbie" to PERL, but an a neophyte.

I am trying to use the LIBWWW package to POST some data to a "foreign" website 
and extract the portion I want from the reply. It was surprisingly easy to get 
the package working with PERLIS (307) under WinNT.

I wrote a test script that POSTS to the target site and extracts the results 
and it works fine from the command line, but gives back 

        "RC: 500 (Internal Server Error) 
        Message: Unexpected EOF at C:\Program 
        Files\perl5\lib/LWP/Protocol/http.pm line 171"

when executed from a web browser. 

The program is modified from the excellent little "cookbook" that comes in the 
distribution. The "cookbook" code is in a subroutine along with the parameters 
for the POST needed by the foreign site. The sub is called, the reply is 
stripped to teh part we want and the results printed.

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

        print "HTTP/1.0 200 OK\r\n" if $ENV{PERLXS} eq "PerlIS";
        print "Content-type: text/html\n\n";

        &get_data();

        # fix up table that was given back to us to use on our site
        $table =~ s/<TD>/$td_form1/gi;

        print "<html><body>$flag";
        print "<center><table width=\"500\" border=\"0\">";
        print $table;
        print "</table></center>";

        print "</body></html>";

        exit;

sub get_data()
        {
        $target = 'http://www.xxxxxx.com';

        # target system parameters here 

        %form = (parameters);

        $ua = new LWP::UserAgent;

        my $req = new HTTP::Request 'POST', $target;
        $req->content_type('application/x-www-form-urlencoded');
        my $curl = url("http:");      # create an empty HTTP URL object
        $curl->query_form(%form);
        $req->content($curl->equery); # %form content as escaped query string

        $reply = $ua->request($req)->as_string;

        # do a dirty parse to pick up the table that is in the reply
        # returns everything inside the <TABLE>...</TABLE> block

        if ($reply =~ /<TH>Highest<\/tr>/ && $' =~ /<\/TABLE/)
                {
                $table = "$`";
                }

        return($table);

        # and return it 

        } 



I know the PERLIS is OK, its working with dozens of other browser initiated 
programs. And as I said, the script appears to be OK as it works from the 
command line.

Can someone give me a clue as to what is wrong here?

Thanks

John


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

Date: Wed, 10 Sep 1997 22:50:11 GMT
From: twheeler@m-net.arbornet.org (T. Wheeler)
Subject: Re: Making a Swiss-Army Knife HTML tool in Perl
Message-Id: <341723ae.192545085@news.stlnet.com>

I have done A LOT more scouting around and found scripts that do most
of these things already.  I have decided to integrate them a bit more
and create a common front-end rather than reinvent the wheel.

After it's done, I will post the location from which it may be FTP'ed.
Thanks to those who replied.  

Tom

>I am wanting to deelop a do-it-all perl tool that will take plain text
>files and create decent formatted HTML.  Once it is completed, I will
>post it in th epublic domain for all to use.
>
>I don't want to waste my time doing work that others have done. I have
>incorporated parts ofother tools I have seen on the net into this one.
>Maybe you could give me guidance as to where I can find more or
>perhaps contribute some code to the script.  I warn you now -- I am
>somewhat of a newbie to perl although I have a bit of experience in
>other languages.  I am also using Windows NT, but don't want to make
>this anymore platform-dependent than it has to be.
>



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

Date: Thu, 11 Sep 1997 00:45:53 GMT
From: ypeduel@ma.ultranet.com (Yuval Peduel)
Subject: performance & memory usage
Message-Id: <34173b7f.2843741@news.ma.ultranet.com>

I have a program doing some rather simple processing of reasonably
large (> 100Mbytes) volumes of data. Processing with the current,
naive, code takes around 45 minutes, so you can understand my interest
in improving performance. I've checked the Camel book, the FAQ, etc.
and have not found any help in answering some of these questions. Any
suggestions, pointers, answers, etc. would be welcomed.


1. %main::

The program loops over a number (> 100) of files. For each file, it
loops over the lines (> 100K) and creates a hash table for each. At
the end of the file, it undefs all the line-specific hash tables. Yet
looking at %main::, all the associated globs are still there.

One theory is that one of the performance problems is that the large
size of %main:: causes L2 cache misses.  My only evidence for this is
that when I run the loop over lines as a separate script rather than
as a subroutine, performance improves by 50% (c.p.u. usage goes down
to 65-75 % of the original value.) Does this make sense? Is there any
way to check this? Is there any way to get these entries out of
%main::?

2. total memory

Executing `ps v` after each file is processed indicates that the total
memory used by the program increases steadily. It ends up being about
80% of the total data size (i.e. > 100 Mbytes). The "page in" count is
not significant, so the working set is resident. This means that
memory size per se probably isn't a factor in the performance
degradation, though it may be causing malloc and other utilities to
slow down, but I'd still like to understand it.

As I indicated, I undef every data structure as soon as I'm done with
it. A check of %main:: (using the code on page 281 of the Camel book)
indicates that while all the globs are still there, none of them have
arrays, hashes, or scalars associated with them, so it does seem that
I haven't missed any of the data structures. The question is, how do I
find out where this memory is going?

I noticed several messages here to the effect that 5.004 had fixed a
large number of leaks so I tried running this program under both 5.002
(the original platform) and 5.004. The behavior is essentially the
same.


3. programming techniques

I am aware that replacing symbolic references with hard references
would improve performance by decreasing both the number of hashes and
the size of %main::. I am also aware that not using $`, $&, and &'
would improve performance slightly.

Most of the other suggestions for time efficiency in the Camel book
don't apply, but I don't understand the one about using shift. Shift
would be fast if arrays were implemented as linked lists, but they
aren't, are they? With real arrays, pop is much faster than shift, and
I confirmed this with a simple test. This implies that when more than
one or two shifts are needed, reverse followed by pop is the way to
go. Am I missing something?

Another recent post claimed that reading files a line at a time is
more "polite" than reading the entire file in at once. What is the
thinking behind this? It seems to me that reading in the entire file
is both easier and faster.

I think the performance FAQ suggested by a recent post would be a
great idea. I was disappointed to see so few responses. I hope this
prompts some knowledgeable posts.

TIA.



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

Date: 11 Sep 1997 02:56:26 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: performance & memory usage
Message-Id: <5v7mkq$3g7@agate.berkeley.edu>

In article <34173b7f.2843741@news.ma.ultranet.com>,
Yuval Peduel <ypeduel@ma.ultranet.com> wrote:

> I noticed several messages here to the effect that 5.004 had fixed a
> large number of leaks so I tried running this program under both 5.002
> (the original platform) and 5.004. The behavior is essentially the
> same.

I do not think these messages were from informed sources.  *Many*
leaks related to multi-interpreter situation were plugged, but not a
lot for one-interpreter one.  However, perl memory usage was tightened
a lot when it was *extra frivious* before (now it is just *very*
frivious with memory :-(), but these were not leaks, strictly
speaking.

I hope you tried Devel::Peek and did a scan over scratchpads.  This is
the most non-intuitive way for Perl to preserve some no-more-used
data.

Of course, if you have circular references, everything is futile.

Ilya


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

Date: 11 Sep 1997 00:02:28 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perl -Dr  regex_debugger
Message-Id: <5v7cek$t4r@agate.berkeley.edu>

In article <3416EDD2.7FEC@bender.com>,
Alex  <alex.t.silverstein@bender.com> wrote:
> Anyone know of a source more comprehensive
> than Friedl's "mastering" that explains the 
> noation of the regex debugger? i.e. the 
> meaning of s'thing such as:
> 
> perl -Dr -e "/T&RO(?\!CWAT&)*TBBTV?/x"

Any such source becomes obsolete with any change to RE engine, like
one designated for 5.005.

> rarest char & at 1

This is a message from constant substr optimizer. (See below.)

> first 14 next 84 offset 0

`first' was giving (useless) opcode of the first "real" node of finite
automaton, at 5 below.  The rest was just noise.

>  1:BRANCH(81)
>  5:EXACTLY(15) <T&RO>
> 15:CURLYX {0,32767}(53)
> 23:UNLESSM(45)
> 27:BRANCH(41)
> 31:EXACTLY(41) <CWAT&>
> 41:SUCCEED(0)
> 45:NOTHING(49)
> 49:WHILEM(0)
> 53:NOTHING(57)
> 57:EXACTLY(67) <TBBT>
> 67:CURLY {0,1}(81)
> 75:EXACTLY(0) <V>
> 81:END(0)

This is the finite automata for the RE.

> start `T&RO' minlen 8 

This is what the constant substr optimizer found.  (And you have
pretty old perl!).  Below is the output with jumbo patch:

Note also that your RE will not compile with newer Perls, because of
meaningless (?!)*. (With RE patch it - unfortunately - will compile
without warning.)

size 22 first at 1
rarest char & at 1
   1:EXACT <T&RO>(4)
   4:CURLYM[0] {0,32767}(15)
   6  :UNLESSM[-0](12)
   7    :END(0)
   8  :EXACT <CWAT&>(11)
  11  :SUCCEED(0)
  12  :TAIL(13)
  13  :SUCCEED(0)
  14  :NOTHING(15)
  15:EXACT <TBBT>(18)
  18:CURLY {0,1}(22)
  20  :EXACT <V>(0)
  22:END(0)
anchored `T&RO' at 0 (checking anchored) minlen 4
Omitting $` $& $' support.

It is slightly more readable than the old one, but still you need to
understand the internals of the finite automaton.  To construct it you
need to know that (4) above means the next node to execute is 4.

Hope this helps,
Ilya


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

Date: Wed, 10 Sep 1997 23:29:18 GMT
From: graeme@casey.co.nz (Graeme Merrall)
Subject: perl 5.004 seg faults
Message-Id: <34172a90.12039406@news.manawatu.gen.nz>

Hi.
I've got the Perl 5.004 dist from Slackware 3.3 on my Linux-2.0.30
machine and it was running fine. I installed  CPAN-1.3 and proceeded
to install Bundle::CPAN to get lots of 'neat stuff'

Somewhere inbetween that and CPAN install libnet-1.0505 something has
gone wrong.  Now most things make Perl die with a seg fault.
perl -v works and I've been able to plug a hello world prog in, but
installing modules and running perl -V dies.
I did an strace on "perl -V" which yielded me this. The same thing
also happens with something like "perl Makefile.PL"

Any clues anyone? Diskpace is fine BTW

Cheers,
 Graeme
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|0x20, 4294967295, 0) =
0x40007000
mprotect(0x40000000, 20500, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x8048000, 413859, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
stat("/etc/ld.so.cache", {st_mode=S_IFREG|0644, st_size=2649, ...}) =
0
open("/etc/ld.so.cache", O_RDONLY)      = 3
mmap(0, 2649, PROT_READ, MAP_SHARED, 3, 0) = 0x40008000
close(3)                                = 0
stat("/etc/ld.so.preload", 0xbffffb4c)  = -1 ENOENT (No such file or
directory)
open("/lib/libgdbm.so.1", O_RDONLY)     = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 24576, PROT_NONE, MAP_PRIVATE|0x20, 4294967295, 0) =
0x40009000
mmap(0x40009000, 18692, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
0) = 0x40009000
mmap(0x4000e000, 2788, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x4000) = 0x4000e000
close(3)                                = 0
mprotect(0x40009000, 18692, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
open("/usr/lib/libdb.so.1", O_RDONLY)   = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 65536, PROT_NONE, MAP_PRIVATE|0x20, 4294967295, 0) =
0x4000f000
mmap(0x4000f000, 56875, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
0) = 0x4000f000
mmap(0x4001d000, 4276, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0xd000) = 0x4001d000
close(3)                                = 0
mprotect(0x4000f000, 56875, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
open("/lib/libdl.so.1", O_RDONLY)       = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 12288, PROT_NONE, MAP_PRIVATE|0x20, 4294967295, 0) =
0x4001f000
mmap(0x4001f000, 4186, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
0) = 0x4001f000
mmap(0x40021000, 364, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x1000) = 0x40021000
close(3)                                = 0
mprotect(0x4001f000, 4186, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
open("/lib/libm.so.5", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 36864, PROT_NONE, MAP_PRIVATE|0x20, 4294967295, 0) =
0x40022000
mmap(0x40022000, 26340, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3,
0) = 0x40022000
mmap(0x40029000, 5808, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x6000) = 0x40029000
close(3)                                = 0
mprotect(0x40022000, 26340, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
open("/lib/libc.so.5", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3"..., 4096) = 4096
mmap(0, 794624, PROT_NONE, MAP_PRIVATE|0x20, 4294967295, 0) =
0x4002b000
mmap(0x4002b000, 562371, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED,
3, 0) = 0x4002b000
mmap(0x400b5000, 20304, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3, 0x89000) = 0x400b5000
mmap(0x400ba000, 207288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|0x20, 4294967295, 0) = 0x400ba000
close(3)                                = 0
mprotect(0x4002b000, 562371, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
munmap(0x40008000, 2649)                = 0
mprotect(0x8048000, 413859, PROT_READ|PROT_EXEC) = 0
mprotect(0x40009000, 18692, PROT_READ|PROT_EXEC) = 0
mprotect(0x4000f000, 56875, PROT_READ|PROT_EXEC) = 0
mprotect(0x4001f000, 4186, PROT_READ|PROT_EXEC) = 0
mprotect(0x40022000, 26340, PROT_READ|PROT_EXEC) = 0
mprotect(0x4002b000, 562371, PROT_READ|PROT_EXEC) = 0
mprotect(0x40000000, 20500, PROT_READ|PROT_EXEC) = 0
SYS_136(0, 0x2, 0x8, 0x40006190, 0x80559a0) = 0
geteuid()                               = 0
getuid()                                = 0
getgid()                                = 0
getegid()                               = 0
brk(0x80b5fb0)                          = 0x80b5fb0
brk(0x80b6000)                          = 0x80b6000
brk(0x80b7000)                          = 0x80b7000
getuid()                                = 0
geteuid()                               = 0
getgid()                                = 0
getegid()                               = 0
brk(0x80b9000)                          = 0x80b9000
brk(0x80ba000)                          = 0x80ba000
time([873933450])                       = 873933450
sigprocmask(SIG_BLOCK, NULL, [])        = 0
open("/dev/null", O_RDONLY)             = 3
brk(0x80bb000)                          = 0x80bb000
brk(0x80bc000)                          = 0x80bc000
brk(0x80bd000)                          = 0x80bd000
brk(0x80be000)                          = 0x80be000
getpid()                                = 2807
brk(0x80bf000)                          = 0x80bf000
sigprocmask(SIG_BLOCK, NULL, [])        = 0
sigprocmask(SIG_BLOCK, NULL, [])        = 0
open("/usr/lib/perl5/i486-linux/5.004/Config.pm", O_RDONLY) = 4
brk(0x80c0000)                          = 0x80c0000
fstat(4, {st_mode=S_IFREG|0444, st_size=16122, ...}) = 0
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|0x20, 4294967295, 0) =
0x40008000
read(4, "package Config;\nuse Exporter ()"..., 4096) = 4096
sigprocmask(SIG_BLOCK, NULL, [])        = 0
sigprocmask(SIG_BLOCK, NULL, [])        = 0
open("/usr/lib/perl5/i486-linux/5.004/Exporter.pm", O_RDONLY) = -1
ENOENT (No such file or directory)
open("/usr/lib/perl5/Exporter.pm", O_RDONLY) = 5
brk(0x80c1000)                          = 0x80c1000
fstat(5, {st_mode=S_IFREG|0444, st_size=12470, ...}) = 0
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|0x20, 4294967295, 0) =
0x400ed000
read(5, "package Exporter;\n\nrequire 5.0"..., 4096) = 4096
brk(0x80c2000)                          = 0x80c2000
brk(0x80c3000)                          = 0x80c3000
brk(0x80c4000)                          = 0x80c4000
brk(0x80c5000)                          = 0x80c5000
brk(0x80c6000)                          = 0x80c6000
brk(0x80c7000)                          = 0x80c7000
brk(0x80c8000)                          = 0x80c8000
brk(0x80c9000)                          = 0x80c9000
brk(0x80ca000)                          = 0x80ca000
brk(0x80cb000)                          = 0x80cb000
brk(0x80cc000)                          = 0x80cc000
brk(0x80cd000)                          = 0x80cd000
brk(0x80ce000)                          = 0x80ce000
brk(0x80cf000)                          = 0x80cf000
read(5, "pe eq \'&\' ? \\&{\"${pkg}::$sym"..., 4096) = 4096
brk(0x80d0000)                          = 0x80d0000
brk(0x80d1000)                          = 0x80d1000
brk(0x80d2000)                          = 0x80d2000
brk(0x80d3000)                          = 0x80d3000
brk(0x80d4000)                          = 0x80d4000
close(5)                                = 0
munmap(0x400ed000, 4096)                = 0
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++



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

Date: 10 Sep 1997 23:34:11 GMT
From: itlm007@dilbert.ucdavis.edu (Mark Cervarich)
Subject: Pipes in perl
Message-Id: <5v7apj$o37$1@mark.ucdavis.edu>

I am sending 4 lines of data to an IRR program (iterative rate of return)
to determine the annualized performance of said stock data.  I have 
figured out how to send the data to the pipe, but I don't know how to
capture it.  Here's what I've got
-----------cut here------------
[mark@serge]$ more t2
$data="1/1/97 1000.00\n2/1/97 1000.00\n3/1/97 1000.00\n4/1/97 -3300.00";
open TEST, "| /home1/mark/tmp/irr/irr";
print TEST $data;
close TEST;
$answer = $?;
print "answer is [$answer]\n";

[mark@serge]$ perl t2
77.786194 % (annualized)
answer is [0]
-----------cut here------------
The answer "77.786194 % (annualized)" is being dumped to STDOUT.
Arghh.
I'm sure the answer is real easy--so if you know what I'm doing wrong,
could you please tell me.

thanks,
mark



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

Date: 11 Sep 1997 02:45:02 GMT
From: "Carl R. McGee II" <carl2@mcgees.com>
Subject: Re: Print an Image
Message-Id: <5v7lve$chv@bgtnsc02.worldnet.att.net>

This is what I use.

sub send_image {
   select(STDOUT);
   $| = 1;
   $gif_image = '/path/filename.gif';
   @gif_data = `cat $gif_image`;
   print ("Content-type:image/gif\n\n");
   print (@gif_data);
   exit;
}

Have a good day.

Stephen Hill <buck@huron.net> wrote in article
<34155860.818020B9@huron.net>...
> Can you have a PERL script output an image? If so how do you do it?
> 
> I have tried many ways, but still cannot accomplish this :-( Any help
> would be appreciated.
> 
> buck@huron.net
> Thanks...
> 
> 
> 


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

Date: Wed, 10 Sep 97 22:37:51 PST
From: snapfisher@worldnet.att.net (Paul Fisher)
Subject: Recursive sorting
Message-Id: <5v7lkd$i83@mtinsc04.worldnet.att.net>

Can the sort function be called resursively?

I have a gouup of strings of the form xxxxx.#:xxxxx.#:xxxxx.#
where xxx are alphabetic characters and # is an ascii numerical 
representation (i.e. a number).

I wrote a sort subroutine to be used by the sort function, as in "sort 
by_myfunc()".  This routine breaks off the first chunnk of the string and 
evaluates it.  If the two substrings are equal, I want it to recursively 
call itself with the remaining string portions.

Sounds simple.  However, when I implemented the function it doesn't return 
correctly from the first recursive call (i.e. the second call).  Within this 
call it encounters a cmp operand and instead of returning to the calling 
function is invoked again -- it's obviously a compiled error, but I believe 
I'm using sort correctly.

Has anyone ever gotten sort to work resursively?  Is there a trick or is it 
just not possible?

--Paul


-- 
Paul Fisher
<snapfisher@worldnet.att.net>
if replying by mail, please send a copy to fisher@ltpmail.gsfc.nasa.gov



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

Date: 11 Sep 1997 00:19:34 GMT
From: gabor@vinyl.quickweb.com (Gabor Egressy)
Subject: Re: Regexp a Yes or No question?
Message-Id: <5v7dem$fqr$2@flint.sentex.net>

Tad McClellan (tadmc@flash.net) wrote:
: : I was thinking more along the line
: : if(/^([yY]([eE][sS])?)?$/) {
:                         ^
:                         ^
: So if the luser just hits return without any other keys, the
: 'do whatever' part should be executed?

Yeah, that is the default, your solution is fine as well, of course.
My point was that accepting just any word that starts with 'y' may not
be such a good idea.

: I think it is easier to read if you write it this way:

:    if(/^y(es)?$/i) {


--
And don't tell me there isn't one bit of difference between null and space,
because that's exactly how much difference there is.  :-)
        --Larry Wall in <10209@jpl-devvax.JPL.NASA.GOV>
Check out this site about the persecution of Randal Schwartz by Intel
http://www.rahul.net/jeffrey/ovs/


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

Date: 11 Sep 1997 00:43:30 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Saving state with CGI.pm
Message-Id: <5v7eri$b5r@news-central.tiac.net>

In article <2SwdwFARdxF0Ew2U@dozyrosy.demon.co.uk>,
Rosemary I H Powell  <Postmaster@dozyrosy.demon.co.uk> wrote:
>Lured by the promise of easily being able to save state across sessions,
>I am in the process of converting from using cgi-lib.pl to CGI.pm in my
>CGI scripts. BUT - I'm a little confused as I was expecting my life to
>be made easier, but so far this doesn't seem to be the case :-(
>
>I have an existing script where form input data is checked and the data 
>re-displayed for checking; I presently do this by re-generating the form
>with all the previously input data "filled in", and by carrying over
>other information via hidden fields on the form, and the user can check
>and correct his input before finally submitting...It works nicely but
>isn't very beautiful.

I think you're working too hard!  Check out the simple example at teh verb
beginning of the docs at:

http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html

Then once you've played with that and seen how much CGI does for yoy and
you're doing a real application you can do something like this could be a
reasonable skeleton:

  use CGI qw/:standard/;

  ...

  if (param ()) {
    #
    # check they're OK
    #

    if ($someErrorInInput) {
      displayForm ($errorMessage);
    }
    else {
     # process data etc.
    }
  }
  else {
    #
    # no params, so it's the first time through
    #

    displayForm ();
  }

  exit 0;

  sub displayForm {
    my $message = shift;

    if (defined $message) {
      print "you messed up ($message)<hr>\n";
    }

    display the form using CGI library primitives
  }

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 10 Sep 1997 23:48:29 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Split operator
Message-Id: <genepoolEGBGst.DrH@netcom.com>


Ramesh Nagarajan (ran@sgi.com) wrote:
: $array # Contains a large text file (2000 lines with hard returns)
: P.S I tried to split on '\n' but the resulting array is all jumbled up.

How is the data organized? If there is some other delimeter to the data 
then split on that. An example of the data and what you are trying to do 
with it might help. 

Cheers,

Jim


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

Date: 10 Sep 1997 23:44:00 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: What does "regexp *+ operand could be empty" mean?
Message-Id: <5v7bc0$s50@agate.berkeley.edu>

In article <3416f45e$7$ofn$mr2ice@speaker.kf8nh.apk.net>,
Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh" <bsa@void.apk.net> wrote:
> In <5v2d90$oan@agate.berkeley.edu>, on 09/09/97 at 02:45 AM,
>    ilya@math.ohio-state.edu (Ilya Zakharevich) said:
> +-----
> | Note that this (very useful) message is gone with the latest jumbo RE patch. 
> +--->8
> 
> Is there any particular reason it didn't become a -w warning?

With Jumbo patch applied there is no reason to mark /^(a?b?)+c/ as an
error/typo.  Maybe this is what you inteded?  If so, Perl will treat
it as such.

There is nothing bad *conceptually* with a RE like this.  A stupid NFA
implementation can choke on it.  Perl will not.

Ilya

P.S.  If I'm not mistaken, the above RE will choke on "adc" with
the current Perl.  (To avoid smartass refusal, one can recode it as
	/^()(a?\1b?)+c/
 ;-)



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1009
**************************************

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