[18112] in Perl-Users-Digest
Perl-Users Digest, Issue: 272 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 12 09:05:53 2001
Date: Mon, 12 Feb 2001 06:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981986714-v10-i272@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 12 Feb 2001 Volume: 10 Number: 272
Today's topics:
.htaccess authentification <jason@generationterrorists.com>
Re: .htaccess authentification (Abigail)
Accessing-deleting mail from perl sparcguy@my-deja.com
Re: Data storage format. Help needed. <wells@cedarnet.org>
Re: dialog with spawned process? <Jerome.Abela@free.fr>
Finding multiply of prime factors <verbitumfong@hotmail.com>
Re: Finding multiply of prime factors <jonni@ifm.liu.se>
Re: Food for guru's: read/modify/write works under Linu <fw@lanvision.nl>
Re: Free Movie Ticket Give-away for solving the basic p <patrickolson@qwest.net>
Re: Getopts? <jdb@ga.prestige.net>
Re: getting date from Week number <steffen@mayo.imperia.net>
Re: Grep error in Perl program... (Anno Siegel)
How do I translate a Cobol WORKING-STORAGE SECTION into <jck1@seed.net.tw>
Re: How do I translate a Cobol WORKING-STORAGE SECTION (Anno Siegel)
Re: How do I translate a Cobol WORKING-STORAGE SECTION <jck1@seed.net.tw>
Re: How to retrieve local machine ip address (Tellslater)
Re: How to run Perl on Windows 2000? <nowayandnohow@hotmail.com>
LWP debug dweisinger@my-deja.com
Re: LWP::Simple hangs? (BUCK NAKED1)
Re: LWP::Simple hangs? (BUCK NAKED1)
Re: Modules/Constants. <dorsettest@uk.insight.com>
Re: Newbie's Stuck (Helgi Briem)
Re: Partial Apology to Perl Fans <cingram-at-pjocs-dot-demon-dot-co-dot-uk>
Re: postgres perl problem <joe+usenet@sunstarsys.com>
Re: Radical readdir suggestion (Mark Jason Dominus)
Re: Radical readdir suggestion (Mark Jason Dominus)
Re: Radical readdir suggestion (Abigail)
Re: Removing leading/trailing spaces zac_thomas@my-deja.com
Re: Removing leading/trailing spaces (Peter J. Acklam)
Sending multiple files with CGI.pm. <jonni@ifm.liu.se>
Re: Splitting a quote-comma delimitted string <eric.kort@vai.org>
Re: TCP server (Anno Siegel)
Re: TCP server (Garry Williams)
Re: the best solution? (Anno Siegel)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Feb 2001 16:06:55 +0800
From: "Jason Q." <jason@generationterrorists.com>
Subject: .htaccess authentification
Message-Id: <3A87999F.AA809D1C@generationterrorists.com>
Hi all
In a perl/cgi script, how (if possible) do I emulate .htaccess
authentification (username/password).
Regards,
JQ.
------------------------------
Date: 12 Feb 2001 08:56:25 GMT
From: abigail@foad.org (Abigail)
Subject: Re: .htaccess authentification
Message-Id: <slrn98f99p.gn6.abigail@tsathoggua.rlyeh.net>
Jason Q. (jason@generationterrorists.com) wrote on MMDCCXXII September
MCMXCIII in <URL:news:3A87999F.AA809D1C@generationterrorists.com>:
?? Hi all
??
?? In a perl/cgi script, how (if possible) do I emulate .htaccess
?? authentification (username/password).
The same way you would in a C/CGI or an APL/CGI program.
Go ask in a CGI group.
Abigail
--
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print
qq{Just Another Perl Hacker\n}}}}}}}}}' |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w
------------------------------
Date: Mon, 12 Feb 2001 11:37:51 GMT
From: sparcguy@my-deja.com
Subject: Accessing-deleting mail from perl
Message-Id: <968huf$pvj$1@nnrp1.deja.com>
I am currently in need of assistance in finding the best way to access
and delete email. I am currently using mail::internet & mail::util to
access basic mail info from /var/mail/username but I am currently
unable to figure out how to delete messages once they have been read.
I am also unsure if if the above modules are the best one to use to
access mail from perl.
Any example code would be appriciated.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 12 Feb 2001 05:44:06 -0600
From: Steve Wells <wells@cedarnet.org>
Subject: Re: Data storage format. Help needed.
Message-Id: <3A87CC86.F4DE713@cedarnet.org>
Look for 'MLDBM' on CPAN.
(http://search.cpan.org/)
It will allow you to use complex data types in a DBM file.
HTH,
STEVE
Jonas Nilsson wrote:
>
> I'm working with a database with a format like this.
>
> $data={'types' => [qw(number number text CAS text text)],
> 'titles' => [qw(mp bp name cas synonyms comments],
> 'data' => [ \@mps, \@bps, \@names, \@cass, \@synonymss,
> \@comments]
> }
>
> I'm storing and reading that data to and from disk using a fromat that I've
> invented myself.
>
> Now, I know there are more "standard" dataformats for storage (or ties)
> supplied by modules. Can somone point me to what kind of database/module
> that could fit my needs. There are about 1000 records, and everytime the
> script is run via a web-interface, the whole database must be searched for
> keywords using methods which depend on the fields in 'types'.
>
> Actually i know nothing about databases so any hint or suggestion would be
> appreciated.
>
> And another question. Are there any OO modules that could handle my database
> nicely and which would support userdefined search methods?
>
> Maybe a bit of fuzzy questions, but that depends on that I'm new to both OOP
> and databases. Please direct my to relevant reading.
> /jN
>
> --
> _____________________ _____________________
> | Jonas Nilsson | | |
> |Linkoping University | | Telephone |
> | IFM | | --------- |
> | Dept. of Chemistry | | work: +46-13-285690 |
> | 581 83 Linkoping | | fax: +46-13-281399 |
> | Sweden | | home: +46-13-130294 |
> |_____________________| |_____________________|
------------------------------
Date: Mon, 12 Feb 2001 08:49:30 GMT
From: Jerome Abela <Jerome.Abela@free.fr>
Subject: Re: dialog with spawned process?
Message-Id: <3A87A2A1.5D49CBC8@free.fr>
big_amko@my-deja.com wrote:
> > open(BOX, "|my_black_box.exe")
>
> Now, I am trying to capture the output from the same "Black Box"
> process in order to parse it for some error or warning messages or some
> other keywords from there, so that I can either proceed further and
> just log the information or react properly if error or warning got
> encountered.
Look at IPC::Open2 and IPC::Open3 manual entries. They allow you to
manipulate both stdin and stdout of the process.
Jerome.
------------------------------
Date: Mon, 12 Feb 2001 17:54:07 +0800
From: "Verbitum Fong" <verbitumfong@hotmail.com>
Subject: Finding multiply of prime factors
Message-Id: <968caq$et2@netnews.hinet.net>
For example:
48 = 2 x 2 x 2 x 2 x 3
121 = 11 x 11
12345 = 3 x 5 x 823
I wrote a program
$input = $compute = 12345;
while($compute>1) {
for $i (2..$compute) {
$temp = $compute/$i;
if($temp == int($temp)) {
push @result,$i;
$compute = $temp;
last;
}
}
}
print "$input = ",join(" x ",@result),"\n";
Although it shows correct answer, I feel it is not so good,
especially the for $i loop. Besides, I am afraid it might
loop infinitely. If sometimes "rounding error" make
the == test fails, the program will hang.
Would you rectify my program to avoid that and make better?
Thanks.
Verbitum Fong
------------------------------
Date: Mon, 12 Feb 2001 13:01:04 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Finding multiply of prime factors
Message-Id: <968j83$nd0$1@newsy.ifm.liu.se>
use:
if (($compute % $i)==0) {
push @result,$i;
$compute = $compute/$i;
last;
instead of:
> $temp = $compute/$i;
> if($temp == int($temp)) {
> push @result,$i;
> $compute = $temp;
> last;
Also, $i need to be only primes (2,3,5,7,11,13) less than sqrt($compute). So
you can minimize computation by going through 2 and every uneven number less
than sqrt($compute) (2,3,5,7,9 .. int(sqrt($compute))
/jN
--
_____________________ _____________________
| Jonas Nilsson | | |
|Linkoping University | | Telephone |
| IFM | | --------- |
| Dept. of Chemistry | | work: +46-13-285690 |
| 581 83 Linkoping | | fax: +46-13-281399 |
| Sweden | | home: +46-13-130294 |
|_____________________| |_____________________|
"Verbitum Fong" <verbitumfong@hotmail.com> wrote in message
news:968caq$et2@netnews.hinet.net...
> For example:
> 48 = 2 x 2 x 2 x 2 x 3
> 121 = 11 x 11
> 12345 = 3 x 5 x 823
>
> I wrote a program
>
> $input = $compute = 12345;
> while($compute>1) {
> for $i (2..$compute) {
> $temp = $compute/$i;
> if($temp == int($temp)) {
> push @result,$i;
> $compute = $temp;
> last;
> }
> }
> }
> print "$input = ",join(" x ",@result),"\n";
>
> Although it shows correct answer, I feel it is not so good,
> especially the for $i loop. Besides, I am afraid it might
> loop infinitely. If sometimes "rounding error" make
> the == test fails, the program will hang.
>
> Would you rectify my program to avoid that and make better?
> Thanks.
>
> Verbitum Fong
>
>
>
------------------------------
Date: Mon, 12 Feb 2001 14:46:59 +0100
From: Frank van Wensveen <fw@lanvision.nl>
Subject: Re: Food for guru's: read/modify/write works under Linux, not under Solaris. Please help!
Message-Id: <evpf8t8vpd6dr528lhik63da2ch177enp5@4ax.com>
On Fri, 09 Feb 2001 15:33:23 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:
[Read/modify/write cycle corrupts text file]
> You likely have a buffering problem.
Yes, one that exist in Solaris but that doesn't seem to bother Linux.
Strange but true. Apparently these Unix flavors are quite different in
these respects.
> In your place, I'd attempt to do a seek(FILE, 0, 1) after writing, and
> before continuing reading.
I tried it, but it makes no difference. (Which is not surprising if
you think about it, because a seek does not flush buffers.)
Working from the assumption that this is indeed a buffering problem, I
went to perldoc.com to learn how to autoflush file handles. It turned
out that putting
select ((select (FILE), $| = 1) [0]); # Autoflush on
and
select ((select (FILE), $| = 0) [0]); # Autoflush off
around my read/modify/write subroutine did the trick!
FVW
------------------------------
Date: Mon, 12 Feb 2001 05:46:13 -0700
From: "Patrick L. Olson" <patrickolson@qwest.net>
Subject: Re: Free Movie Ticket Give-away for solving the basic problem on Time:HiRes.pm module
Message-Id: <RVQh6.320$mr5.59338@news.uswest.net>
"Carmari" <caramari9@hotmail.com> wrote in message
news:3a848fb6$0$70817$1dc6e903@news.corecomm.net...
> Hi :
>
> I am writing a TIMER program with HiResolution requirement.
Basically, we
> can get 4.34 double precision seconds from timeofday function ( from
> TIME::HiRes) . However, I got problem on the very simple
implementation.
> Here is the detail:
> Please read and let me know what is the problem. Thank you. I will
send you
> a free movie ticket as reward. Promise!!!
> Thanks.
>
> Caramari
>
>
> +++++++++
> Perl system information:
> +++++++++
>
> perl: /usr/bin/perl /usr/sbin/perl /usr/sbin/perl5.00502-n32
> /usr/sbin/perl5.00502 /usr/sbin/perl5.00404 /usr/lib/perl
> /usr/local/bin/perl /usr/freeware/bin/perl
/usr/freeware/bin/perl5.00502
>
> +++++++++
> program:
> +++++++++
> #!/usr/bin/perl
> use Time::HiRes qw(gettimeofday);
>
> $t0=gettimeofday;
> for($i=0;$i<=100;$i++)
> {
> $y +=$i;
> }
> $t1=gettimeofday;
> $elapsed = $t1-$t0;
> print $elapsed;
> ----------------------
> ----------------------
>
> perl -c t.cgi
>
> +++++++++
> Error message:
> +++++++++
>
> Can't locate Time/HiRes.pm in @INC (@INC contains:
> /usr/freeware/lib/perl5/5.00502/irix-n32
/usr/freeware/lib/perl5/5.00502
> /usr/freeware/lib/perl5/site_perl/5.005/irix-n32
> /usr/freeware/lib/perl5/site_perl/5.005
> /usr/freeware/lib/perl5/sgi_perl/irix-n32
/usr/freeware/lib/perl5/site_perl
> .) at t.cgi line 3.
> BEGIN failed--compilation aborted at t.cgi line 3
>
>
>
C:\>ppm install time-hires
worked for me
------------------------------
Date: Mon, 12 Feb 2001 09:07:44 GMT
From: "Jeremia d." <jdb@ga.prestige.net>
Subject: Re: Getopts?
Message-Id: <3A86C456.CF1677D5@ga.prestige.net>
--------------74A6170E21F12780D853FB5F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Thanks for the paper...
Jonathan Feinberg wrote:
> jdb@ga.prestige.net writes:
>
> > I am in need of a example or a url to a good example of getopts
> > usage.
>
> I have placed on the web a html-ized version of a brief Microsoft Word
> document I wrote as an introduction to getopts for a class.
>
> http://pobox.com/~jdf/options.html
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
> http://pobox.com/~jdf
--
A little experience often upsets a lot of theory.
--------------74A6170E21F12780D853FB5F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Thanks for the paper...
<br>Jonathan Feinberg wrote:
<blockquote TYPE=CITE>jdb@ga.prestige.net writes:
<p>> I am in need of a example or a url to a good example of getopts
<br>> usage.
<p>I have placed on the web a html-ized version of a brief Microsoft Word
<br>document I wrote as an introduction to getopts for a class.
<p> <a href="http://pobox.com/~jdf/options.html">http://pobox.com/~jdf/options.html</a>
<p>--
<br>Jonathan Feinberg jdf@pobox.com Sunny Brooklyn,
NY
<br><a href="http://pobox.com/~jdf">http://pobox.com/~jdf</a></blockquote>
<pre>--
A little experience often upsets a lot of theory.</pre>
</html>
--------------74A6170E21F12780D853FB5F--
------------------------------
Date: 12 Feb 2001 12:54:08 GMT
From: Steffen Beyer <steffen@mayo.imperia.net>
Subject: Re: getting date from Week number
Message-Id: <968mdg$krr$1@swifty.westend.com>
In article <981671781.122979@hpvablab.cup.hp.com>, Richard J. Rauenzahn <nospam@hairball.cup.hp.com> wrote:
> mike_solomon@lineone.net writes:
>>Using Date::Calc I can get a Week number by providing a date
>>
>>($week,$year) = Week_of_Year($year,$month,$day);
>>
>>I want to provide the Week number and the Year and get the Week
>>Commencing date
>>
>>So if I provide week 3 year 2001 I want to get back 15/01/2001
>>
>>Does anyone have any idea how this could be done?
> Calculate it yourself...
> #!/usr/bin/perl -w
> use strict;
> use Date::Calc qw(:all);
> my $week = 3;
> my @date = Monday_of_Week(1, 2001);
> @date = Add_Delta_Days(@date, 7*($week-1));
> print "@date\n";
> __END__
Almost!
But not quite...
Better:
use Date::Calc qw(:all);
my $week = 3;
my $year = 2001;
my @date = Monday_of_Week($week, $year);
print "@date\n";
> Rich
Cheers!
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: 12 Feb 2001 09:42:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Grep error in Perl program...
Message-Id: <968b5v$fo2$1@mamenchi.zrz.TU-Berlin.DE>
Nicholas C. Cheung <ncheung@draper.com> wrote in comp.lang.perl.misc:
>Anno Siegel wrote:
[...]
>> Yes. Don't use an external program for selection, use a perl regex.
>> That way you have quotemeta() (q.v.) to make your regex safe against
>> unexpected meta-characters appearing in the program name.
>>
>> Anno
>
>
>Anno,
>
> I need to run an external program (ps) to find if a certain process is
>running or not. Is there a perl equivalent for the Unix command ps?
No. You'll need ps (or the /proc filesystem, even less portable) to
get the basic data. That is no reason to use external grep as well.
Anno
------------------------------
Date: Mon, 12 Feb 2001 10:03:49 +0800
From: "jck1" <jck1@seed.net.tw>
Subject: How do I translate a Cobol WORKING-STORAGE SECTION into the format I wanted?
Message-Id: <968a52$cjo@netnews.hinet.net>
hi all
I want to translate the Cobol WORKING-STORAGE SECTION into the format I
wanted.
But I don't know how to do. The Cobol WORKING-STORAGE SECTION almost like
the
below statement.
01 IABC-R.
03 IABC-F13 PIC 9(07).
03 IABC-F14 OCCURS 3 TIMES.
05 IABC-AKLFJDKAS PIC X(01).
05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
03 FILLER PIC X(10).
I want the statements below the OCCURS line expaned themself n times.
For example, the translated format looks like below.
01 IABC-R.
03 IABC-F13 PIC 9(07).
03 IABC-F14 OCCURS 3 TIMES.
05 IABC-AKLFJDKAS PIC X(01).
05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
05 IABC-AKLFJDKAS PIC X(01).
05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
05 IABC-AKLFJDKAS PIC X(01).
05 IABC-ZZZZZZZZ OCCURS 4 TIMES.
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
03 FILLER PIC X(10).
Somebody have idea to solve it. I have failed many times.
Who will give me some suggestion about the "data structure" and "algorithm"?
Thanks a lot :)
------------------------------
Date: 12 Feb 2001 10:53:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How do I translate a Cobol WORKING-STORAGE SECTION into the format I wanted?
Message-Id: <968fba$o78$1@mamenchi.zrz.TU-Berlin.DE>
jck1 <jck1@seed.net.tw> wrote in comp.lang.perl.misc:
>hi all
>I want to translate the Cobol WORKING-STORAGE SECTION into the format I
>wanted.
If you want help with that, you'll have to find a way to explain the
format you want.
>But I don't know how to do. The Cobol WORKING-STORAGE SECTION almost like
>the
>below statement.
>01 IABC-R.
> 03 IABC-F13 PIC 9(07).
> 03 IABC-F14 OCCURS 3 TIMES.
> 05 IABC-AKLFJDKAS PIC X(01).
> 05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
> 07 IABC-KKK PIC 9(08).
> 07 IABC-ZZZ PIC 9(01).
> 03 FILLER PIC X(10).
>
>I want the statements below the OCCURS line
There are two lines that contain "OCCURS". Which one do you mean?
> expaned themself n times.
What is "n"? The replication factor from "OCCURS"? You aren't
saying.
>For example, the translated format looks like below.
> 01 IABC-R.
> 03 IABC-F13 PIC 9(07).
> 03 IABC-F14 OCCURS 3 TIMES.
> 05 IABC-AKLFJDKAS PIC X(01).
> 05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
> 07 IABC-KKK PIC 9(08).
> 07 IABC-ZZZ PIC 9(01).
> 07 IABC-KKK PIC 9(08).
> 07 IABC-ZZZ PIC 9(01).
> 05 IABC-AKLFJDKAS PIC X(01).
> 05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
> 07 IABC-KKK PIC 9(08).
> 07 IABC-ZZZ PIC 9(01).
> 07 IABC-KKK PIC 9(08).
> 07 IABC-ZZZ PIC 9(01).
> 05 IABC-AKLFJDKAS PIC X(01).
> 05 IABC-ZZZZZZZZ OCCURS 4 TIMES.
This "OCCURS" goes with a factor of 4 while the other two have 2.
How is that derived from your specification?
> 07 IABC-KKK PIC 9(08).
> 07 IABC-ZZZ PIC 9(01).
> 07 IABC-KKK PIC 9(08).
> 07 IABC-ZZZ PIC 9(01).
> 03 FILLER PIC X(10).
>
>Somebody have idea to solve it. I have failed many times.
Unfortunately you have also failed in conveying what you want to
do in the first place. Just giving one example of input and
corresponding output is *never* a sufficient problem description.
Apparently you want to replicate a block of lines a number of times.
To specify your problem, you'd have to explain:
Where does the block of lines start? Where does it end? Where does
the number of replications come from? How (if at all) is the repeated
text to be modified?
>Who will give me some suggestion about the "data structure" and "algorithm"?
You'll have to do your homework first.
Anno
------------------------------
Date: Mon, 12 Feb 2001 20:22:56 +0800
From: "jck1" <jck1@seed.net.tw>
Subject: Re: How do I translate a Cobol WORKING-STORAGE SECTION into the format I wanted?
Message-Id: <968l06$p9d@netnews.hinet.net>
Sorry. I have poor English. So, I can't explain what I want clearly. But I
will try to do it.
Ok, let's go.
The source data is below.
=====================================================
01 IABC-R.
03 IABC-F13 PIC 9(07).
03 IABC-F14 OCCURS 3 TIMES.
05 IABC-AKLFJDKAS PIC X(01).
05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
03 FILLER PIC X(10).
=====================================================
In order to explain what I want, I mark the source data with "line_number"
in the front of each line and note the "lead_number" in the end of each
line.
So the source data seem like the below statement.
=====================================================
line_number
lead_number
0 01 IABC-R.
01
1 03 IABC-F13 PIC 9(07).
03
2 03 IABC-F14 OCCURS 3 TIMES.
03
3 05 IABC-AKLFJDKAS PIC X(01).
05
4 05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
05
5 07 IABC-KKK PIC 9(08).
07
6 07 IABC-ZZZ PIC 9(01).
07
7 03 FILLER PIC X(10).
03
=====================================================
I want to read the source data and do something to it and produce what I
want.
First, we read the 0th line, a common line, so we print it directly.
Second, we read the 1th line, a comon line too, so we print directly.
Third, we raed the 2th line, a special line with OCCURS, so we must do
something.
When the OCCURS appears, it means the lines below the OCCURS line will be
affected if the line's lead_number is less than the OCCURS line's
lead_number.So the 3th,4th,5th,6th and 7th line will be affected. The 2th
line says "03 IABC-F14 OCCURS 3 TIMES.", it means 3th, 4th, 5th, 6th, and
7th
line must occur 3 times in sequence.
Forth,we read the 3th line, a common line, but it affected by the 2th line.
Fifth, we read the 4th line, a OCCURS line too, so the rule is the same with
the 2th line.
As the story goes, we can generate the output data. It may look like the
below statement.
==============================================================
01 IABC-R.
03 IABC-F13 PIC 9(07).
03 IABC-F14 OCCURS 3 TIMES.
05 IABC-AKLFJDKAS PIC X(01).
05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
05 IABC-AKLFJDKAS PIC X(01).
05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
05 IABC-AKLFJDKAS PIC X(01).
05 IABC-ZZZZZZZZ OCCURS 4 TIMES.
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
07 IABC-KKK PIC 9(08).
07 IABC-ZZZ PIC 9(01).
03 FILLER PIC X(10).
==============================================================
That's all. I will work hard to find some solution. And any suggestion and
answer is welcome. :)
------------------------------
Date: 12 Feb 2001 10:16:24 GMT
From: tellslater@aol.com (Tellslater)
Subject: Re: How to retrieve local machine ip address
Message-Id: <20010212051624.26171.00000636@ng-cd1.aol.com>
Hi David _ I am writing a program at the moment that also needs the facility to
get your IP own address, and I was interested in the reply about using
MSCONFIG. I have therefore come up with the sub routine below that works on my
Windows 98 machine (I know it is not the best written routine in the world -
but it works for me). I will use it to get my program working until I find a
better way.
Regards Terry.
sub readip {
system("ipconfig >myip.txt");
if (open(MYFILE,"myip.txt")){
@contents=<MYFILE>;
close(MYFILE);
$myip=$contents[5];
#print $myip."\n";
@parts=split(/: /,$myip);
$ip=$parts[1];
} else {
print "Cannot open myip.txt\n";
exit 1;
}
------------------------------
Date: Mon, 12 Feb 2001 13:39:48 GMT
From: "nowayandnohow" <nowayandnohow@hotmail.com>
Subject: Re: How to run Perl on Windows 2000?
Message-Id: <EIRh6.7862$R45.2265923@typhoon2.ba-dsg.net>
I am running perl (activestate) on my windows 200 professional right now. I
jut went to activestate.com and installed it from there, I have had no
problems with it at all...
"Damian James" <damian@qimr.edu.au> wrote in message
news:slrn98e88s.kv9.damian@puma.qimr.edu.au...
> Thus spake Sean on Fri, 09 Feb 2001 15:53:18 GMT:
> >Thanks for your reply. But our needs are more than met with Windows 2000
> >server. All I really wanted to know is how to run Perl on Windows
> >2000.....thanks again.
> >
>
> Err, yes they may be, but the last time I looked, no version of Windows
> shipped with a pre-installed Perl interpreter. You need to install one.
> Since you mentioned CGI, I suggested a version of Perl that includes web
> server software. You need this too -- whether you use Apache or IIS is
your
> business. If you are running CGI programs written in Perl, however, you
will
> find that Apache and Perl work better together.
>
> Also note that Windows 2000 Server != web server software. Whatever web
server
> software you are running, this is what you have to deal with when
developing
> CGI.
>
> So try either Indigo Perl, or as has also been suggested, Active Perl.
>
> HTH
>
> Cheers,
> Damian
> --
> $;=ord$%,$:=$;-ord q,.,,$_=q
13346:3366:3276:3326:3386:546:566:966:3396:3376:1.
> q
73386:546:;96:3326:3336:3386:3266:3236:3366:546::26:3236:3366:32:6:546:32667
.
>
q,:;96:;;6:3296:3236:3366:326:56,,s,.,;ord($&)-$:-$;;;;;,eg,s,$;,;chr$&-$:;,
eg,
> eval eval; #requires 5.6.0 ## my first attempt at one of
these...
------------------------------
Date: Mon, 12 Feb 2001 12:54:41 GMT
From: dweisinger@my-deja.com
Subject: LWP debug
Message-Id: <968mef$ta0$1@nnrp1.deja.com>
I've tried to automate the POST action on some CGI forms
by using LWP::UserAgent.
I've been successful with about 30 of the 35 forms.
The remaining 5 forms are bugging me.
I'm not sure what's wrong or why these forms are less forgiving than
the other ones...
Is there a way to debug LWP? The response just gives me some standard
error.
Is there a way to see what HTTP message is being sent from a browser
where the form works?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 12 Feb 2001 02:13:49 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: LWP::Simple hangs?
Message-Id: <16370-3A879B3D-147@storefull-246.iap.bryant.webtv.net>
cgould@gate.net wrote...
>=A0=A0if ($urlname =3D~ /http\:/) { } else {die();}
Aren't you missing a semi-colon after {die();} doing it that way? How
'bout...
die unless ($urlname =3D~ /http\:/);
--dennis
------------------------------
Date: Mon, 12 Feb 2001 02:24:13 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: LWP::Simple hangs?
Message-Id: <16371-3A879DAD-66@storefull-246.iap.bryant.webtv.net>
> my $content = get($urlname) or die("Net error!");
> print $content or die("$!");
Oops, I see another problem... you don't want a die statement in your
"print $content" line. How does the script know whether to print or die
on that line? HINT: On the "my $content" line, it knows to die if the
"get" fails.
--Dennis
------------------------------
Date: Mon, 12 Feb 2001 11:09:29 +0000
From: Kelly Dorset <dorsettest@uk.insight.com>
Subject: Re: Modules/Constants.
Message-Id: <3A87C469.99F1D7C9@uk.insight.com>
> I'm going to make one more guess, though. You don't have a package
> statement in pebbleconst.pm. If you copied actual code, then this is
> the problem. You need to review the Exporter manual page:
>
> ...
> SYNOPSIS
> In module ModuleName.pm:
>
> package ModuleName;
> require Exporter;
> ...
>
> Your constants module needs a package statement.
>
> package pebbleconst;
Marvellous. That seems to work. I guess that was all thats missing!
I'd forgotten to put the package name at the top of that one :)
Thanks for your help!
k
------------------------------
Date: Mon, 12 Feb 2001 14:00:31 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Newbie's Stuck
Message-Id: <3a87ebc5.254551525@news.itn.is>
On Fri, 9 Feb 2001 15:40:24 -0500, "jlm" <jlm@cca-int.com>
wrote:
>How would I search for the presense of @ in a string?
>Assume an email addr. in variable $email - how do I test $email for an at
>sign.
>many thanks for your help...
>
my $email = 'foo@bar.com';
if ($email =~ /\@/) { print "\@ found in $email\n"; }
else { print "\@ not found in $email\n"; }
And for a lot more information read
perldoc perlre
Regards,
Helgi Briem
------------------------------
Date: Fri, 9 Feb 2001 13:56:15 -0000
From: "Clyde Ingram" <cingram-at-pjocs-dot-demon-dot-co-dot-uk>
Subject: Re: Partial Apology to Perl Fans
Message-Id: <981983878.19050.0.nnrp-14.9e98e5bc@news.demon.co.uk>
> extrapolate their own preferences onto everybody else. Viva La
> Difference! (Is my french better than my Perl?)
No chance.
Vive la difference. (Je crois . . .)
------------------------------
Date: 12 Feb 2001 08:33:02 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: postgres perl problem
Message-Id: <m31yt4m3g1.fsf@mumonkan.sunstarsys.com>
"Tony Dalbrekt" <to.da@spray.se> writes:
> Can't locate pg.pm in @INC (@INC contains: /usr/lib/perl5/5.6.0/i386-linux
> /usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i386-linux
> /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at
> /home/toda/html//cgi-bin/test.cgi line 8.
>
> Why do I get this error message every time I try to connect to my postgres
> database.
That's perl's way of telling you that your script needs to load the
pg.pm module, but perl can't find the file in it's search path (@INC)
to load it. If you forgot to install the correct module, it's available
on CPAN. A search for "postgres" at
http://www.cpan.org
pulled up lots of packages; be sure to get the one that corresponds to
your script.
HTH
Joe Schaefer
--
#include <stdio.h> /* requires gcc and *nix
use strict; system("cc -x c $0") and die $?; open C, "|a.out" or die $! . q*/
main(){char s[32]; remove("a.out"); printf("%s/C hacker\n",fgets(s,32,stdin));
return 0;}/*; print C "Just another Perl"; close C or die $?; #*/
------------------------------
Date: Mon, 12 Feb 2001 09:21:20 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Radical readdir suggestion
Message-Id: <3a87ab0f.33c$1b4@news.op.net>
In article <981709247.24219@itz.pp.sci.fi>,
Ilmari Karonen <usenet11362@itz.pp.sci.fi> wrote:
>I'm now wondering
>whether one could find a single filesystem on this planet that had a
>deliberate loop of hard links made for any purpose other than just to
>show that it can be done.
>
>...Better not let find(1) get anywhere near it..
I seem to recall that the original paper about Unix from the Bell
System Technical Report series, by Thompson and Ritchie, mentions that
although the Unix filesystem may be an arbitrary DAG, it is not
allowed to contain loops, precisely for the reason that they will
complicate the implementation of programs that traverse the filesystem.
The DAG property was probably a lot more important before there were
symlinks.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Mon, 12 Feb 2001 09:36:03 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Radical readdir suggestion
Message-Id: <3a87ae82.397$251@news.op.net>
In article <3a87ab0f.33c$1b4@news.op.net>,
Mark Jason Dominus <mjd@plover.com> wrote:
>I seem to recall that the original paper about Unix from the Bell
>System Technical Report series, by Thompson and Ritchie, mentions that
>although the Unix filesystem may be an arbitrary DAG, it is not
>allowed to contain loops, precisely for the reason that they will
>complicate the implementation of programs that traverse the filesystem.
I remembered the source, but not the content. Here is the relevant
excerpt from the BSTJ paper, which later appeared in CACM:
The directory structure is constrained to have the form of a
rooted tree. Except for the special entries ``.'' and ``..'',
each directory must appear as an entry in exactly one other
directory, which is its parent. The reason for this is to
simplify the writing of programs that visit subtrees of the
directory structure, and more important, to avoid the
separation of portions of the hierarchy. If arbitrary links to
directories were permitted, it would be quite difficult to
detect when the last connection from the root to a directory
was severed.
Also, the authors are not Thompson and Ritchie, but Ritchie and Thompson.
The full paper is available from:
http://cm.bell-labs.com/cm/cs/who/dmr/cacm.html
This would appear to contradict Martien's suggestion about remaining
true to Unix's roots by providing support for nontrees; the paper is
from 1974 and probably qualifies as the Revealed Truth on this issue.
Goven this, one wonders why the original readdir() function returned
'.' and '..' at all. I believe that the intent was to be functionally
compatible with the pre-readdir() method, which was to open(2) the
directory file and read the 16-byte directory entries out of it.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 12 Feb 2001 10:33:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Radical readdir suggestion
Message-Id: <slrn98ff0g.hhu.abigail@tsathoggua.rlyeh.net>
Mark Jason Dominus (mjd@plover.com) wrote on MMDCCXXII September MCMXCIII
in <URL:news:3a87ab0f.33c$1b4@news.op.net>:
""
"" I seem to recall that the original paper about Unix from the Bell
"" System Technical Report series, by Thompson and Ritchie, mentions that
"" although the Unix filesystem may be an arbitrary DAG, it is not
"" allowed to contain loops, precisely for the reason that they will
"" complicate the implementation of programs that traverse the filesystem.
Well, if it has a loop, it would not be a DAG in the first place. ;-)
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: Mon, 12 Feb 2001 09:56:48 GMT
From: zac_thomas@my-deja.com
Subject: Re: Removing leading/trailing spaces
Message-Id: <968c0u$lnv$1@nnrp1.deja.com>
In article <m3ae7sn355.fsf@mumonkan.sunstarsys.com>,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> zac_thomas@my-deja.com writes:
>
Thanks Joe - I think I am going about this the wrong way!
Zac
> my $var = " ";
> $var =~ s/^\s+$//; # emtpies all "blank" strings
>
> For details, see
>
> % man perlop
>
> Also, (un)pack is good for handling records with fixed-width
> fields; so can split() with an appropriate regexp. See
>
> % perldoc -f pack
> % perldoc -f split
> % man perlre
>
> A deja search of this newsgroup should pull up lots of relevant
threads.
>
> > ... same problem with removing leading/trailing spaces globally.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> There's a faq you should read for this in perlfaq4:
>
> % perldoc -q "strip blank space"
>
> [...]
>
> > I would be grateful for any tips.
>
> There is also a module on CPAN for handling CSV files called
Text::CSV.
> You might be better off just trying that instead.
>
> HTH
>
> Joe Schaefer
> --
> #include <stdio.h> /* requires gcc and *nix
> use strict; system("cc -x c $0") and die $?; open C, "|a.out" or die
$! . q*/
> main(){char s[32]; remove("a.out"); printf("%s/C
hacker\n",fgets(s,32,stdin));
> return 0;}/*; print C "Just another Perl"; close C or die$?; #*/
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 11 Feb 2001 12:23:13 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: Removing leading/trailing spaces
Message-Id: <wkr915jzg9.fsf@math.uio.no>
Joe Schaefer <joe+usenet@sunstarsys.com> writes:
> $var =~ s/^\s+$//; # emtpies all "blank" strings
$var = '' unless $var =~ /\S/;
TMTOWTDI
Peter
--
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!
------------------------------
Date: Mon, 12 Feb 2001 09:58:46 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Sending multiple files with CGI.pm.
Message-Id: <9688i9$9fg$1@newsy.ifm.liu.se>
How can I send multiple files with CGI.pm?
This doesn't work. It will send both files as one download with the
separators included.
$file1='/tmp/file1.exe';
$file2='/tmp/file2.exe';
#!/usr/local/bin/perl
use CGI qw/:push -nph/;
$| = 1;
print multipart_init();
for ($file1,$file2) {
print multipart_start(-type=>'download/execute');
local($/);
open(FILE,$_);
binmode(FILE);
print <FILE>;
close(FILE);
print multipart_end;
}
File content after download:
--------- =_aaaaaaaaaa0
HTTP/1.1 200 OK
Content-Type: download/execute
<FILE1 contents>
--------- =_aaaaaaaaaa0
HTTP/1.1 200 OK
Content-Type: download/execute
<FILE2 contents>
How to make it work?
/jN
--
_____________________ _____________________
| Jonas Nilsson | | |
|Linkoping University | | Telephone |
| IFM | | --------- |
| Dept. of Chemistry | | work: +46-13-285690 |
| 581 83 Linkoping | | fax: +46-13-281399 |
| Sweden | | home: +46-13-130294 |
|_____________________| |_____________________|
------------------------------
Date: Mon, 12 Feb 2001 08:55:55 -0500
From: "Eric" <eric.kort@vai.org>
Subject: Re: Splitting a quote-comma delimitted string
Message-Id: <968pno$1av3$1@msunews.cl.msu.edu>
Egad! My humble apologies, and thanks for pointing this out.
Eric
"Gwyn Judd" <tjla@guvfybir.qlaqaf.bet> wrote in message
news:slrn98943n.7o0.tjla@thislove.dyndns.org...
> I was shocked! How could Eric <eric.kort@vai.org>
> say such a terrible thing:
> >How can I split the following without splitting on the comma inside
quotes:
>
> This is in the FAQ:
>
> perldoc -q 'How can I split a [character] delimited string except when
> inside [character]?'
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
>
> "We look for things."
> "So I've heard."
>
> -- Reginod and Geordi in ST:TNG "Samaritan Snare"
------------------------------
Date: 12 Feb 2001 09:57:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: TCP server
Message-Id: <968c37$fo2$2@mamenchi.zrz.TU-Berlin.DE>
Studio 51 <leekembel@hotmail.com> wrote in comp.lang.perl.misc:
>Hi, I'm monkeying around with a simple TCP server, and I have a question
>regarding how to handle signals.
>
>I understand it's bad to put a whole lot of code into a handler for a
>signal. Apparently (among other things) if you use a function in that
>handler that was already in use when the signal arrived, Perl might dump
>core. Well, I have a big fat mess of stuff I want to do when I get a SIGHUP
>(Kill a bunch of child processes, write to a log, write to STDOUT, close
>filehandles, exec(), etc...). The recommended way to handle incoming signals
>seems to be to just set a simple flag that the rest of the program can deal
>with. The problem is that I can't check that flag while I'm blocking with
>accept(). My little server may not get a new connection for some time, and
>if it gets the SIGHUP while it's waiting for accept() to return then it
>won't get a chance to check for the flag till it gets a new connection.
You can make the socket non-blocking and call accept() repeatedly,
checking flags (and delaying) between calls.
>Should I really be concerned with putting too much code in a Perl signal
>handler?
If you can afford an occasional server crash (clean up a core dump,
restart the server), it's probably not worth the bother. How often
is "occasional"? Nobody knows, except you when you run the application.
Reports range from "It almost never happens" to "It crashes all the time".
Anno
------------------------------
Date: Mon, 12 Feb 2001 12:56:39 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: TCP server
Message-Id: <b4Rh6.2254$ZS3.10658@eagle.america.net>
On Mon, 12 Feb 2001 08:04:20 GMT, Studio 51 <leekembel@hotmail.com> wrote:
>Hi, I'm monkeying around with a simple TCP server, and I have a question
>regarding how to handle signals.
>
>I understand it's bad to put a whole lot of code into a handler for a
>signal. Apparently (among other things) if you use a function in that
>handler that was already in use when the signal arrived, Perl might dump
>core. Well, I have a big fat mess of stuff I want to do when I get a SIGHUP
>(Kill a bunch of child processes, write to a log, write to STDOUT, close
>filehandles, exec(), etc...). The recommended way to handle incoming signals
>seems to be to just set a simple flag that the rest of the program can deal
>with. The problem is that I can't check that flag while I'm blocking with
>accept().
Sure you can. Check for EINTR return from accept().
--
Garry Williams
------------------------------
Date: 12 Feb 2001 13:24:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: the best solution?
Message-Id: <968o5h$o78$2@mamenchi.zrz.TU-Berlin.DE>
Chris Fedde <cfedde@fedde.littleton.co.us> wrote in comp.lang.perl.misc:
>#/usr/bin/perl -w
>#
># Please excuse jeopardy style posting
># Are you asking for something different than this?
>#
>$count += /\bthe\b/ig while (<DATA>);
>print $count,"\n";
>
>__END__
>In article <v_Ug6.63$s4.218@news.indigo.ie>,
>Tony O Sullivan <tony@codeisland.net> wrote:
>>Hi all,
>>I know this seems like a simple problem but I can't figure out the best way
[snip problem]
Correct solution posted in jeopardy position. You know better
than that, Chris. Furrfu!
Anno
------------------------------
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 V10 Issue 272
**************************************