[8798] in Perl-Users-Digest
Perl-Users Digest, Issue: 2415 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 24 18:07:35 1998
Date: Fri, 24 Apr 98 15:00:26 -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 Fri, 24 Apr 1998 Volume: 8 Number: 2415
Today's topics:
Allowing only one script to access a script on a differ <petershane@yahoo.com>
Re: Array of Hashes <zenin@archive.rhps.org>
Best way to prompt for input? <lamber45@EGR.msu.edu>
Re: Can an assignment and a substitution be done in one (Alfred von Campe)
Re: Can an assignment and a substitution be done in one <jdf@pobox.com>
Re: Defending Perl (Ilya Zakharevich)
Re: foreach question <rootbeer@teleport.com>
Re: Help: crypt for Win32 ?? (Ben Coleman)
How to read command line literally? (Saurabh S. Tendulkar)
Re: How to turn off warnings at *compile time*? <jdf@pobox.com>
Re: How to turn off warnings at *compile time*? <rootbeer@teleport.com>
Re: Just a thought... <jason@primal.ucdavis.edu>
Re: Just a thought... (Andre L.)
Re: Just a thought... <uri@sysarch.com>
Re: Just a thought... <lr@hpl.hp.com>
Re: Many users, only one of me!! (Pat Luther)
Re: matching man page lines (John Erjavec V)
Re: NEED HELP GRABBING RECORDS OUT OF TEXT FILE (Craig Berry)
Re: NEED HELP GRABBING RECORDS OUT OF TEXT FILE <beske@worldnet.att.net>
Re: NEED HELP GRABBING RECORDS OUT OF TEXT FILE <brianm@kodak.com>
PERL chmod on NT <kregeste@cbu.edu>
Re: Perl classes or training <beske@worldnet.att.net>
Re: Read-only value? (Jason Gloudon)
Re: reading a binary file <rootbeer@teleport.com>
Re: RMS should be invited to O'Reilly's "Free Software <sds@usa.net>
Re: Using LEDA with Perl in C++ (Ken Fox)
Re: Using module outside @INC without changing @INC <zenin@archive.rhps.org>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 24 Apr 1998 22:07:43 +0100
From: "Peter" <petershane@yahoo.com>
Subject: Allowing only one script to access a script on a different server?
Message-Id: <893452072.27206.0.nnrp-04.c2de5b4a@news.demon.co.uk>
Hello all!
Hate to post the question here, but I posted the same question in CGI
newsgroups ages ago, didn't receive any replies. Here is my last attempt -
Do not stay on and read this if you don't like learners asking questions.
I have two Perl scripts.
I want script no. 1 to run script no. 2 where is located in different
server.
To achieve that, I use Sockets to open a connection between those two
servers. Then, script no. 1 will request for the script no. 2.
But, there is a security issue. I want script no. 2 to be only accessible by
script no. 1.
I used the HTTP_REFERER method (check if it's from script no. 1 or not) ...
But, when I tested it - The HTTP_REFERER was set to null when script no. 1
requested script no. 2 ...
I don't want that .. I want HTTP_REFERER to be set to where the script no. 1
is.
Do anyone know why? Or if HTTP_REFERER won't set to the path of CGI scripts.
Or do you know any other way around it? (In order to prevent outside users
to access the script no. 2)
Thank you very much for reading this. I apologise if any of you are
upsetting about the message being here and, finally, pardon my English.
Peter.
------------------------------
Date: 24 Apr 1998 20:10:05 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Array of Hashes
Message-Id: <893449045.236986@thrush.omix.com>
[posted & mailed]
malhotra@ap.org wrote:
: I have an array made up of hashes,
Not possible. You have an array of hash /references/. This is
where the confusion is found. You can't treat references like
non-references because nothing ever gets dereferenced for you.
: and would like to parse this array using foreach. If I try
: foreach %hashelem (@my_array)
Close, what you want is:
foreach my $hashref (@my_array) {
print $hashref->{'some_key'};
}
-Take out the "my" if you're using a perl < 5.004, but leave
it in if you can.
: I get a syntax error. I tried using
: for ($i = 0; $i < $#my_array; $i++)
: {
: %hashelem = $my_array[$i]
: print $hashelem{'some_key'};
: }
: I do not get the desired output.
The "%hashelem = $my_array[$i]" statement trys to assign a hash
ref to a hash without first dereferencing it. You probably want:
%hashelem = %{ $my_array[$i] };
See man perlref, perldsc, and perllol.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Fri, 24 Apr 1998 17:08:04 -0400
From: David Lee Lambert <lamber45@EGR.msu.edu>
Subject: Best way to prompt for input?
Message-Id: <Pine.GSO.3.96.980424170354.16181C-100000@area51>
What's the best way to prompt a user for input, then check it? I wrote
this little test program that doesn't do what I expect:
#!/usr/bin/perl
print "Enter a word: ";
<STDIN>; chomp;
if (m/^[a-z]+$/) {
print "Word was $_\n";
} else {
print "\'$_\' was not a word, matched \'$1\' instead\n";
};
# end
It always prints the error message. Any ideas?
--
m/lamber45\100(egr|pilot)\.msu\.edu/ and print <<MHM16x20
David Lee Lambert -- Just another perl hacker
webstuph at http://web.egr.msu.edu/~lamber45
MHM16x20
------------------------------
Date: 24 Apr 1998 19:53:35 GMT
From: alfred@hw.stratus.com (Alfred von Campe)
Subject: Re: Can an assignment and a substitution be done in one statement?
Message-Id: <6hqqjv$2sg@transfer.stratus.com>
Earl Hood (ehood@medusa.acs.uci.edu) wrote:
|> ($foo = $bar) =~ s/x/y/;
Of course, why didn't I think of that. Now the (rhetorical)
question is, which one is more "elegant":
$foo = $bar;
$foo =~ s/x/y/;
or
$foo = $bar; $foo =~ s/x/y/;
or
($foo = $bar) =~ s/x/y/;
Alfred
--
+------------------------------------------------------------+
| Phone: H: 978.448.6214, W: 508.490.6306, fax: 508.460.2888 \
| Mail: Alfred von Campe, 402 Lowell Road, Groton, MA 01450 \
| Email: alfred@hw.stratus.com \
+----------------------------------+-----------------------------+
| Why is common sense so uncommon? | I'd rather be flying N4381Q |
+----------------------------------+-----------------------------+
------------------------------
Date: 24 Apr 1998 15:55:07 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Can an assignment and a substitution be done in one statement?
Message-Id: <son3gct0.fsf@mailhost.panix.com>
alfred@hw.stratus.com (Alfred von Campe) writes:
> I often find myself wanting to assign the modified value of one
> scalar to another. Something like this:
>
> $foo = $bar;
> $foo =~ s/x/y/;
>
> Can this be done in one fell swoop?
>From the blue Camel:
($new = $old) =~ s/foo/bar/g;
This is a consequence of the fact that in Perl the assignment operator
produces an lvalue.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 24 Apr 1998 21:04:10 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Defending Perl
Message-Id: <6hquoa$aiq$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <6hqofl$so3$1@csnews.cs.colorado.edu>:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> :Anyone with dejanews access can confirm that you participated in
> :discussions on 200x slowness of Perl. Yes, I remember that your
> :results were only 80x on your PPro200, but you have seen that most the
> :other guys get numbers around 200.
>
> Time to put your money where your mouth is, Ilya. Here's your challenge:
Hmm, I think my contributions to Perl give me enough credit, so if you
need money, advance them from that account ;-).
> TASK 1: Write a file copy program using I/O calls (not mmap).
> There is no limit to the size of the files.
Copying files does not create an added value.
> TASK 2: Write a program that reads all its input, then prints
> out those input lines in the opposite order they
> were read in. There is no limit to the number of
> input records, nor of their lengths.
Inverting lines in the file does not create an added value.
> TASK 3: Write a word frequency counter. Read stdin, and produce
> a list of unique words and the frequency they occurred at the
> end of the run. There is no limit to the size of the input
> file, the length of a line, the number of different words,
> nor the size of each.
This may be 1% useful for some real computer-related job indeed.
It is interesting that people with system-programming background treat
system maintainance tasks as something the computers are good for ;-).
Of course, given the amount of time people spend on maintainance one
may easily forget what she wanted to use computers for *at the
beginning*.
Fortunately, the maintainance (=no-added-value) tasks come in a few
categories, so a well-designed tool (like Perl ;-) makes one feel much
better about them.
It is those non-maintainance, "real"-value-added (*), tasks which are
too diverse to be covered by the few primitives Perl has. And doing
them outside of the primitives puts Perl on the knees of its
abysmally slow interpreter.
(Note that the Perl compile-tree interpreter is quite quick as
interpreters go, but not comparable with any real compiled language.)
Moving things into extensions does not always help. For example, the
horrible slowness of Perl subroutine call often makes Math::Pari
slower than GP/PARI, though GP interpretes directly over
non-preprocessed input program. (GP is a tcl-like driver for PARI,
which is in turn a huge library of math-related routines done over
math-related objects.)
Ilya
(*) P.S. The above distinction is not even 90% bullet-proof, since
one may easily argue that distributing info from a web server
*creates* an additional value without adding new knowledge. So
probably one may need somehow s/value/knowledge/ in all the
dictionaries around... ;-)
------------------------------
Date: Fri, 24 Apr 1998 20:02:10 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: "Gilly (kEQNql)" <mingtian@hanmail.net>
Subject: Re: foreach question
Message-Id: <Pine.GSO.3.96.980424125906.5518q-100000@user2.teleport.com>
On Fri, 24 Apr 1998, Gilly (=EB=C5=D1=CE=F1=EC) wrote:
> foreach (sort (@filelist)) { .. }
>=20
> Does it sort each time during the loop? or only once?
foreach's list is built up before the iterations start, so it's done only
once. (There are some exceptions, but they don't apply here.) Hope this
helps!=20
--=20
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 24 Apr 1998 20:40:19 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Re: Help: crypt for Win32 ??
Message-Id: <3540f7c3.69200204@news.mindspring.com>
On Wed, 22 Apr 1998 22:26:03 -0400, Vish Viswanathan <vish@netscape.com>
wrote:
>Where can I find UNIX-like "crypt" function for Win32 Perl ?? Does
>anyone have a crypt lib for NT Perl ??
>thanks
There's a Perl version of crypt at
http://www.pdv-systeme.de/users/martinv/Crypt.pm. I've used it
successfully under Win32 without problems. See the usenet message
<34ee8886.524144494f47414741@radiogaga.harz.de> for Martin's post about it.
Ben
--
Ben Coleman tnguru@termnetinc.com |
Senior Systems Analyst |
TermNet Merchant Services, Inc. |
Atlanta, GA |
------------------------------
Date: 24 Apr 1998 20:37:45 GMT
From: tendus@rpi.edu (Saurabh S. Tendulkar)
Subject: How to read command line literally?
Message-Id: <6hqt6p$n7a@newsfeeds.rpi.edu>
I am new to Perl. I want to read the command line literally. For example,
if I say
perlprog *.txt
ARGV expands into all the .txt files. I want $ARGV[0] = "*.txt". How can
I do that ?
I preferably dont want to change the command line in any way.
TIA
Saurabh.
------------------------------
Date: 24 Apr 1998 15:46:41 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: How to turn off warnings at *compile time*?
Message-Id: <vhrzgd72.fsf@mailhost.panix.com>
psf@euclid.jpl.nasa.gov (Peter Scott) writes:
> BEGIN {
> local $^W = 0;
> use FindBin;
> }
>
> As the FAQ says, $^W controls run-time warning printing.
> And of course this is compile-time.
Not pretty, but:
BEGIN {
local $^W;
require FindBin;
import FindBin;
}
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Fri, 24 Apr 1998 20:11:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter Scott <psf@euclid.jpl.nasa.gov>
Subject: Re: How to turn off warnings at *compile time*?
Message-Id: <Pine.GSO.3.96.980424130706.5518s-100000@user2.teleport.com>
On 24 Apr 1998, Peter Scott wrote:
> Subject: How to turn off warnings at *compile time*?
> The Cwd in 5.004_04 is not -w friendly;
Grrr. Gotta get that fixed. All Perl modules should be -w clean. If anyone
reading this has any time to spare for this effort, contact the Perl
developers at once.
> BEGIN {
> local $^W = 0;
> use FindBin;
> }
Close. The problem is that the local doesn't happen until (the BEGIN
block's) runtime, and by then FindBin is already loaded. Here's one
solution.
{
my $save_warn;
BEGIN { $save_warn = $^W; $^W = 0; }
use FindBin;
BEGIN { $^W = $save_warn; }
}
> In the mean time, I guess I'll just hack on Cwd.pm to stop Perl complaining...
Thanks! And submit your patch with the perlbug program. Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 24 Apr 1998 13:11:26 -0700
From: Jason Christian <jason@primal.ucdavis.edu>
Subject: Re: Just a thought...
Message-Id: <Pine.OSF.3.95.980424130423.3619G-100000@primal.ucdavis.edu>
On 24 Apr 1998, Tom Christiansen wrote:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> "Larry Rosler" <lr@hpl.hp.com> writes:
> :Nowadays, many scholars and others try to divorce the notation from
> :religious significance by referring to "BCE" (Before the Common Era) and
> :"CE" (Common Era).
>
> I disbelieve. And considering that the majority of Americans
> are at least nominally Christian, I don't see this changing.
The BCE/CE thing may well be scholarly peecee, but Larry *did* say "many
scholars," and in that, at least, he is correct. He didn't attempt
"most," and nor will I...
> Unless you live in Israel or the Soviet Union,
> BC and AD are pretty here to stay, even if it offends you.
The offense, if any, sprang full grown and ornately armored in Tom Tom
the Christian's Son's post...and nowhere, at least in the preserved
snippets, do I see any prediction on Larry's part that the scholarly
conceit will soon play in Peoria. Whether I like it or not.
---------------------------------------------------------------------------
Jason Christian University of California, Davis
jason@primal.ucdavis.edu Agricultural and Resource Economics
Office:(530)752-1357 FAX:(530)752-5614 Davis, CA 95616
------------------------------
Date: Fri, 24 Apr 1998 16:05:41 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Just a thought...
Message-Id: <alecler-2404981605410001@dialup-685.hip.cam.org>
I rather like the system of counting dates from I September MCMXCIII.
Instead of April 24, 1998 A.D. (Anno Domini), we could say MDCXCVII
September MCMXCIII E.A. (Era of Abigail).
The only downside to it that we would have to deal with the MM bug in only
CCCIII days instead of DCXVII with the current system.
A.L.
================================
In article <MPG.faa72fd6a08fe189896bd@news.ais.net>,
edwardj.keepthespamthanks@torvalds.com (Ed Jamison) wrote:
> I had an interesting idea the other day. It's not really practical, but
> I thought it would be interesting to find out what others had to say
> about it...
> Currently, time (in years) is kept track of in years since the birth of
> Christ (somewhat accurately). Hence, we are now in the year 1998 A.D. I
> thought it would be interesting to start with a new method of keeping
> track, A.C. or A.U. This new method would begin on January 1, 1970 as 0
> A.C. (After Computers, or Ante Computers; After UNIX, Ante UNIX). As I
> said before, not really practical, but interesting. Computers can be
> viewed as one of the most important inventions in the history of time and
> they have done more to change the way things work on this planet than
> just about anything I can think of. (With a few exceptions, of course;
> electricity, engines, etc...)
> I'm just curious what comments I could get from this.
------------------------------
Date: 24 Apr 1998 16:36:56 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Just a thought...
Message-Id: <x790ovdkif.fsf@sysarch.com>
>>>>> "EJ" == Ed Jamison <edwardj@torvalds.keepthespamthanks.com> writes:
EJ> Long ago (Fri, 24 Apr 1998 16:34:51 GMT), in a land far far away,
EJ> jdporter@min.net spouted nonsense similar to this...
>> Ed Jamison wrote: > > I had an interesting idea the other day.
>> It's not really practical, but > I thought it would be interesting
>> to find out what others had to say > about it... > Currently, time
>> (in years) is kept track of in years since the birth of > Christ
>> (somewhat accurately). Hence, we are now in the year 1998 A.D. I
>> > thought it would be interesting to start with a new method of
>> keeping > track, A.C. or A.U. This new method would begin on
>> January 1, 1970 as 0 > A.C. (After Computers, or Ante Computers;
>> After UNIX, Ante UNIX). As I > said before, not really practical,
>> but interesting.
>>
>> 1. If you just want to escape the hegemony of the Christian
>> heritage over Western civilization, you would do better to adopt
>> one of the dating systems already in use elsewhere in the world.
>> 2. The 'A' in 'AD' stands for 'Anno', not 'After'; 3. 'Ante' means
>> 'before', not 'after'.
as a non follower of JC (i'm jewish) i was taught to use BCE and CE,
Before Common Era and Common Era. we don't acknowlodge JC as worthy of
counting years as BC and AD do since they have deeply religious
meanings. especially since AD mean after the coming of the lord. we use
the CE years as an accepted method for convenience.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---- 8 Years of Perl Experience, Available Immediately
uri@sysarch.com --------- Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net -------- http://www.northernlight.com
------------------------------
Date: Fri, 24 Apr 1998 13:37:42 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Just a thought...
Message-Id: <6hqt6q$ptq@hplntx.hpl.hp.com>
Tom Christiansen wrote in message
<6hqpeh$so3$2@csnews.cs.colorado.edu>...
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc,
> "Larry Rosler" <lr@hpl.hp.com> writes:
>:Nowadays, many scholars and others try to divorce the notation from
>:religious significance by referring to "BCE" (Before the Common Era)
and
>:"CE" (Common Era).
>
>I disbelieve. And considering that the majority of Americans
>are at least nominally Christian, I don't see this changing.
How does one "disbelieve" a statement which is fact? I chose not to
define "many" but now I'll try. An AltaVista search for "+bce +ce"
returns 3848 documents. The first few results should give you an idea:
1. Timeline: Traditional Vietnam (300 BCE - 1900 CE)
2. Early Native American Cultures (1000 BCE-1600 CE)
3. NCTE-talk: Re: [ncte-talk] re: bce/ce
4. Alabama Archives: 300 BCE - 1000 CE
5. Spring Phenomena, 25 BCE to 38 CE
6. Notes for History 102: 3000 BCE to 1450 CE
7. Great Stupa at Sanchi, 3rd C. BCE-1st C. CE
I didn't imply that "this" (BC/AD) would change, whether it should or
not. Americans still refuse to convert to the metric system, though the
rest of the world has.
>Unless you live in Israel or the Soviet Union,
>BC and AD are pretty here to stay, even if it offends you.
If by this you mean that only Jews or atheists (I guess -- there is no
Soviet Union) might be sensitive enough to use this terminology, you are
dead wrong, as you can see from the above citations.
>--tom
>--
> Tom Christiansen tchrist@jhereg.perl.com
>
>
> "Help save the world!" --Larry Wall in README
Responses like yours are no way to "Help save the world!"
Back to Perl???
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 24 Apr 1998 14:14:02 -0700
From: t_patl@qualcomm.com (Pat Luther)
Subject: Re: Many users, only one of me!!
Message-Id: <t_patl.893451746@gano>
Bojan Landekic <bland@sprint.ca> writes:
>My problem is this. I am designing a "login" and a "logout" program for
>our Intranet and have run into some problems. There are approximately
>1,000 users, and at any given time 100-200 of them need to be "logged
>in".. now this part I have finished. I also need to keep track of their
>total hours a day, a week, for 2 weeks, for a month,...etc... This is
>posing me a little problem. I cannot decide which is better. Keep one
>file with things like username:time:action: with action being "LOGIN" or
>"LOGOUT" and then just have a script which goes through this file and
>calculates time based on the username provided to it. OR, the other
>option is to have a separate file for each user with the same
>information.
How about something like this, assuming you don't care about exactly *when*
they logged in or out.
A file has one line for each user:
username:timespentloggedin:logintime
When they log in, it writes the time into the logintime field,
when they log out, it computes the difference between current time and
login time and adds the difference to timespentloggedin.
This could be exanded out to:
username:tsliyear:tslimonth:tsliweek:tsliday:logintime
And have the script add the appropriate values to all the fields.
Put a Zero in the :logintime field when they log out, and you can use a non-zero
value to generate a list of who's logged in currently.
One problem, of course, is that this doesn't do anything for people who
leave without logging out (break out some other way...)
What does my answer have to do with perl?
Well...uh....the whole thing can be done with a perl script! :-)
And...uh...I wrote a perl script once.
(Actually I wrote a perl script *yesterday*) (only directly plagiarized
less than half of it. Thank you everyone!)
??pat
--
--
Pat Luther t_patl@qualcomm.com
The opinions expressed herein are probably not those of Qualcomm.
We don't really agree on all that much....
------------------------------
Date: 24 Apr 1998 20:06:36 GMT
From: jev@pconline.com (John Erjavec V)
Subject: Re: matching man page lines
Message-Id: <6hqrcc$2f4$1@bell.pconline.com>
Ronald J Kimball (rjk@coos.dartmouth.edu) wrote:
: John Erjavec V wrote:
: > next if (/^\s+(.+).+(\1)\s*$/); #for all headers
:
: This is probably the slowest regex. It seems like it would take a lot of work
: to try all the possibilities with non-matching lines, and since you're
: matching headers and footers I bet most of the lines don't match.
:
: This should speed it up a little without changing the set of matching strings:
:
: /^\s+(\S.*).+(\1)\s*$/
:
: Anyway, that regex will match lines like
:
: " foo does weird things if\n"
:
: Are you sure that's what you want?
No, not really. What I am trying to do is match lines like:
SYBPERL(1) 26/Mar/98 SYBPERL(1)
and like:
User Contributed Perl Documentation User Contributed Perl Documentation
While I haven't run into any problems with matching lines like you pointed
out, that now appears to be blind luck. I was trying to go for "working",
and then "good", but I guess I should have been at least trying for
"working right". :) I tried matching right, space, center, space, and
then left in a regex, but never could get that to work right. That one
seemed to match just about everything, while the one I used has the
appearance of just matching the headers.
: > if ($#ARGV == 1) {
: > if (($ARGV[1] eq "4up") || ($ARGV[1] eq "2up") || ($ARGV[1] eq "2+")) {
: > @system_args = ("lp", "-t$manpage", "-o$ARGV[1]", "$temp_file");
: > }
: > } else {
: > @system_args = ("lp", "-t$manpage", "$temp_file");
: > }
: >
: > system @system_args;
:
: What should @system_args be if $#ARGV is 1 and $ARGV[1] is none of those strings?
That's a good question, too. I actually never noticed that one. However,
I did take out the if block, and just have it print the pages in a 2+
configuration. That's the way I like it, and that's the way it will stay
unless|until I put in GetOpts code for printing options.
Thanks for the suggestions. I think I will try working on the regex to
make it right, and _then_ try to speed things up.
-JEV
--
John Erjavec V PGP fingerprint:
jev@pconline.com 7593 1B5A AE11 C0FE BA09 EB5E 8DE9 D2E5 BF5B 87AD
http://www.pconline.com/~jev/index.html
------------------------------
Date: 24 Apr 1998 20:30:51 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: NEED HELP GRABBING RECORDS OUT OF TEXT FILE
Message-Id: <6hqspr$3c1$1@marina.cinenet.net>
Ron B. (ronb@schoolnotes.com) wrote:
: I have a text file with 90,000 lines. Each line contains a 100 byte record
: with fields separated with the | character. One of the fields contains
: numbers and the whole file is sorted by this field in ascending order.
:
: I would like any suggestions on how I can reach into this file and select
: only those records where this certain field is equal to some specific
: number.
my $keyFieldIndex = 3; # Or whatever.
my $desiredKey = 1234; # Or whatever.
my @matches = ();
while (<FILE>) {
my @fields = split /\|/;
my $key = $fields[$keyFieldIndex];
next if $key < $desiredKey;
last if $key > $desiredKey;
push @matches, $_;
}
If you'd prefer to stash the pre-split list of fields instead (which is
likely to be more convenient), replace the push with
push @matches, [ @fields ];
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 24 Apr 1998 16:41:54 -0400
From: Bryan Beske <beske@worldnet.att.net>
Subject: Re: NEED HELP GRABBING RECORDS OUT OF TEXT FILE
Message-Id: <6hqtfs$nph@bgtnsc02.worldnet.att.net>
I'm assuming that these are fixed length records so that
record #x is at position (x-1)*100.
If true, use the binary search technique with file positioning/read
commands to search. This is an nlog(n) style search which will
be simple/fast searching method.
Consulting available if you need help writing it.
Bryan
------------------------------
Date: Fri, 24 Apr 1998 16:45:29 -0400
From: Brian Mathis <brianm@kodak.com>
To: "Ron B." <ronb@schoolnotes.com>
Subject: Re: NEED HELP GRABBING RECORDS OUT OF TEXT FILE
Message-Id: <3540F9E9.CC92E4BE@kodak.com>
Ron B. wrote:
>
> Hi,
>
> I have a text file with 90,000 lines. Each line contains a 100 byte record
> with fields separated with the | character. One of the fields contains
> numbers and the whole file is sorted by this field in ascending order.
>
> I would like any suggestions on how I can reach into this file and select
> only those records where this certain field is equal to some specific
> number.
>
> Thank you.
>
> Ron
Your best bet is to probably just search through the file for the
number, and keep track of the lines that you find it in. something
like:
while( <FILE> ) {
if( /$number/ ) { push(@list, $_) }
}
now you have a list of only the lines with that number in it, now you
can split it up as you see fit.
Brian Mathis
------------------------------
Date: Fri, 24 Apr 1998 14:57:43 -0500
From: KenRoy Regester <kregeste@cbu.edu>
Subject: PERL chmod on NT
Message-Id: <3540EEB7.57CEB7C0@cbu.edu>
Does the PERL chmod function for files have the same syntax as UNIX in
the NT version of PERL?
------------------------------
Date: Fri, 24 Apr 1998 16:38:48 -0400
From: Bryan Beske <beske@worldnet.att.net>
Subject: Re: Perl classes or training
Message-Id: <6hqta2$nph@bgtnsc02.worldnet.att.net>
Check out http://www.onsightinc.com/
------------------------------
Date: Fri, 24 Apr 1998 20:33:31 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: Read-only value?
Message-Id: <slrn6k1to7.ei2.jgloudon@hyssop.bbn.com>
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
.
.
>No error messages. Maybe your attempt to modify a read-only value is
>happening somewhere else. Of course 'if (! $val)' never evaluates to true
>in this scenario. Also, you probably mean $val=" ";
The original poster's perl version is probably older than 5.003.
--
Jason Gloudon
------------------------------
Date: Fri, 24 Apr 1998 20:04:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Alex Rentzis~ <arentzis@hal031.ch.intel.com>
Subject: Re: reading a binary file
Message-Id: <Pine.GSO.3.96.980424130241.5518r-100000@user2.teleport.com>
On 24 Apr 1998, Alex Rentzis~ wrote:
> code similar to this does not work:
>
> while(read(STDIN,$data,$SIZE_OF_FILE)) {
> @array = unpack('N*',$data);
> }
>
> I was hoping that @array would now contain the entire array.
Do you mean to be replacing @array each time through the while loop?
Maybe you mean to read the entire file into $data and unpack that, but I'd
read chunks of (say) 8192 bytes at a time, and push them onto @array. If
that's not the problem you're having, try asking again. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Apr 1998 17:15:37 EDT
From: Sam Steingold <sds@usa.net>
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <m3g1j2apl6.fsf@mute.eaglets.com>
>>>> In a very interesting message <6hqc07$mb7@dfw-ixnews6.ix.netcom.com>
>>>> Sent on Fri, 24 Apr 98 15:44:10 GMT
>>>> Honorable eugene@cs.umb.edu (Eugene O'Neil) writes
>>>> on the subject of "Re: RMS should be invited to O'Reilly's "Free Software Summit"":
>> That's basic copyright law: you can't arbitrarily revoke a license once
>> you issue it.
Are you a lawyer?! Whether yes or no, could you please provide a
reference?
AFAIK, the copyright *holder* can do whatever he wants at any time.
E.g., *AFAIK*, MS can, *at any time*, request that we stop running win95
and erase it from our HDs, and whoever doesn't comply is a felon. This
is why the FSF assignment document specifically prohibits this kind of
crap (the paper I signed stipulated that I assign copyright to the FSF
on the condition that they keep it under the GPL, so if FSF is bought by
MS and GNU Emacs is licensed under a non-GPL-compatible license, I can
claim my bit of code back).
Disclaimer: I am *NOT* a lawyer.
--
Sam Steingold, running RedHat5 GNU/Linux (http://www.linux.org)
Micros**t is not the answer. Micros**t is a question, and the answer is Linux,
the choice of the GNU (http://www.gnu.org) generation.
The program isn't debugged until the last user is dead.
------------------------------
Date: 24 Apr 1998 19:50:27 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Using LEDA with Perl in C++
Message-Id: <6hqqe3$o5v1@eccws1.dearborn.ford.com>
[copy mailed to author]
Bertram Ludaescher <ludaesch@kilda.informatik.uni-freiburg.de> writes:
>
> Has anybody experience with C++ embedded Perl code when used together
> with LEDA classes?
>
> It seems that they don't work together. ...
>
> [lot's of pre-processor name conflicts]
This is a really big problem. Perl jumps through hoops to leave a
clean symbol space (i.e. linkage), but it has massive numbers of
preprocessor macros and type definitions. I've solved the problem
by putting my perl interfaces into separate files from my application
code. That isn't a very good solution, but it generally works.
If you need to intermingle perl functionality with your application
code, you can try using my perl-c++ wrappers. Those wrappers wrap
the underlying perl implementation completely -- everything is nicely
packaged inside of class and class templates. Look in CPAN under
authors/id/KENFOX.
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
Date: 24 Apr 1998 19:56:13 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Using module outside @INC without changing @INC
Message-Id: <893448214.589123@thrush.omix.com>
Peter Scott <psf@euclid.jpl.nasa.gov> wrote:
>snip<
: but I was looking for a really concise idiom since others will use
: this module and I would prefer to publish just a one-liner.
Hmm, I'm not sure if a one-liner could do it.
: Of course, you can put a path in require, but then it's evaluated at
: runtime, not compile time, and that won't do in this case.
BEGIN { require "/full/path/to/module.pm" }
But don't forget to call import() in that BEGIN if you really
want it to look like a use. -If it's a class, you probably
don't need it though.
: I worked around the problem, but would still appreciate any suggestions.
This isn't a one liner, but how about:
use lib "/my/lib";
use Foo;
no lib "/my/lib";
--
-Zenin
zenin@archive.rhps.org
------------------------------
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 2415
**************************************