[11163] in Perl-Users-Digest
Perl-Users Digest, Issue: 4763 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 27 18:07:16 1999
Date: Wed, 27 Jan 99 15:00:16 -0800
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, 27 Jan 1999 Volume: 8 Number: 4763
Today's topics:
Re: anonymous blocks of code? (Charles DeRykus)
Re: Anyone know of a stock quote script? <gellyfish@btinternet.com>
Re: Anyone know of a stock quote script? (Gaetan Lord)
Re: CDDA Access? Or CDDB even! <amcleod@caribSPAMsurf.com>
Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris <gellyfish@btinternet.com>
Re: dupes in Perl <gellyfish@btinternet.com>
Example of mod http posting a form <gavin@optus.net.au.dontspam.myass>
Re: Example of mod http posting a form <ludlow@us.ibm.com>
HELP with string parsing and scoring <paxtond@ix.netcom.com>
HELP- lock a file <carwong@newbridge.com>
Re: HELP- lock a file <ludlow@us.ibm.com>
Re: Jesus Rides a HOG(tm) : was :CONCLUSIVE PROOF: The (Oly)
Re: multi column sort in perl (Andrew M. Langmead)
Re: Perl Criticism [summary] topmind@technologist.com
Re: Perl Criticism [summary] <uri@ibnets.com>
Re: Recursively reading files <gellyfish@btinternet.com>
redirect fails <aaron_newcomb@inter-tel.com>
Re: Request for negative value list indexes <uri@ibnets.com>
Re: Request for negative value list indexes (Mike Stok)
Re: sendmail part deux <gellyfish@btinternet.com>
Re: Version Check <gellyfish@btinternet.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 Jan 1999 20:31:25 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: anonymous blocks of code?
Message-Id: <F68JoD.2rH@news.boeing.com>
In article <2wrr2.4133$Ge3.17561713@news.itd.umich.edu>,
Sean McAfee <mcafee@waits.facilities.med.umich.edu> wrote:
>
>My own variation:
>
>my $file_contents = do { local (@ARGV, $/) = 'filename', <> };
>
>my $node_list;
>chomp(@{ $node_list = [ do { local @ARGV = 'Unix_boxes.txt'; <> } ] });
or when the cooler idioms fade from memory:
my $file_contents = `cat filename`;
(assuming you're not on some unmentionable,
emasculated excuse of an OS :)
--
Charles DeRykus
------------------------------
Date: 27 Jan 1999 21:42:59 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Anyone know of a stock quote script?
Message-Id: <78o193$298$1@gellyfish.btinternet.com>
On Wed, 27 Jan 1999 01:34:10 GMT dturley@pobox.com wrote:
>
> Hopefully this answer is acceptable to Mr. Larry "I led the standardization
> of the C language" Rosler. I would hate to get anymore of his snotty,
> holier-than- thou email correcting honest oversights.
>
Dont do that. I dont see Larry ever giving anyone a raving for something
that wasnt deserved and I would include myself in that. We have enough
trouble with flame merchants as it is dont we ?
Cool it.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 27 Jan 1999 22:31:50 GMT
From: gaetan@gotlib.montreal.sgi.com (Gaetan Lord)
Subject: Re: Anyone know of a stock quote script?
Message-Id: <slrn7av4rd.1shh.gaetan@gotlib.montreal.sgi.com>
On 26 Jan 1999 14:32:16 GMT, Cypher <cypher5@yahoo.die.spammers.com> wrote:
>Hi,
>I'm looking for a stock quoting script that would send thw output to
>email. Does anyone know of such a script?
>All I need is the ticker symbol and the current value (Last traded at)
>to be sent to an email message.
>
>Cheers,
>Cypher.
>
>---
>(A)bort (R)etry (W)hackthefuckoutofit
>---
>If you want to email me please take die.spammers out of my email address.
Hi,
I'm not a good programmers, but the follwing code will do what you want.
Note, it's configure to work with a proxy
2 way to call the script
gq ticker1 ticker2 ...
or by creating a ticker file, like
sgi 15 20
where 15 is the minimum threshold and 20 the maximum
this will put a - or + in the W columns
with this ticker file, you call the script without argument
here's the output
W TICKER LAST CHANGE TRADE DATE TIME OPEN HIGH LOW
---------------------------------------------------------------------------
SGI 18.0000 -0.1250 1961400 1/27 4:07P 18.500 18.688 17.875
here's the code.
hope this could be useful for other people
BTW, i got a similar code to look for the news header, and display with lynx
#!/usr/local/bin/perl
use File::Basename;
use IO::Socket;
use Getopt::Std;
use strict;
package main;
my $rcfile="/home/gaetan/.get_quoterc";
my $EDITOR="/bin/vi";
my $proxy='proxy.stlaurent.sgi.com';
my $proxyport=8080;
my $SymbolStr;
my $symbol;
my ($min, $max);
my ($stock, $date, $info, @info, $getcmd);
my ($sock,$ticker,$end,$time,$change,$open,$high,$low,$trade);
my ($mois,$jour,$an);
my (%SYMBOL,$w);
# parse command line args
my $rc=&getopts ("e");
if (! $rc) {
print ("\n\nUsage: $0 [-e] [ticker] \
-e: edit the config file \
no args: show quote from $rcfile\n");
exit;
}
if ( @ARGV > 0 ) {
$SymbolStr=join("+",@ARGV);
print "[$SymbolStr]\n";
}
# execute the proper code to deal with options
if (my $opt_e) { exec "$EDITOR $rcfile"; exit; }
if ( -e $rcfile ) {
open(RCFILE,"$rcfile") || die "
========================================
Can't open $rcfile
======================================== \n\n";
} else {
open(RCFILE,">$rcfile") || die "
========================================
Can't create $rcfile
======================================== \n\n";
print "Creating ticker file $rcfile\n";
print "Writing SGI ticker has default\n";
print RCFILE ("# Get_quote config file\n");
print RCFILE ("# columns 1 -> quotes\n");
print RCFILE ("# columns 2 -> minimum (visual alert)\n");
print RCFILE ("# columns 3 -> maximum (visual alert)\n");
print RCFILE ("SGI 5 40\n");
close RCFILE;
open(RCFILE,"$rcfile") || die "
========================================
Can't reopen $rcfile
after creation
======================================== \n\n";
}
# read the ticker
if ( ! $SymbolStr ) {
while ( <RCFILE> ) {
if ( $_ !~ /#/ ) {
$_=~s/\s+/,/g;
($symbol,$min,$max)=split(/,/,$_);
$symbol =~ tr/a-z/A-Z/;
$SYMBOL{$symbol}=$_;
$SymbolStr=$SymbolStr . "+" . $symbol ;
}
}
close RCFILE;
}
getquote();
sub getquote {
package;
$sock = new IO::Socket::INET (PeerAddr => $proxy,
PeerPort => $proxyport,
Proto => 'tcp',
);
die "Socket could not be created. Reason $!\n" unless $sock;
# the following line is spilt in 2 parts to fit 80 columns
$getcmd="http://quote.yahoo.com/download/quotes.csv?";
$getcmd=$getcmd . "symbols=$SymbolStr&format=sl1d1t1c1ohgv&ext=.csv";
# send the cmd to the proxy
print $sock "GET $getcmd\r\n";
#retrieve the stock info
@info=<$sock>;
foreach $stock (@info) {
# remove trailing char
chop($stock);
chop($stock);
# "SGI",12,"7/2/1998","4:01PM",-0.1875,12.25,12.25,12,816300
($ticker,$end,$date,$time,$change,$open,$high,$low,$trade)=split(/,/,$stock);
# remove " from date and remove year to display only month and days
$date=~tr/"//d;
($mois,$jour,$an)=split(/\//,$date);
$date="$mois/$jour";
$time=~tr/"//d;
# remove the M at the end of time
chop($time);
$ticker=~tr/"//d;
$ticker=~tr/a-z/A-Z/d;
$w="";
($symbol,$min,$max)=split(/,/,$SYMBOL{$ticker});
if ( $max eq "" ) { $max=10000 ; }
if ( $min eq "" ) { $min=-1 ; }
if ( $end > $max ) { $w="+"}
if ( $end < $min ) { $w="-"}
close $sock;
write;
}
}
format STDOUT_TOP=
W TICKER LAST CHANGE TRADE DATE TIME OPEN HIGH LOW
---------------------------------------------------------------------------
.
format STDOUT =
@< @<<<<< @##.#### @##.#### @####### @>>>> @>>>>> @##.### @##.### @##.###
$w,$ticker,$end, $change, $trade, $date,$time, $open, $high, $low
.
--
--
----------------------------------------------------------------------
Gaetan Lord - FTA - gaetan@sgi.com - SGI - Montreal, Canada
pager: gaetan_p@montreal.sgi.com (200 car. max)
"There is no future in time traveling"
----------------------------------------------------------------------
------------------------------
Date: Wed, 27 Jan 1999 10:31:50 -0400 (AST)
From: "Angus McLeod" <amcleod@caribSPAMsurf.com>
Subject: Re: CDDA Access? Or CDDB even!
Message-Id: <nzpyrbqpnevofhespbz.f685t21.pminews@news.caribsurf.com>
Naturally, I ment CDDB. :-/
On Mon, 25 Jan 1999 16:49:42 -0400 (AST), Angus McLeod wrote:
>Is there any code around to assist in accessing the internet CDDA servers?
>
>
------------------------------
Date: 27 Jan 1999 21:35:15 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris 2.6 OS
Message-Id: <78o0qj$295$1@gellyfish.btinternet.com>
On Wed, 27 Jan 1999 13:56:17 -0500 Peter J. Messore wrote:
> Tony>And these errors would be...what? Oh, you didn't
> Tony>tell us. I'll take a stab though: you don't have a
> Tony>C compiler on the box.
>
>
> We currently have Sun WorkShop Compilers C/C++ 4.2 and they are up and
> working just fine.
>
When prompted in configure for your C compiler answer 'c89' instead of 'cc'
as long as that is in your path - you may have to add some other paths to
your library path and so forth but it certainly is that compiler that is
the problem.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 27 Jan 1999 22:34:55 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: dupes in Perl
Message-Id: <78o4af$2g7$1@gellyfish.btinternet.com>
On 27 Jan 1999 17:30:48 +0100 Jonathan Feinberg wrote:
> tadmc@metronet.com (Tad McClellan) writes:
>
>> I have similarly stepped on my di^H^H... on a part of my anatomy
>> that is very painful to step on, in the past.
>
> If I were physically able to do such a thing, I'd be in another line
> of work entirely.
>
Just like :
"If I could walk that way I would be earning a thousand dollars a day on
sunset strip"
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 27 Jan 1999 21:17:42 GMT
From: "Gavin Cato" <gavin@optus.net.au.dontspam.myass>
Subject: Example of mod http posting a form
Message-Id: <WnLr2.1$lO6.245448@news0.optus.net.au>
Would anyone be able to show me a quick sample bit of code that does a http
POST to a website? (i.e. without shelling out to use Lynx)
i.e.
POST http://www.website.net/cgi-bin/whatever.cgi?code=xxxxx&VALUE=aaaa
etc..
thanks
--
--
Gavin Cato - Optus Network Engineer - gavin@optus.net.au
gawk; talk; date; wine; grep; touch; unzip; touch; gasp; finger; gasp;
mount; \
fsck; more; yes; gasp; umount; make clean; make mrproper; sleep
------------------------------
Date: Wed, 27 Jan 1999 15:27:09 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Example of mod http posting a form
Message-Id: <36AF84AD.968E29B3@us.ibm.com>
Gavin Cato wrote:
>
> Would anyone be able to show me a quick sample bit of code that does a http
> POST to a website? (i.e. without shelling out to use Lynx)
Look at the documentation for the LWP module. It has example code.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 27 Jan 1999 17:37:03 -0500
From: Danny Paxton <paxtond@ix.netcom.com>
Subject: HELP with string parsing and scoring
Message-Id: <36AF9509.1297A97D@ix.netcom.com>
Hello...
I am looking for some help. I am taking a 31 character string from an
HTML FORM and attempting to treat each character as an individual answer
to a question of a test. I am then trying to assign a certain number
depending on the individual character (it changes depending on the
answer and question number). I am then trying to keep a running total
so that I can get an overall score. I have tried to use substr() to
isolate the idnividual characters of the string but am not enough of an
accomplished perl programmer to see where my mistakes may lie. If
someone could give me the first couple of lines of code I would greatly
appreciate it.
Thank you.
------------------------------
Date: Wed, 27 Jan 1999 16:33:32 -0500
From: Carmen Wong <carwong@newbridge.com>
Subject: HELP- lock a file
Message-Id: <36AF862C.ADF3C27C@newbridge.com>
I tried to place an exclusive lock in a file right after I opened it, somehow other users can write to that file. Does anyone
know how to fix that ? or anyother function I can use ?
$LOCK_EX = 2;
open(FH, "+<$textA") or ErrorAbort(2, "Unable to open textA file");
flock(FH, $LOCK_EX) or ErrorAbort(2, "Unable to lock file");
thanks,
Carmen
------------------------------
Date: Wed, 27 Jan 1999 15:56:14 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: HELP- lock a file
Message-Id: <36AF8B7E.CD9983B0@us.ibm.com>
Carmen Wong wrote:
>
> I tried to place an exclusive lock in a file right after I opened it, somehow other users can write to that file. Does anyone
> know how to fix that ? or anyother function I can use ?
>
> $LOCK_EX = 2;
>
> open(FH, "+<$textA") or ErrorAbort(2, "Unable to open textA file");
>
> flock(FH, $LOCK_EX) or ErrorAbort(2, "Unable to lock file");
When flock locks a file, it is only a suggestion. All processes have to
play by the same rules or you end up with exactly the situation you
mentioned. I suggest you read the documentation on flock. It
explicitly states that the lock is "merely advisory."
$ perldoc -f flock
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 27 Jan 1999 16:20:30 -0600
From: "Olice (Oly) Certain" <ocertain@webwide.net>
Subject: Re: Jesus Rides a HOG(tm) : was :CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <78o71b$k27$1@news.unicomp.net>
grendal wrote in message <36AEED60.EAC2CC5B@buffnet.net>...
Please stop cross-posting this thread to sci.astro.amateur.
>Take sci.astro.amateur out of your list...or start posting something
related.
>Astro and riding aren't that far apart, unless you're a dip shit.
>My 21 year old rebuilt honda cb 750 will tool you insignificant fuckers
anyway.
>Not saying I don't want a harley, but what am I supposed to do, kill
>one of you? (Easier done then said, but you can't see the stars from
>jail.) You probably don't ride anyway. If you want to debate the facts,
>email me, you bloated jackass. (Or even better...
>actually, I like this NG too much to go on.) Always good to have
>my theory proven, genetics are in fact working in reverse.
>
>Ears wrote:
>>
>> On Wed, 27 Jan 1999 03:11:43 GMT,
>> Spider Fighter <spiderfighter@REMOVETHISTOEMAILMEhotmail.com> wrote:
>>
>> >Well, _that_ was interesting.
>> >Please don't post this thread to the rec.games.video.nintendo newsgroup
any more.
>>
>> OK, consider it done. No longer crossposting there.
>>
>> BTW, did John Lennon ride a Harley ? Or any other bike, for that matter ?
>>
>> I'll bet if Harleys were around when Jesus was, he, and all his apostles
>> would've ridden. Well, they did say he could see the future....
>>
>> BTW, this thread is no longer being posted to rec.games.video.nintendo.
>> If you don't want this posted to your newsgroup either, reply to us here
>> at rec.motorcycles.harley, and we will be glad to take it out of the
>> header for you. Unless of course, you're smart enough to do it yourself
>> before you repost.
>>
>> This thread is currently being maintained by bonafide Harley riders now.
>>
>> --
>> *Ears* 98 XL 1200 Custom
>> kd4zkw@amsat.org
>> http://www.dialisdn.net/user/cdlevin
------------------------------
Date: Wed, 27 Jan 1999 21:19:50 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: multi column sort in perl
Message-Id: <F68Lx2.CB8@world.std.com>
"Ryan Bark" <ryan.h.bark@boeing.com> writes:
>Suppose I have an array with the following columns on each line:
> "col1 col2 col3 col4"
>Is there a way in perl, to sort this list by col3, then col2 and col4?
Break the columns up into distinct elements, keeping track of which
record they refer too, sort by comparing col3, then if equal col2, and
if still equal col4. Once sorted, rearrange the original records to
the same order. For more information take a look at "Far More Than
Everything You Ever Wanted to Know About Sorting"
<URL:http://www.perl.com/CPAN/doc/FMTEYEWTK/sorting>
while(<>) {
push @record, @_;
push @fields, [ split ' ', $_ ];
}
@indicies = sort { $fields[$a][2] cmp $fields[$b][2] or
$fields[$a][1] cmp $fields[$b][1] or
$fields[$a][3] cmp $fields[$b][3] } 0 .. $#record;
@sorted = @record[@indicies];
Or more compactly with a Scwartian Transform:
@sorted = map { $_->[0] }
sort { $a->[3] cmp $b->[3] or
$a->[2] cmp $b->[2] or
$a->[4] cmp $b->[4] }
map { [ $_, split ' ', $_ ] } @record;
--
Andrew Langmead
------------------------------
Date: Wed, 27 Jan 1999 21:20:30 GMT
From: topmind@technologist.com
Subject: Re: Perl Criticism [summary]
Message-Id: <78nvuj$ma4$1@nnrp1.dejanews.com>
In article <m3emojgsdm.fsf@moiraine.dimensional.com>,
Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:
> iqbal <iqbal@orangenet.co.uk> writes:
>
> > Dont suppose anyone has a summary to this thread :-)
>
> Sure, here you go.
>
> topmind (drooling on himself in a small padded room):
> Hi, I'm a total idiot. They promise that they'll let me
> try to tie my own shoes Real Soon Now, but for now I am
> condemned to sitting in a padded room with nothing more
> lethal than a keyboard to entertain me. Oh yeah, perl
> sucks.
>
> CLPM regulars (gathered around a long table, throwing back
> pints of Guinness):
> Perl doesn't suck.
>
> topmind (receiving his hourly medication):
> Perl is evil. Most of the problems on our planet are the
> result of Perl programmers. We must stop the evil perl
> programmers before they do any more damage
>
> CLPM regulars (looking irritated):
> Perl isn't evil. It's a tool, and a damn fine one.
>
> topmind (back to drooling on himself):
> But think of the managers.
>
> CLPM regulars (back to being cocky and self-assured):
> Fuck the managers. If they were stupid enough to become
> managers in the first place that's not our problem.
>
> topmind (still drooling, also now twitching occasionally):
> But think of the bottom line.
>
> CLPM regulars:
> Fuck the bottom line. If your programmers aren't producing
> good code then you'll go out of business and the bad programmers
> will be out of their jobs. Not our problem.
>
> topmind (still drooling, also now grunting occasionally as
> he tries to color his friend the purple dinosaur):
> Perl is unreadable. How can you evil people use a language that
> is incomprehensible to people who haven't learned it.
>
> CLPM regulars:
> English is also unreadable if you don't know it.
>
> topmind (calm again after his injection):
> Perl is unreadable.
>
> ...(much time passes during which the last three points are repeated)...
>
> topmind (becoming agitated again, somebody call his nurse):
> Dammit, people, I'm telling you that I'm stupid, unreliable,
> and unmaintainable. Oops, I mean perl is stupid, or something.
>
> CLPM regulars:
> Why don't you go implement your hypothetical language so that
> we can all see the benefits.
>
> topmind (growing ever more agitated, his eyelids begin to twitch
> ferociously as his nostrils flare):
> I'm not smart enough to understand the value of an implementation.
>
> CLPM regulars:
> Oh, go away then.
>
> ...(much time passes as the previous three points are repeated)...
>
> topmind (once again smiling as his medication takes hold):
> I can program in dozens of languages.
>
> CLPM:
> You are lying.
>
> topmind:
> I'm not lying. I know Visual Basic.
>
> CLPM:
> That's not dozens.
>
> topmipnd (once again getting mad):
> I was exaggerating. I can't believe you people expect me to
> mean the things I say. That is so unfair. Perl is unmaintainable.
>
> CLPM:
> Go away.
>
> .......<snip much more>........
>
> I'd provide the rest of the story, unfortunately this is the point at
> which I started plonking everyone posting to the thread. You'll need
> to ask elsewhere to see how it ends up, although I'd be surprised if
> any last minute character development took place. :-)
>
> HTH
>
> dgris
> --
> Daniel Grisinger dgris@moiraine.dimensional.com
> perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
> m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
>
Well, at least the insults aren't ALL directed my way.
That was refreshing to see. You at least hinted at the
anti-establishment cowboy-like center-of-the-prairie
attitude of some of those here.
P.S. I don't drool (unless Lara walks by)
-tmind-
http://www.geocities.com/SiliconValley/Lab/6888/langopts.htm
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 27 Jan 1999 17:01:39 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Perl Criticism [summary]
Message-Id: <39iudsv0ho.fsf@ibnets.com>
>>>>> "t" == topmind <topmind@technologist.com> writes:
t> P.S. I don't drool (unless Lara walks by)
she must be on your screen's background since you seem to drool all over
your keyboard judging by your spelling and grammar (or rather lack
thereof). regardless of how bad a programmer you are (and you seem
awfully bad from your illogical diatribes), you wouldn't get hired in
most places with such a bad grasp of english (and such a strong grasp on
a cdrom character)
interesting how bottommind read these threads and keeps flaming but has
nothing to say in any other thread. maybe he could actually post some
code or comments in a reply to a real perl question. then we can see the
true genius of his unobsfucated code.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: 27 Jan 1999 21:54:23 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Recursively reading files
Message-Id: <78o1uf$29g$1@gellyfish.btinternet.com>
On 26 Jan 1999 13:51:53 -0700 Tom Christiansen wrote:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> "Laran Coates" <lcoates@bu.edu> writes:
> :I want to write a script to read through all files within a directory tree.
>
> Use the find tool -- remember that a tools-based approach
> will always win over a monolith.
>
> perl -i.bak -pe 's/foo/bar/g' `find . -type f -print`
>
Of course on some systems this might result in an error like :
bash: /usr/bin/perl: Arg list too long
> Or use the File::Find module for more elaborate work.
>
Or when you need to process more than a couple of hundred files ...
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 27 Jan 1999 16:43:18 -0500
From: "Aaron Newcomb" <aaron_newcomb@inter-tel.com>
Subject: redirect fails
Message-Id: <78o1a3$nfe$1@remarQ.com>
I am trying to learn perl. I am currently using Active Perl for Win 32 on a
Windows NT 4.0 server. I have a form which I want to use to create an HTML
document and then redirect the user to that new document for their preview.
The script works fine when I do not post any data to it (i.e. run the form
directly), but when I post information to it from my html page it times out
instead of going to the redirect site. Any help would be appreciated. Here
is the script. Please forgive syntax errors as I am still new at this.
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n/ /g;
$FORM{$name} = $value;
}
# get time
$time = localtime;
# open an HTML file called the Company Name
open(OUTF,">install/jobs/$FORM{'name'}pkg.html") or &dienice("Couldn't open
file for writing. Please notify webmaster.");
# write the header
print OUTF <<endheader;
<HTML>
<HEAD>
<TITLE>$FORM{'name'} Job Package</TITLE>
<META name="description" content="">
<META name="keywords" content="">
</HEAD>
<BODY BGCOLOR=FFFFFF TEXT=000000 LINK=0000FF VLINK=800080>
<CENTER><H3>Inter-tel Technologies</H3>
<H1>NEW ORDER CHECKLIST AND JOB PACKAGE</H1>
This Job Package has been approved by:<BR>
Future Enhancement</CENTER><P>
endheader
;
# write the basic info
print OUTF <<endbasic;
<CENTER><I>This quote was generated on $time by $FORM{'slsrep'} in the
$FORM{'department'} Sales Group.</I></CENTER>
<H3>Project Number: $FORM{'projnum'}<BR>
Customer Name: $FORM{'name'}<BR>
Customer DBA: $FORM{'dba'}<BR>
The $FORM{'neworex'} customer number is $FORM{'number'}<BR>
$FORM{'when'} cut date is requested on $FORM{'cutdate'} because:</H3>
$FORM{'why'}<BR>
</BODY>
</HTML>
endbasic
;
# close the file
close(OUTF);
# redirect
use CGI qw(:standard);
print redirect('http://cinci.inter-tel.com');
sub dienice {
($errmsg) = @_;
print "<html><body>\n";
print "<h2>Error</h2>\n";
print "$errmsg<p>\n";
print "</body></html>\n";
exit;
}
------------------------------
Date: 27 Jan 1999 16:54:22 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Request for negative value list indexes
Message-Id: <39k8y8v0tt.fsf@ibnets.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> @ary = qw(A B C D E) $first = $ary[0]; @rest = @ary[2 .. -1]; #
BL> does NOT work, because -1 < 2
.. is defined as an incrementing operation. so how could it handle 2 .. -1?
to get what you want just use reverse as in:
@ary[reverse -1 .. 2]
or
reverse @ary[-1 .. 2]
so there is no need for a decrementing ..
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Wed, 27 Jan 1999 16:27:59 -0600
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Request for negative value list indexes
Message-Id: <eyxTMRkS#GA.188@news1.texas.rr.com>
In article <39k8y8v0tt.fsf@ibnets.com>, Uri Guttman <uri@ibnets.com> wrote:
>
>>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
>
> BL> @ary = qw(A B C D E) $first = $ary[0]; @rest = @ary[2 .. -1]; #
> BL> does NOT work, because -1 < 2
>
>.. is defined as an incrementing operation. so how could it handle 2 .. -1?
>
>to get what you want just use reverse as in:
>
> @ary[reverse -1 .. 2]
>or
> reverse @ary[-1 .. 2]
>
>so there is no need for a decrementing ..
But Bart may have been lamenting that @array[2 .. -1] doesn't go from
element 2 to the last element of the array, if you consider -1 as the
rightmost element of the array then reverse @ary[-1 .. 2] probably doesn't
do what you want:
DB<1> @array = (1 .. 10)
DB<2> print $array[-1]
10
DB<3> print $array[9]
10
DB<4> print @array[2 ..9]
345678910
DB<5> print reverse @array[-1 .. 2]
32110
in python you can do something like array[2:] to go from array[2] to
the last element of the array and array[2:-1] to go from array[2] to the
element before the last.
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
| 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 27 Jan 1999 21:09:32 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: sendmail part deux
Message-Id: <78nvac$27r$1@gellyfish.btinternet.com>
On Wed, 27 Jan 1999 11:38:38 +0000 iqbal wrote:
> Hi
>
> I have a shell command which works fine
>
> `$mailprog who@ever.com <message` #where mailprog is /usr/sbin/sendmail
>
> Now I want to do this in perl, but am not getting very far.
> open(MAIL, "|$mailprog who@ever.com");
>
> *see below;
> close(MAIL)
>
> * this is the part where I am stuck, do I need to read in the message
> and print each line out to the MAIL filehandle, or can i just put the
> entire thing in (this i would prefer).
>
Of course this is answered in perlfaq9:
How do I send mail?
Use the sendmail program directly:
open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq")
or die "Can't fork for sendmail: $!\n";
print SENDMAIL <<"EOF";
From: User Originating Mail <me\@host>
To: Final Destination <you\@otherhost>
Subject: A relevant subject line
Body of the message goes here, in as many lines as you like.
EOF
close(SENDMAIL) or warn "sendmail didn't close nicely";
etc etc ...
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 27 Jan 1999 21:24:05 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Version Check
Message-Id: <78o05l$292$1@gellyfish.btinternet.com>
On Tue, 26 Jan 1999 18:39:07 -0500 Murtuza Chhil wrote:
> Hi,
> I am writing installation scripts using perl,
> need to overwrite certain active X ocx / dll , hence I need to know the
> version so that I don't overwrite the newer one with an olde one
Ah ye olde ocx dangerous ;-}
I think that there is a windows API that will enable you to check this -
you will need to use Win32::API and check out the Win32 SDK to find out
what function from what DLL you will need to use.
There is no Perl builtin that will do this of course...
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4763
**************************************