[6582] in Perl-Users-Digest
Perl-Users Digest, Issue: 207 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 31 09:15:26 1997
Date: Mon, 31 Mar 97 06:00:31 -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 Mon, 31 Mar 1997 Volume: 8 Number: 207
Today's topics:
Re: Functions and operators (Mark)
gethostbyaddr ? <LGR96JAL@lustudat.student.lu.se>
Re: HELP with Perl search script! (Eric Bohlman)
Re: HELP with Perl search script! (M.J.T. Guy)
Hlp pls : "push" errors when scripts ported to Unix. (s sweeting@neuronet.com.my
Re: Hlp pls : "push" errors when scripts ported to Unix <gwhassan@prodigy.net>
Re: How do I ? .. rand/srand champs read this (Mark)
How to get from one array to another <christop@ozinter.co.jp>
Re: How to get from one array to another (Tad McClellan)
Re: Microsoft Running Naked Through the Streets? (Nathan V. Patwardhan)
MS PWS, Perl, Forms and Parameter Passing <fisherka@xmission.com>" <fisherka@xmission.com>
Re: Perl hourly fees? (Cameron Laird)
Re: Perl mishandles some multidimensional array referen <merlyn@stonehenge.com>
Re: Q: sorting by date <tchrist@mox.perl.com>
Re: Question on Strings [HELP] (David Alan Black)
Requesting help for idiotic (?) problem .. sigh. (Mark)
Re: Requesting help for idiotic (?) problem .. sigh. <dalewis@cs.buffalo.edu>
Re: Requesting help for idiotic (?) problem .. sigh. (Eric Bohlman)
Re: Requesting help for idiotic (?) problem .. sigh. (M.J.T. Guy)
Re: running a loop foreach $ARGV? (Eric Bohlman)
Re: running a loop foreach $ARGV? <liquid@ciberspace.com>
Re: running a loop foreach $ARGV? (Andrew M. Langmead)
Re: running a loop foreach $ARGV? <merlyn@stonehenge.com>
Re: Running CGI Scripts <flemingj@interaccess.com>
Re: scripts broken after 5.003 install (Simon Hyde (aka Jeckyll))
Re: Selena Sol's BBS on NT? (Simon Hyde (aka Jeckyll))
Re: skipping around in file being read... (Simon Hyde (aka Jeckyll))
Re: Webfax scripts or mods in Perl? <christop@ozinter.co.jp>
Re: What is the limitation to use DBD::Oracle module? <Tim.Bunce@ig.co.uk>
Re: Why is no subscripting allowed in custom sort routi (Michael Constant)
win32 sendmail (Vincent Koser)
Re: win32 sendmail <glauber@iws-irms.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 31 Mar 1997 06:11:16 GMT
From: (Mark)
Subject: Re: Functions and operators
Message-Id: <33425234.22781890@news.ntr.net>
On 30 Mar 1997 22:42:49 GMT, Hans Mulder< hansm@icgned.nl> wrote:
>Randal Schwartz <merlyn@stonehenge.com> wrote:
>
>> >>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:
>
>> Tom> @a = ('a'..'z');
>> Tom> $a = time @a; print "$a\n"; # takes no args, hence compiler error
>> Tom> $a = int @a; print "$a\n"; # takes one scalar arg
>> Tom> $a = unlink @a; print "$a\n"; # takes a list of args
>
>> Or this:
>
>> %3 = ( fred => 5, barney => 2);
>> $a = time %3; # no args, so time mod 3
>> $a = int %3; # one arg, so scalar (hash bucket stats)
>> $a = unlink %3; # list arg, so unlink qw(fred 5 barney 2)
>
>I think the worst case of overloading is the {,} notation: in list context
>
> do{3,8} has 2 elements: 3 and 8
> +{3,8} has 1 element : a reference to an anonymous hash ( 3 => 8 )
> ${3,8} has 1 element : $8
> $q{3,8} has 1 element : $q{'3' . $SUBSEP . '8'} (an element of %q)
> @q{3,8} has 2 elements: $q{'3'} and $q{'8'} (elements of %q)
> q{3,8} has 1 element : the string '3,8'
> <q{3,8}> has 2 elements: 'q3' and 'q8'
> /q{3,8}/ has 1 element if $_ matches /qqq/, 0 otherwise
>
>Is {,} a function or an operator? Or several of each?
>
>- HansM
>
You are asking if the *comma* is an operator or a function? Now I'm
confused...
The comma is a syntactic element, the same way a paren or a dollar
sign is syntactic in certain contexts. Comma is part of the syntax of
a function/sub/etc
And off the top of my head I'd call scalar() a compiler pragma or some
such. [not quoted here but in this thread.] You are asking
(forcing) the (possibly) non-default interpretation that the compiler
would normally make. Maybe compiler override or context override...
--
Mark <mark@ntr.net>
Please don't sue my boss because you don't
understand the concept of free speech.
*Pain is something funny that happens to YOU*
------------------------------
Date: Mon, 31 Mar 1997 11:23:05 +0200
From: Jane Lilja <LGR96JAL@lustudat.student.lu.se>
Subject: gethostbyaddr ?
Message-Id: <333F8279.2463@lustudat.student.lu.se>
Hi!
Anyone know of how to invoke and print out the result for
gethostbyaddr? And what is ADDRTYPE? In the book "Programming perl"
it states it is the same as gethostbyaddr 3 and i did a man lookup on
that but it didn't help me :-(
gethostbyaddr(ADDR,ADDRTYPE)
($name, $aliases, $addrtype, $length, @addrs)
Please, answer me via e-mail.
Thanks!
------------------------------
Date: Mon, 31 Mar 1997 05:47:41 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: HELP with Perl search script!
Message-Id: <ebohlmanE7w83H.28s@netcom.com>
Tom Knoblauch (tomk@infinityquest.com) wrote:
: I can only get the script to read the first if
: Each following if is ignored.
[snip]
: if ($age_group == $DATA{'age_group'}) {
^^
print <<"'FINISH' x 100;
I will not use == to compare strings.
That operator works on numbers only.
I will use eq when comparing strings for equality.
FINISH
------------------------------
Date: 31 Mar 1997 08:44:06 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: HELP with Perl search script!
Message-Id: <5hntgm$dqe@lyra.csx.cam.ac.uk>
Eric Bohlman <ebohlman@netcom.com> wrote:
>Tom Knoblauch (tomk@infinityquest.com) wrote:
>
>: I can only get the script to read the first if
>: Each following if is ignored.
>
>[snip]
>
>: if ($age_group == $DATA{'age_group'}) {
> ^^
>print <<"'FINISH' x 100;
>I will not use == to compare strings.
>That operator works on numbers only.
>I will use eq when comparing strings for equality.
>FINISH
And MUCH MUCH more importantly
"I will run my scripts with -w before posting."
It's great when scripts debug themselves.
Mike Guy
------------------------------
Date: Mon, 31 Mar 1997 03:11:09 -0600
From: sweeting@neuronet.com.my
Subject: Hlp pls : "push" errors when scripts ported to Unix. (simple 2-d arrays)
Message-Id: <859798998.26408@dejanews.com>
I had no problems using List of lists on an NT box, but now
porting the scripts to a Digital Unix machine, I have the following
error :
"syntax error in file - at line 14, next 2 tokens "push @allentries"
Execution of - aborted due to compilation errors. "
I was using Push as follows in the very simple script -
#!/usr/bin/perl
print "Content-type: text/html\n\n";
&Show;
sub Show {
$myfile = "top10.txt";
open (fileobject,"<$myfile") || die "Can't find $myfile :$!\n";
# Read in the file line by line.($_)
# Create an array for each entry and push (append) to @allentries
# which is consequently a 2-D array.
@allentries = ();
while (<fileobject>) {
@entry = split (/:/,$_);
push @allentries, [@entry];
}
# Close the file :
close fileobject;
# Print it out :
print "<TABLE>";
for ($i = 0; $i < 10 ; $i ++ ) {
print "<TR>";
for ($j = 0; $j < 2 ; $j ++ ) {
print "<TD>$allentries[$i][$j] : </TD>";
}
print "</TR>";
}
print "</TABLE>";
}
Another scrips also choked on references to 2-d arrays, such as
$allentries[$i][$j]
Does anyone have any ideas why this may not work ?
(The digital unix box is running perl 4 and NT has perl 5,
but i thought 'push' was applicable in perl 4)
Thank you very much in advance....
chas
ps. a cc to sweeting@neuronet.com.my would be much appreciated
since posting via DejaNews. thank you.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 31 Mar 1997 05:17:37 +0000
From: Greg Hassan <gwhassan@prodigy.net>
To: sweeting@neuronet.com.my
Subject: Re: Hlp pls : "push" errors when scripts ported to Unix. (simple 2-d arrays)
Message-Id: <333F48F1.307CCBCA@prodigy.net>
sweeting@neuronet.com.my wrote:
>
> while (<fileobject>) {
> @entry = split (/:/,$_);
> push @allentries, [@entry];
> }
> # Close the file :
> close fileobject;
>
> # Print it out :
> print "<TABLE>";
> for ($i = 0; $i < 10 ; $i ++ ) {
> print "<TR>";
> for ($j = 0; $j < 2 ; $j ++ ) {
> print "<TD>$allentries[$i][$j] : </TD>";
> }
> print "</TR>";
> }
> print "</TABLE>";
> }
That doesn't seem correct, as far as multi dim arrays but why
bother with them...
try:
print "<table>";
while (<FI>)
{
chop();
s/:/ : <\/td><td>/;
print "<tr><td>$_ : </td></tr>\n";
}
print "</table>";
This should be very portable :-)
-Greg
--
============================================
Greg Hassan
The Independent Solution
Web Developer (CGI, Java, C, Perl, Oracle)
http://www.hassan.com/
gwhassan@prodigy.net, 1-415-969-5856
============================================
------------------------------
Date: Mon, 31 Mar 1997 05:11:13 GMT
From: (Mark)
Subject: Re: How do I ? .. rand/srand champs read this
Message-Id: <33413ff3.18108371@news.ntr.net>
On 26 Mar 1997 12:35:38 -0800, Russ Allbery <rra@stanford.edu> wrote:
>Tom Phoenix <rootbeer@teleport.com> writes:
>
>> @list = 0..99; # Or whatever list of reasonable size
>> {
>> my @temp;
>> push @temp, splice @list, rand @list, 1 while @list;
>> @list = @temp;
>> }
>
>Ugh. Lines of code like that make me start to agree with Tom about the
>inherent evil of array to scalar automagic conversion. It took a while
>peering at that to follow what it does, and first glance was baffling.
>
>I find:
>
> push (@temp, splice (@list, rand ($#list + 1), 1)) while @list;
>
>*much* easier to read.
>
>--
>Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
I always found this approach nice...
for ($i = @list;$i >1;$i--) {push(@list, splice[@list, rand($i),1)}
no $temp means you can lean towards arrays of 'unreasonable size'
and the '$i = @list' is quite a bit more obviously a scalar assignment
so you don't have to do the horrible '$#list + 1' over and over...
I learned this from a basic program that had a 'swap' command
that could switch two variables values in one step. Scary huh?
Does perl have a 'swap' like command? Maybe larry could....
Nah, to damn trivial to be of use I suppose.
--
Mark <mark@ntr.net>
Please don't sue my boss because you don't
understand the concept of free speech.
*Pain is something funny that happens to YOU*
------------------------------
Date: Mon, 31 Mar 1997 14:35:50 +0900
From: "christop@ozinter.co.jp" <christop@ozinter.co.jp>
Subject: How to get from one array to another
Message-Id: <333F4D36.FCA@ozinter.co.jp>
Hi
I have this:
%Data = (
group1 => ["one:1.htm","two:2.htm","three:3.htm"],
group2 => ["ay:a.htm","bee:b.htm","cee:c.htm","dee:d.htm"]
);
and I want to get the group1 bits happily into elements of the list
array @instruction.
How do I do it ? Documentation has me stumped at this point..
As always I would be eternally grateful and moved onto the next level by
someone's assistance.
Cheers, Christopher.
Tokyo March 31st
(On the road to Mandarray..)
------------------------------
Date: Mon, 31 Mar 1997 05:39:42 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to get from one array to another
Message-Id: <up7oh5.lk.ln@localhost>
christop@ozinter.co.jp (christop@ozinter.co.jp) wrote:
: Hi
: I have this:
: %Data = (
: group1 => ["one:1.htm","two:2.htm","three:3.htm"],
: group2 => ["ay:a.htm","bee:b.htm","cee:c.htm","dee:d.htm"]
: );
: and I want to get the group1 bits happily into elements of the list
: array @instruction.
: How do I do it ? Documentation has me stumped at this point..
@instruction = @{$data{group1}};
: As always I would be eternally grateful and moved onto the next level by
: someone's assistance.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 31 Mar 1997 05:08:59 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Microsoft Running Naked Through the Streets?
Message-Id: <5hngtb$5kl@fridge-nf0.shore.net>
Mark () wrote:
: Was Microsoft also yelling 'Freeshow' as it ran thru the
: streets nekkid?
No. If someone was running through the streets yelling the word 'free,'
it probably wouldn't be Microsoft...
Considering that my original posting was a parody of recent Microsoft
trolls (by others), I think that we've gotten ample mileage out of it.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 31 Mar 1997 09:03:40 GMT
From: "Kurt A. Fisher <fisherka@xmission.com>" <fisherka@xmission.com>
Subject: MS PWS, Perl, Forms and Parameter Passing
Message-Id: <01bc3db3$fc6d67c0$510146a6@kurtfish>
Q1: Can MS PWS pass parameters to a perl script via the POST method or
that functionality not supported by the paired back MS PWS? Will the GET
method work?
I started using Perl_for_Win95 (ActiveWare), MS Frontpage and MS Personal
Web Server for initial "offnet" debugging of my perl scripts and web pages
prior to moving everything to my ISP. (My ISP's HTTP server does not
support the MS Server Extensions).
I've successfully tested simple "Hello world" scripts using form-submit
buttons and the POST method. I've successfull tested an environment
parameter passing script under perl, MS PWS and Internet Explorer.
However, I when I expand the test to include parameter passing from a form
via the POST method, I cannot seem to get seem to be able to MS Personal
Web server to recognize parameter passing. I get the 501 error,
"functionality not implemented."
I concluded that MS PWS is _so_ paired back from MS's full internet server
product that it does not support the basic function of parameter passing.
Is my conclusion right, or will the GET method work for testing forms?
Kurt A. Fisher
Email: fisherka@xmission.com
WWW: http://www.xmission.com/~fisherka
FTP Box: ftp.xmission.com /pub/users/f/fisherka
PGP Key: See WWW
------------------------------
Date: 31 Mar 1997 07:12:52 -0600
From: claird@Starbase.NeoSoft.COM (Cameron Laird)
Subject: Re: Perl hourly fees?
Message-Id: <5hod8k$7b0@Starbase.NeoSoft.COM>
In article <94ghh5.p5d.ln@localhost>, Tad McClellan <tadmc@flash.net> wrote:
>Patrick Poon (poon@sgi.com) wrote:
>: Hi folks,
>
>: I was just wondering...what's the going rate for a Perl programmer
>: nowadays?
>
>
>From zero to two hundred dollars per hour.
>
>That's my cheeky way of saying "it depends" ;-)
>
>
>I expect that the great bulk of Perl programming done by Independant
>Contractors is in the $40-100/hour range.
.
.
.
Isn't there a schedule written by one of the triumvirate that
categorizes something like
$25/hour: uncertain when to write "Perl"
vs. "perl".
$50/hour: likes Perl. Occasionally
writes subroutines.
$100/hour: native speaker of anonymous
functions.
? The original I remember as more grammatical, insightful,
and funny than this shadow that I offer.
--
Cameron Laird http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com +1 713 623 8000 #227
+1 713 996 8546 FAX
------------------------------
Date: 31 Mar 1997 06:47:56 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: hansm@icgned.nl
Subject: Re: Perl mishandles some multidimensional array references???
Message-Id: <8cragwfa0j.fsf@gadget.cscaper.com>
>>>>> "Hans" == Hans Mulder <Hans> writes:
Hans> Randal Schwartz <merlyn@stonehenge.com> wrote:
>> Again, the easiest way to get the syntax is to start with the seven
>> kinds of variable access, and what they can contain:
>> $S = scalar
>> $L[scalar] = scalar
>> $H{scalar} = scalar
>> @L[list] = list
>> @H{list} = list
>> %H = list (key/value pairs)
Hans> You forgot the seventh:
Hans> $H{list} = scalar
No, the seventh is:
@L = list
Bleh. Silly that I forgot that.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 519 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 31 Mar 1997 12:45:52 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Q: sorting by date
Message-Id: <5hobm0$qcp$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Randal Schwartz <merlyn@stonehenge.com> writes:
:This is pretty expensive on a large hash. You should be using
:something like the Schwartzian Transform, described in some detail in
:my "sorting" Unix Review columns at
:http://www.stonehenge.com/merlyn/UnixReview/.
And in *great* detail in http://www.perl.com/perl/all_about/sort.html
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
All language designers are arrogant. Goes with the territory... :-)
--Larry Wall in <1991Jul13.010945.19157@netlabs.com
------------------------------
Date: 31 Mar 1997 04:53:00 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Question on Strings [HELP]
Message-Id: <5hnfvc$d8s@pirate.shu.edu>
Hello -
bretth3522@aol.com (BrettH3522) writes:
>Is there any way to convert a string (of numbers to an integer). If not,
>is there a way to convert an integer into a string?
I don't think there's any way *not* to. What exactly are you aiming
to do, and what problems is it giving you?
David Black
dblack@icarus.shu.edu
------------------------------
Date: 31 Mar 1997 04:51:21 GMT
From: quarth@Walden.mo.net (Mark)
Subject: Requesting help for idiotic (?) problem .. sigh.
Message-Id: <5hnfs9$1ra@twain.mvp.net>
.. okay, I admit it. I'm in "Day 3" of learning Perl in 21
days. Heh. But heck, I'm trying to program some super simple stuff that I
can't seem to see the problem with. Can anyone explain what the problem
is with the code below? No matter what I enter, I always end up with,
"That is correct!!".
From what I can tell, the second line must have something wrong
with it, because if I replace "Answer" with a number, such as $name=1,
then everything works. Ideas? Thanks ..
#!/usr/local/bin/perl
$name="Answer";
print("What is the answer? ");
$ask=<STDIN>;
chop($ask);
until ($ask==$name) {
print("\n\nNope! Try again.\n\n");
print("What is the answer? ");
$ask=<STDIN>;
chop($ask);
}
if ($name==$ask) {
print("\n\nThat is correct!!\n\n");
}
------------------------------
Date: Mon, 31 Mar 1997 00:23:41 -0500
From: Douglas Lewis <dalewis@cs.buffalo.edu>
To: Mark <quarth@Walden.mo.net>
Subject: Re: Requesting help for idiotic (?) problem .. sigh.
Message-Id: <333F4A5D.6C1446CB@cs.buffalo.edu>
Mark wrote:
> until ($ask==$name) {
You probably want to use 'eq' not '=='
eq is a string comparison operator
== is a numeric comparison operator
most strings == 0.. so you are checking if (0 == 0) which is true for
almost all values of 0.
> if ($name==$ask) {
Same thing here.
------------------------------
Date: Mon, 31 Mar 1997 06:20:08 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Requesting help for idiotic (?) problem .. sigh.
Message-Id: <ebohlmanE7w9LK.3xo@netcom.com>
Mark (quarth@Walden.mo.net) wrote:
: From what I can tell, the second line must have something wrong
: with it, because if I replace "Answer" with a number, such as $name=1,
: then everything works. Ideas? Thanks ..
: #!/usr/local/bin/perl
: $name="Answer";
: print("What is the answer? ");
: $ask=<STDIN>;
: chop($ask);
: until ($ask==$name) {
^^
This is a common beginner's mistake. "==" compares two *numbers* for
equality. To compare two *strings*, you need to use "eq" instead. If
the book you're using didn't mention that fact before asking you to do an
exercise like this, the author needs to be taken out and shot.
------------------------------
Date: 31 Mar 1997 08:47:08 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Requesting help for idiotic (?) problem .. sigh.
Message-Id: <5hntmc$dqt@lyra.csx.cam.ac.uk>
Eric Bohlman <ebohlman@netcom.com> wrote:
>This is a common beginner's mistake. "==" compares two *numbers* for
>equality. To compare two *strings*, you need to use "eq" instead. If
>the book you're using didn't mention that fact before asking you to do an
>exercise like this, the author needs to be taken out and shot.
And if the author didn't say "Always use -w, beginner or expert.", s/he
should be hung, drawn and quartered.
Mike Guy
------------------------------
Date: Mon, 31 Mar 1997 06:15:23 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: running a loop foreach $ARGV?
Message-Id: <ebohlmanE7w9Dn.3q6@netcom.com>
Brett Longworth (blongwor@student.umass.edu) wrote:
: I need to do a bunch of stuff with every file from the command line.
: I've tried a foreach loop like:
[snip]
: and also a more convoluted construct:
: while (<>) {
: $file = $ARGV;
: while ($file = $ARGV) {
^
Oops.
: #stuff
: }
: }
: which does the same thing but worse, because it becomes an endless loop.
Probably the best idea is something like:
$lastfile="";
while (<>) {
if ($ARGV ne $lastfile) {
#insert stuff that needs to be done when new file encountered
$lastfile=$ARGV;
}
#insert stuff that needs to be done for each line of each file
}
------------------------------
Date: Mon, 31 Mar 1997 02:55:25 -0600
From: Daniel Honig <liquid@ciberspace.com>
Subject: Re: running a loop foreach $ARGV?
Message-Id: <333F7BFD.3C9B@ciberspace.com>
Eric Bohlman wrote:
>
> Brett Longworth (blongwor@student.umass.edu) wrote:
> : I need to do a bunch of stuff with every file from the command line.
> : I've tried a foreach loop like:
>
> [snip]
> : and also a more convoluted construct:
>
> : while (<>) {
> : $file = $ARGV;
> : while ($file = $ARGV) {
> ^
> Oops.
>
> : #stuff
> : }
> : }
> : which does the same thing but worse, because it becomes an endless loop.
>
> Probably the best idea is something like:
>
> $lastfile="";
> while (<>) {
> if ($ARGV ne $lastfile) {
> #insert stuff that needs to be done when new file encountered
> $lastfile=$ARGV;
> }
> #insert stuff that needs to be done for each line of each file
> }
What about using the inline features in perl?
For example using
If we put the script in a file called goodbye.pl
then every file specified on the command line will be parsed through
and the script body will be executed upon it...Any files changed
will be modified in line...
#! /shbang/line/perl -pi
s/Hello/Goodbye/fg;
------------------------------
Date: Mon, 31 Mar 1997 12:28:02 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: running a loop foreach $ARGV?
Message-Id: <E7wqMq.q8@world.std.com>
Douglas Lewis <dalewis@cs.buffalo.edu> writes:
>or the follwing (If you are interested in what file you are working on)
>my @PASSED_ARGV = @ARGV;
>foreach $FILE (@PASSED_ARGV)
>{
> @ARGV = ($FILE);
> while (<>)
> {
> # whatever
> }
>}
If all you need to know is the name of the currently selected
filehandle, then why not check the contents of the magic $ARGV
variable?
Otherwise, if you are going to iterate over the contents of @ARGV, why
not just put an explicit open() on a filehandle rather than saving
@ARGV, shoving each file individually on @ARGV, and using the "<>"
shortcut.
--
Andrew Langmead
------------------------------
Date: 31 Mar 1997 06:46:32 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Douglas Lewis <dalewis@cs.buffalo.edu>
Subject: Re: running a loop foreach $ARGV?
Message-Id: <8cu3lsfa2v.fsf@gadget.cscaper.com>
>>>>> "Douglas" == Douglas Lewis <dalewis@cs.buffalo.edu> writes:
Douglas> I would consider: (If you don't really care what info comes from
Douglas> what file
Douglas> while (<>)
Douglas> {
Douglas> # whatever
Douglas> }
Douglas> or the follwing (If you are interested in what file you are working on)
Douglas> my @PASSED_ARGV = @ARGV;
Douglas> foreach $FILE (@PASSED_ARGV)
Douglas> {
Douglas> @ARGV = ($FILE);
Douglas> while (<>)
Douglas> {
Douglas> # whatever
Douglas> }
Douglas> }
Or, even simpler simpler
while (<>) {
$the_file_I_am_working_on = $ARGV;
# whatever
}
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 519 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Mon, 31 Mar 1997 06:21:23 -0600
From: John Fleming <flemingj@interaccess.com>
To: Arthur Merar <amerar@unsu.com>
Subject: Re: Running CGI Scripts
Message-Id: <333FAC43.4C5D@interaccess.com>
<HTML><BODY>
Isn't it cmd=, not cgi=?
<BR>
<BR>Arthur Merar wrote:
<BLOCKQUOTE TYPE=CITE>Hello, I need some help. I am dealing with
my first CGI script. This
<BR>script simply prints out some GIF's on my homepage, but it is not
<BR>working.
<BR>
<BR>I am trying to get it working locally on my Linux drive first. When
I
<BR>enter the script name from the prompt, the script 'seems' to work.
It
<BR>displays the code from my HTML document on the screen.
<BR>
<BR>Next I put the command <!--#exec cgi="/root/www/cgi-bin/counter.cgi"-->
<BR>in my homepage, but nothing happens. No GIF's, no nothing.
<BR>
<BR>I am trying to figure out what I am doing wrong, if it is my setup or my
<BR>script or something. I thought someone with more CGI experience than
me
<BR>can could help me out.
<BR>
<BR>I appreciate any help.
<BR>
<BR>Thanks,
<BR>
<BR>Arthur
<BR>amerar@unsu.com
<BR><A HREF="http://www.unsu.com">http://www.unsu.com</A>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>
------------------------------
Date: Mon, 31 Mar 1997 10:50:28 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: scripts broken after 5.003 install
Message-Id: <333fde52.5640808@news.uni-stuttgart.de>
On 29 Mar 1997 22:34:36 GMT, keith@rucus.ru.ac.za (Keith Burdis )
wrote:
>Hi there
>
>Some of my perl scripts that worked fine under perl version 5.002
>don't seem to work now that I have installed version 5.003.
>
>Here's an example of a cgi script that now doesn't work :
>
> rucus:/var/www/server/cgi-bin/krb# perl -c -w krbdb-process.cgi
> Use of uninitialized value at /usr/local/lib/perl5/CGI.pm line 687.
> Can't load '/usr/local/lib/perl5/i386-freebsd/auto/Msql/Msql.so' for module Msql: Undefined symbol "_stack_base" in perl5:/usr/local/lib/perl5/i386-freebsd/auto/Msql/Msql.so at /usr/local/lib/perl5/DynaLoader.pm line 140.
>
> at /usr/local/lib/perl5/Msql.pm line 56
> BEGIN failed--compilation aborted at krbdb-process.cgi line 27.
> rucus:/var/www/server/cgi-bin/krb#
>
You must recompile all add on modules with the new perl binary,
although perl only modules such as CGI.pm require no alteration.
However this looks like u need to recompile Msql.pm
------------------------------
Date: Mon, 31 Mar 1997 10:50:30 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Selena Sol's BBS on NT?
Message-Id: <3340115d.2414016@news.uni-stuttgart.de>
On Sun, 30 Mar 1997 15:33:31 -0600, cwyatt@cris.com (Charles Wyatt)
wrote:
>Upon passing from the bbs_entrance.cgi to the bbs_forum.cgi scripts, I
>receive "document contains no data" from my browser, rather than the forum
>itself.
>
This usually means perl is dying with a syntax error try tunning perl
-c bbs_forum.cgi
------------------------------
Date: Mon, 31 Mar 1997 10:50:26 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: skipping around in file being read...
Message-Id: <333eccd5.1162388@news.uni-stuttgart.de>
On Sun, 30 Mar 1997 14:03:30 -0500, Brett Longworth
<blongwor@student.umass.edu> wrote:
>Hiya,
>
>Yet again, this seems like a FAQ, but I couldn't find it there or in the
>manual. How does one skip forwards or backwards in the file being
>read? for instance, what if I wanted to get something a few lines below
>a regex, or in this particular case, start a while loop on the next line
>after a match.
>
To skip forward a line just read one line in, to skip back u will have
to look at seek() and maybe tell(), using read() or sysread() to read
in one charecter and then seek to seek back 2 until u reach a \n
------------------------------
Date: Mon, 31 Mar 1997 17:45:34 +0900
From: "christop@ozinter.co.jp" <christop@ozinter.co.jp>
Subject: Re: Webfax scripts or mods in Perl?
Message-Id: <333F79AD.293F@ozinter.co.jp>
Or if tpc.int doesn't cover the areas you need check out faxaway.com;
email to fax gateway that lets you have faxback autoresponders that are
easy enough to access via perl.
shyde@POBoxes.com wrote:
>
> In article <333CAAE2.6C0@mkt2mkt.com>,
> annalisa <annalisa@mkt2mkt.com> wrote:
>
> >Does anyone know of any webfax scripts laying around?
> >
> >I'm investigating writing a program for an order form to be sent to a
> >fax rather than an email box.
> >
> >Then I thought..Gee maybe it's been done already.
> >
> >Care to share?
>
> You could just send an email to tpc.int (free email->fax gateway) take a
> look at www.tpc.int for more info
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 31 Mar 1997 12:13:00 GMT
From: Tim Bunce <Tim.Bunce@ig.co.uk>
Subject: Re: What is the limitation to use DBD::Oracle module?
Message-Id: <E7wpxp.Dtv@ig.co.uk>
In article <5gdp8g$pai$3@news.hkol.com>, Pao Wan <paowan@drdun.com> wrote:
> Is the Oracle module for perl only support a limited subset of Oracle SQL?
> Will it be wise to switch PL/SQL with Oracle Webserver?
DBD::Oracle uses Oracle's own interface (OCI) and has full use of SQL.
Here's a chunk of code demonstrating both PL/SQL and input/output variable:
$csr = $dbh->prepare(q{
declare bar varchar2(200);
begin
bar := :1;
bar := '**'||bar||'**';
:1 := bar;
end;
}) || die $DBI::errstr;
$param = "foo";
$csr->bind_param_inout(1, \$param, 100) || die $DBI::errstr;
$csr->execute || die $DBI::errstr;
print "param='$param'\n";
After the execute call $param will automatically hold the new value.
Tim.
------------------------------
Date: 30 Mar 1997 23:27:37 -0800
From: mconst@soda.CSUA.Berkeley.EDU (Michael Constant)
Subject: Re: Why is no subscripting allowed in custom sort routines?
Message-Id: <5hnp19$qc9@soda.CSUA.Berkeley.EDU>
Eric D. Friedman <friedman@medusa.acs.uci.edu> wrote:
> my $routine = sub { $a cmp $b };
> my @sorted_foo = sort &$routine @foo;
>
>My question: how can I write an anonymous sort subroutine that is NOT
>an in-line BLOCK?
Give your anonymous subroutine a name, for a while:
local *anonymous = $routine;
sort anonymous @foo;
See perlmod(1) under "Symbol Tables" for an explanation of what it
means to assign to a typeglob.
--
Michael Constant (mconst@soda.csua.berkeley.edu)
------------------------------
Date: Mon, 31 Mar 1997 12:40:07 GMT
From: vkoser@biggun.com (Vincent Koser)
Subject: win32 sendmail
Message-Id: <3340b0a5.118988218@news.gte.net>
I have many scripts from unix that I am openeing a file to sendmail
like so.
open(SENDMAIL, "|/usr/sbin/sendmail $email")|| die "Can't use
sendmail!\n";
is there a way to accomplish this functionality in win32? I guess if
there were an smtp mail module or something that would do it.
any help is greatly appreciated.
thanks, please cc email on reply if you can.
vince
------------------------------
Date: Mon, 31 Mar 1997 07:46:15 -0600
From: Glauber Ribeiro <glauber@iws-irms.com>
To: Vincent Koser <vkoser@biggun.com>
Subject: Re: win32 sendmail
Message-Id: <333FC027.5B14@iws-irms.com>
Vincent Koser wrote:
>
> I have many scripts from unix that I am openeing a file to sendmail
> like so.
>
> open(SENDMAIL, "|/usr/sbin/sendmail $email")|| die "Can't use
> sendmail!\n";
>
> is there a way to accomplish this functionality in win32? I guess if
> there were an smtp mail module or something that would do it.
>
> any help is greatly appreciated.
> thanks, please cc email on reply if you can.
> vince
There is a sendmail port for NT in the Microsoft site, but if you'd
rather not have to deal with full-fledged sendmail configuration, get
Blat. It will email a text file through a SMTP gateway with a minimum of
trouble. I use it under NT, it's reported to work with W95 as well.
http://gepasi.dbs.aber.ac.uk/softw/blat.html
Glauber
--
Glauber Ribeiro -- Integrated Warehousing Solutions
mailto:glauber@iws-irms.com http://www.iws-irms.com
------------------------------
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 207
*************************************