[11853] in Perl-Users-Digest
Perl-Users Digest, Issue: 5453 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 22 13:07:37 1999
Date: Thu, 22 Apr 99 10:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 22 Apr 1999 Volume: 8 Number: 5453
Today's topics:
.JPG version of GD? <dont.spam@me.org>
Re: CGI programmer wanted <uri@sysarch.com>
cheap perl scripts pejman@pejman.com
Re: cookies & perl <cassell@mail.cor.epa.gov>
Re: Database Converter (Larry Rosler)
Re: FAQ 4.9: Why aren't my random numbers random? <cassell@mail.cor.epa.gov>
Re: grep look a like (Larry Rosler)
Re: grep look a like <Michael.Cameron@no.spam.technologist.com>
Re: HELP: opening files in perl and streaming them to w (Larry Rosler)
Re: How to join (David H. Adler)
Re: HTTP_REFERRER (Juho Cederstrom)
Illegal seek (this makes no sense to me =) phukit@enteract.com
Re: Is there a shorter way? (Clinton Pierce)
Re: Is there a shorter way? <jdf@pobox.com>
Re: Is there a shorter way? <jklein@alerts.co.il>
Re: Is there a shorter way? (Bart Lateur)
Re: Need to parse exported table from access <cassell@mail.cor.epa.gov>
newbie with a "howto" question derose@my-dejanews.com
Re: Perl notation question? <cassell@mail.cor.epa.gov>
Re: Reading C binary data from disk <Michael.Cameron@no.spam.technologist.com>
Re: Reading C binary data from disk (Larry Rosler)
Re: Reading C binary data from disk <jdf@pobox.com>
Re: Reading C binary data from disk <tchrist@mox.perl.com>
Re: reset $. in one-liner <jdf@pobox.com>
Re: reset $. in one-liner (M.J.T. Guy)
Re: Telnet problems <Michael.Cameron@no.spam.technologist.com>
Where can I get a CGI modul <sergue@ica.net>
Re: Why can't the script find the Perl binaries?. <jeromeo@atrieva.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 22 Apr 1999 16:42:13 +0100
From: ChrisG <dont.spam@me.org>
Subject: .JPG version of GD?
Message-Id: <371F4355.5ED7@me.org>
Sorry if this is a dumb question, but ..
Is there a Perl library out there for working with .JPGs on a NT
platform like GD does GIF?
We have a web site where people upload photographs and we want to
automate creation of thumbnails and watermarks. I have found lots of
stuff for X-Windows, but no help with NT ...
--
HTTP://CHRISG.COM/ :O)
------------------------------
Date: 22 Apr 1999 12:49:23 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: CGI programmer wanted
Message-Id: <x7hfq8d2i4.fsf@home.sysarch.com>
>>>>> "TM" == Tad McClellan <tadmc@metronet.com> writes:
TM> Uri Guttman (uri@sysarch.com) wrote:
TM> : i'd rather have a bottle in front of me than a frontal lobotomy!
TM> Was that Groucho Marx or W. C. Fields?
i doubt either created it nor said it. IMO it doesn't match their
styles.
i think this may have been created by that prolific author, anon.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 22 Apr 1999 15:31:37 GMT
From: pejman@pejman.com
Subject: cheap perl scripts
Message-Id: <372f40c2.3349313@nntp.best.com>
Hi,
I am looking for somebody, who can write me some small perl scripts
for small amount of money. Please let me know if you are interested
or if you know somebody who is willing to do that.
(please reply to my email-address)
Thanks in advance,
Pejman
------------------------------
Date: Thu, 22 Apr 1999 09:48:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: cookies & perl
Message-Id: <371F52D3.8CDEBEFE@mail.cor.epa.gov>
Abigail wrote:
>
> David Cassell (cassell@mail.cor.epa.gov) wrote on MMLIX September
> MCMXCIII in <URL:news:371E5BBB.65BD42AB@mail.cor.epa.gov>:
> "" Lars Plessmann wrote:
> "" >
> "" > is it possible to read the cookies of a browser by perl?
> "" > if so, how can I do that? (larsplessmann@gmx.de)
> ""
> "" That said, you might be interested to know that the CGI.pm
> "" module will do this and a lot of other nice stuff for you.
> "" So will several other modules, all of which are available
> "" at CPAN.
>
> Oh really? I've my browser here, and I know it got a cookie. How do
> I use CGI.pm to read that cookie? I thought CGI was for the _server_
> side, not the client?
I took a guess about which side he was using. Can I weasel out of
this by pointing out that one of those "several other modules"
I mentioned might help on the client side? :-)
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Thu, 22 Apr 1999 08:25:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Database Converter
Message-Id: <MPG.1188df5383d95e5c98990f@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <uCFT2.2426$94.1029054@news1.usit.net> on Thu, 22 Apr 1999
13:37:30 GMT, JJ <webdude@mcminn.net> says...
> Got it with regular expressions
> $field[0] =~ s/\^DJI/Dow Jones/;
> utilizing the substiution operator
You'll do better in the long run using a hash lookup.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Apr 1999 09:34:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: FAQ 4.9: Why aren't my random numbers random?
Message-Id: <371F4F97.10A24057@mail.cor.epa.gov>
Andrew Allen wrote:
>
> Just a nit:
>
> David Cassell (cassell@mail.cor.epa.gov) wrote:
> <snip>
>
> : print "Uh oh! Looks like your computer uses the ANSI example.\n"
>
> need a semi-colon at the end there. ^
>
> Andrew
That doesn't look like a nit to me. It looks like something worth
flagging. Thanks. And I thought I was doing well by getting that
incorrect `}' in the journal out of there. Oops.
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Thu, 22 Apr 1999 08:01:27 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: grep look a like
Message-Id: <MPG.1188d9a17e714add98990e@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7fn0ha$746@morgana.mat.uc.pt> on 22 Apr 1999 11:18:02 GMT,
Jorge A. Tavares <jast@student.dei.uc.pt> says...
...
> The problem is that grep searchs for a match in
> the entire string and that's gives me a small bug ! If i have a friend which
> the login is "elio" and there is another person called "delio" , whenever
> "delio" is connected and "elio" not, it will give me "delio" and I don't
> want it ! And of course, when the two are connected, it gives me the two !
...
> @result = grep( /$friend/x, @fing);
...
> If anybody could help I would be very gratefull.
> Please, answers to my e-mail address.
No problem, because your address looks unmunged.
Look in the document perlre for the '\b' word-boundary assertion.
@result = grep( /\b$friend\b/x, @fing);
The '/x' in your regex is harmless but unnecessary in this case.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Apr 1999 15:21:57 +0000
From: Michael Cameron <Michael.Cameron@no.spam.technologist.com>
To: "Jorge A. Tavares" <jast@student.dei.uc.pt>
Subject: Re: grep look a like
Message-Id: <371F3E94.31E80B44@no.spam.technologist.com>
"Jorge A. Tavares" wrote:
>
> @result = grep( /$friend/x, @fing);
Without getting into rewriting your code you can anchor the pattern you are
searching for to the start of a line using the caret (^) symbol or include other
text to anchor it elsewhere.
eg
@result = grep( /^$friend/x, @fing); # matches if $field is at the
start of the line
@result = grep( /^login: $friend/x, @fing); # matches if $field follows the
string "login:" at the start of the line
Learning regular expressions is a good idea.
HTH,
Michael
------------------------------
Date: Thu, 22 Apr 1999 08:59:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HELP: opening files in perl and streaming them to web pages
Message-Id: <MPG.1188e755497b1730989910@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7fnang$fht$1@nnrp1.dejanews.com> on Thu, 22 Apr 1999
14:12:04 GMT, Matt Evans <stats123@my-dejanews.com> says...
...
> this seems to work but if I change the file to open from a text file to a jpg
> say, and I change the Content-type to image/jpeg te whole thing stops working.
Use binmode() on both the input file and on STDOUT. Use read() to read
the file, not <>.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Apr 1999 11:58:14 -0400
From: dha@panix.com (David H. Adler)
Subject: Re: How to join
Message-Id: <slrn7huhok.d72.dha@panix.com>
On Wed, 21 Apr 1999 18:23:51 -0400, Jay Glascoe <jglascoe@giss.nasa.gov> wrote:
>This is how we join, say, NY Perl Mongers:
>
>echo 'subscribe ny' | mail majordomo@lists.pm.org
Ah, we *do* have them trained well here, don't we? :-)
Btw - meeting tonight (thurs, apr 22). See
<http://ny.pm.org/events.html>.
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
perl -e '$_ = (join "", (map (chr, (shift =~ /.../g))));print "$_\n"
;' 106117115116032097032110121032112101114108032104097099107101114
------------------------------
Date: Wed, 21 Apr 1999 18:47:46 +0300
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho Cederstrom)
Subject: Re: HTTP_REFERRER
Message-Id: <slrn7hrsp2.259.cederstrom@vortex.cede.net>
On 20 Apr 1999 21:22:22 -0000,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
Goes offtopic: Why can't I get a tilde out of my keyboard...
> What ? I havent the faintest idea what a keyboard in your neck of the woods
> looks like but how can do Perl, Unix Shell, vi, Spanish without one ...
Well, the problem isn't my keyboard (the Finnish one), it's my editor. You
just can't imagine how terrified I was when I found out that CoolEdit doesn't
support it!!!
Well, now I've deleted CoolEdit. Maybe kedit works better. And yes, tilde
works now just fine.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=)
--
# This is a Perl-script which will display juhoc's email address
$_ = "ohuj s'ciameda lserdsi sdec tsreAmorlokTubmuTODsfi";
s/(.)(.)(.)(.)/$4$3$2$1/g;s/AT/\@/;s/DOT/\./;print $_."\n";
------------------------------
Date: 22 Apr 1999 16:02:20 GMT
From: phukit@enteract.com
Subject: Illegal seek (this makes no sense to me =)
Message-Id: <7fnh6c$h2o$1@eve.enteract.com>
Ok, I'm completely stumped on this one. All I'm trying to do is have
part of my script open sendmail, pipe some mail through and then close
sendmail.
I've done this many many times before, but for some reason this time,
it's not working and I've got no idea on earth why.
Here's the relevant portion of the code:
&ddebug("DEBUG 2 $!\n");
open SENDMAIL, "|/usr/sbin/sendmail my\@email.address";
&ddebug("DEBUG 3 $!\n");
foreach $each (@{$message_headers}) {
print SENDMAIL $each;
}
print SENDMAIL "\n";
foreach $each (@{$message_body}) {
print SENDMAIL $each;
}
close(SENDMAIL);
Between DEBUG 2 and 3, an Illegal seek error shows up in $!. I've been
working on this work some time and can't find anything on dejanews.
Can anyone please shed some light on this? I'm totally baffled.
------------------------------
Date: Thu, 22 Apr 1999 14:35:41 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Is there a shorter way?
Message-Id: <372a3131.1901559117@news.ford.com>
[poster cc'd in e-mail]
On Thu, 22 Apr 1999 09:22:23 GMT, pingouino@my-dejanews.com wrote:
>Some friends of mine at work accidentally got into a little "challenge";
>we implemented the same piece of code in different ways, then started
>seeing who could do it in fewest characters. The task was to print out
>an environment variable (in this case, USER) padded out to a minimum of
>six characters with "x", or not modified if it was six characters or more.
>
>So, "foo" becomes "fooxxx", "foos" becomes "foosxx", "foobar" remains
>"foobar" and "foobars" remains "foobars" (note how the 7-letter word is
>not truncated).
>
>The best we came up with (with all unnnecessary spaces removed) was:
>
>perl -e'$_=$ENV{USER};print$_."x"x(6-split//)'
>
>Note how we are relying on USER being treated as a bareword and also
>"split" defaulting to $_ and returning an array to be evaluated in
>scalar context to mimic "length".
Why? Because:
(6-split//)
is longer than
(6-length)
by a character, and both behave the same here. AFAIK. Since warnings
were not turned on (perl would have complained about the implicit split
into @_ in your example) you could have dropped the double quotes and
done:
print$_.x x(6-length)
Although that looks hairy.
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: 22 Apr 1999 11:16:54 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: pingouino@my-dejanews.com
Subject: Re: Is there a shorter way?
Message-Id: <m3yajkn0rd.fsf@joshua.panix.com>
pingouino@my-dejanews.com writes:
> perl -e'$_=$ENV{USER};print$_."x"x(6-split//)'
>
> Note how we are relying on USER being treated as a bareword
That's not exactly a "bareword", in that a single word within curlies
is a string, per the docs.
> and also "split" defaulting to $_ and returning an array to be
> evaluated in scalar context to mimic "length".
Why not just use length, saving you a character (and being much
faster, as if that mattered)?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Thu, 22 Apr 1999 19:03:34 +0300
From: Yossi Klein <jklein@alerts.co.il>
Subject: Re: Is there a shorter way?
Message-Id: <Pine.SO4.4.10.9904221901560.5704-100000@cain.alerts.co.il>
Personally, I'd go with:
print$_.x x(6-+y///c);
It's just as short as using length and MUCH more fun:-)
Yossi
On 22 Apr 1999, Jonathan Feinberg wrote:
> pingouino@my-dejanews.com writes:
>
> > perl -e'$_=$ENV{USER};print$_."x"x(6-split//)'
> >
> > Note how we are relying on USER being treated as a bareword
>
> That's not exactly a "bareword", in that a single word within curlies
> is a string, per the docs.
>
> > and also "split" defaulting to $_ and returning an array to be
> > evaluated in scalar context to mimic "length".
>
> Why not just use length, saving you a character (and being much
> faster, as if that mattered)?
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
> http://pobox.com/~jdf
>
>
------------------------------
Date: Thu, 22 Apr 1999 16:22:43 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Is there a shorter way?
Message-Id: <37214c38.8458065@news.skynet.be>
pingouino@my-dejanews.com wrote:
>The best we came up with (with all unnnecessary spaces removed) was:
>
>perl -e'$_=$ENV{USER};print$_."x"x(6-split//)'
perl -e "print $_=$ENV{USER},'x'x(6-length)"
Bart.
------------------------------
Date: Thu, 22 Apr 1999 09:30:24 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Need to parse exported table from access
Message-Id: <371F4EA0.A23B78@mail.cor.epa.gov>
Pamela Goldfarb wrote:
>
> I am storing an exported access table on my web server. It is an ascii file
> with comma delimited fields and with strings enclosed with "".
Ah. Standard CSV - comma-separated values.
> The strings can contain commas, quotation marks, and new-lines. There can
> also be blank fields.
>
> Example (each data record, has three fields: a numeric, followed by a
> string, followed by a numeric)
>
> 123, "abc", 456,
> 124, "first word then
> newline", 888,
> 125, "first word ""quoted"" end
> ,,,", 999
>
> I want to create a perl script that can parse this data into an array of
> fields that can then be searched, processed, etc. and the outputted to a
> html file.
>
> I am having trouble constucting the appropriate parsing code. In particular
> the fact that there may be multiple lines in the datafile that make a whole
> data line.
Go to CPAN and get the Text::CSV module, which should do what you want.
http://www.perl.com/CPAN/
should get you to the archive of huge numbers of useful Perl modules.
And you may be interested in reading section 6 of the FAQ, on regular
expressions. It has several answers that relate to your problem,
including:
"I'm having trouble matching over more than one line. What's wrong?"
Can I use Perl regular expressions to match balanced text?
> Since this is MS Access outputted data, I would think that perl code to do
> what I want already exists, can someone
> point me to where I can find such code?
Actually, Perl [and many Perlites] tend to be unix-centric, rather
than Bill-centric. But CSV is common enough that there are now
tools for coping with it.
You may also want to look into Perl's ODBC features, since you're
on a WinTel system. And Perl's DBI which lets you have a uniform
interface to a wide variety of databases.. including MS Access.
HTH,
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Thu, 22 Apr 1999 15:31:01 GMT
From: derose@my-dejanews.com
Subject: newbie with a "howto" question
Message-Id: <7fnfbl$jpj$1@nnrp1.dejanews.com>
Hello,
I'm new at Perl, and don't really have the patience's to find the answers in
my books, so I thought I would ask some experts.
I have two questions really
1. Is there a comparable command or module to unix's uniq? I want to sort and
uniq a simple text file. I've figured out how to sort it in Perl, but not how
to uniq it. If I were to do this in shell I would say something like:
cat $file1 | sort | uniq > $outfile
2. Is there a module or function that will parse a line in a text file? I
have a file with four individual columns, and I want to read each line on at
a time and have each word placed in an individual variable. If I were to do
this in shell, I would have used awk to parse the lines.
If any one could point me in the correct direction, I would appreciate it.
Thank you,
Daryl
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Apr 1999 09:56:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl notation question?
Message-Id: <371F54B3.CFF829B9@mail.cor.epa.gov>
Rick Delaney wrote:
>
> [posted & mailed]
>
> David Cassell wrote:
> >
> > Perhaps the answer is:
> > TIMTOWTSI - There Is More Than One Way To Spell It.
>
> Probably.
>
> > I prefer TIMTOWTDI, since the docs say it is supposed to be pronounced
> > 'tim-toady'.
>
> perldoc perl
>
> The Perl motto is "There's more than one way to do it."
But surely, in this NG full of linguistic pedants, we have to allow
for the case where someone prefers not to use the contraction.
What would Dr. Johnson say? :-)
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Thu, 22 Apr 1999 15:06:36 +0000
From: Michael Cameron <Michael.Cameron@no.spam.technologist.com>
To: Nigel Simon <armchair@my-dejanews.com>
Subject: Re: Reading C binary data from disk
Message-Id: <371F3AFC.43C0C5FE@no.spam.technologist.com>
Nigel Simon wrote:
> Is it possible to write out a C double (or int) using fwrite() and then open
> that file and read the double value into a Perl scalar type - using just Perl
> code??
> --
> Nigel
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
I think you want pack/unpack.
perldoc -f unpack
perldoc -f pack
How you use it will depend on your platform.
HTH
Michael
------------------------------
Date: Thu, 22 Apr 1999 07:54:49 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reading C binary data from disk
Message-Id: <MPG.1188d8148ed7ae2498990d@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7fmtjs$3oe$1@nnrp1.dejanews.com> on Thu, 22 Apr 1999
10:28:15 GMT, Nigel Simon <armchair@my-dejanews.com> says...
> Is it possible to write out a C double (or int) using fwrite() and then open
> that file and read the double value into a Perl scalar type - using just Perl
> code??
Certainly.
perldoc -f unpack (for the decoding function itself)
perldoc -f pack (for the format definitions)
Don't forget to 'binmode()' the file after opening it and before reading
it. Just in case...
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Apr 1999 11:17:57 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: Nigel Simon <armchair@my-dejanews.com>
Subject: Re: Reading C binary data from disk
Message-Id: <m3vheon0pm.fsf@joshua.panix.com>
Nigel Simon <armchair@my-dejanews.com> writes:
> Is it possible to write out a C double (or int) using fwrite() and then open
> that file and read the double value into a Perl scalar type - using just Perl
> code??
perldoc -f unpack
perldoc -f pack
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 22 Apr 1999 09:39:50 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Reading C binary data from disk
Message-Id: <371f42c6@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
:Don't forget to 'binmode()' the file after opening it and before reading
:it. Just in case...
Just in case, that is, you should be confined to an infernal system with
an ancient design flaw, a flaw continually revisited unto the children
of the tenth generation of those who first sold themselves into servitude
and bondage.
http://www.io.com/~mccoy/beginning_print.html
--tom
--
f u cn rd ths, itn tyg h myxbl cd.
------------------------------
Date: 22 Apr 1999 11:25:14 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: richard_chen@my-dejanews.com
Subject: Re: reset $. in one-liner
Message-Id: <m3so9sn0dh.fsf@joshua.panix.com>
richard_chen@my-dejanews.com writes:
> How can one reset $. in such a one liner? I know that
> one can use eof in an elaborate while ... continue ... loop.
> But that make the one liner much too complicated.
The only way to reset $. is to close the magical filehandle ARGV. As
for making the one-liner much to complicated... one-liners are for
simple tasks! But it can be done, using the trick that Abigail so
often exploits...
perl -lne 'print $. } continue {close ARGV if eof'
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 22 Apr 1999 16:51:40 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: reset $. in one-liner
Message-Id: <7fnk2s$qk$1@pegasus.csx.cam.ac.uk>
In article <7fn9ql$ei0$1@nnrp1.dejanews.com>,
<richard_chen@my-dejanews.com> wrote:
>I would like to insert a line at the beginning of
>many files. The following will not work
>
>$ perl -pi -e 's|(.*)|#!/usr/bin/perl\n$1| if $.==1' *.pl
>
>because $. does not get reset after the first file.
perl -pi -e 's|(.*)|#!/usr/bin/perl\n$1| if $.==1;close ARGV if eof' *.pl
See "perldoc -f eof".
Mike Guy
------------------------------
Date: Thu, 22 Apr 1999 15:11:24 +0000
From: Michael Cameron <Michael.Cameron@no.spam.technologist.com>
To: scott@sboss.net
Subject: Re: Telnet problems
Message-Id: <371F3C19.DA0F1A30@no.spam.technologist.com>
scott@sboss.net wrote:
>
> From the same machine I am executing the script I can telnet to all the
> machines and login without a problem. Any suggestions?
You do not mention what machine you are using. I used the expect module on
Solaris and had to change some of the values in the perl headers, unfortunately
that was some time ago and I no longer ave access to the system in question.
You might find that you need to tweak a few things for Net:telnet too. Failing
that you could always implement the same thing using the expect module to drive
a telnet.
HTH,
Michael
------------------------------
Date: Thu, 22 Apr 1999 12:28:55 -0700
From: serguei <sergue@ica.net>
Subject: Where can I get a CGI modul
Message-Id: <371F7877.4004CD10@ica.net>
Hi, everybody.
Can somebody tell me where can I get a modul CGI.pm .
What a directory will I have to use to install it?
Thanks in advance
Serguei
------------------------------
Date: Thu, 22 Apr 1999 09:21:44 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
To: "WF, Yee" <softcomp@home.com>
Subject: Re: Why can't the script find the Perl binaries?.
Message-Id: <371F4C98.521ED0E2@atrieva.com>
WF, Yee wrote:
> I have "#!/usr/bin/perl" as the first line of my
> script but yet when I tried to execute it, I get
> "No such file or directory". When I did "perl mytest" (name
> of script is mytest), the script worked fine.
I think it's 'mytest' that can't be found. Try
./mytest
and see what happens. Adjust your path accordingly.
Good Luck!
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
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 5453
**************************************