[17784] in Perl-Users-Digest
Perl-Users Digest, Issue: 5204 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 27 03:05:31 2000
Date: Wed, 27 Dec 2000 00:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977904312-v9-i5204@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 27 Dec 2000 Volume: 9 Number: 5204
Today's topics:
Re: =~ operator (Andrew N. McGuire)
ANNOUNCE: Mail::IMAPClient v2.0.5 <David.Kernen@bms.com>
Re: converting code to mod perl (should I use globals?) <joe+usenet@sunstarsys.com>
Re: converting code to mod perl (should I use globals?) (Tim Hammerquist)
Re: declaring variables <bwalton@rochester.rr.com>
Re: declaring variables (Tim Hammerquist)
Re: FAQ 6.21: What's wrong with using grep or map in (Tim Hammerquist)
Re: FAQ 6.21: What's wrong with using grep or map in (Abigail)
Re: Help with searching flat files & CGI <jhelman@wsb.com>
Re: Help with searching flat files & CGI <jhelman@wsb.com>
How to delete items from an array? georgebailey@my-deja.com
Re: How to delete items from an array? <wescott@conterra.com>
Re: How to delete items from an array? (Tad McClellan)
Re: How to delete items from an array? (Abigail)
Re: How to delete items from an array? <uri@sysarch.com>
How to have three dimentional array shwekhaw@my-deja.com
Re: Is there an overhead using long variable names? (Andrew N. McGuire)
Re: my cgi scripts starts a download? urgent help neede <dwebb@cvalley.net>
Re: Parsing (Andrew N. McGuire)
regex question: putting back references in another vari <michael@datahost.com>
Re: regex question: putting back references in another (Rafael Garcia-Suarez)
want to fetch html files without LWP hongdou@my-deja.com
Re: want to fetch html files without LWP (Chris Fedde)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Dec 2000 00:34:35 -0600
From: anmcguire@ce.mediaone.net (Andrew N. McGuire)
Subject: Re: =~ operator
Message-Id: <86k88me5j8.fsf@hawk.ce.mediaone.net>
>>>>> "MC" == Michael Carman <mjcarman@home.com> writes:
MC> Martin Schmidt wrote:
>>
>> What is the =~ operator called?
>> I'm reading 'Learning Perl' and they just call it the
>> =~ operator.
MC> I generally refer to it as the 'binding' operator, as it binds an
MC> variable to a regexp.
being a bit pedantic, but:
s/regexp/pattern/;
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Tue, 26 Dec 2000 16:08:57 -0500
From: Dave <David.Kernen@bms.com>
Subject: ANNOUNCE: Mail::IMAPClient v2.0.5
Message-Id: <t4ip8h3if0qp08@corp.supernews.com>
Happy Holidays everybody. I'm pleased to announce version 2.0.5 of
Mail::IMAPClient, which provides perl routines that simplify a sockets
connection to and an IMAP conversation with an IMAP server.
This release fixes a number of bugs. It is also reported to work on a
couple of new platforms, among them Exchange and Cyrus IMAP. (Okay,
these platforms aren't new; reports of successfully using
Mail::IMAPClient on these platforms is the new part.)
If you haven't upgraded Mail::IMAPClient lately, now would be a good
time. This module has changed rather dramatically since the version 1.x
days!
Changes in version 2.0.5:
Fixed bug in parse_headers so that RFC822 headers now match the pattern
/(\S*):\s*/
instead of /(\S*): /. Thanks go to Paul Warren for reporting this bug
and providing the
fix.
Added more robust error checking to prevent infinite loops during read
attempts and
fixed bugs in parse_headers. Thanks go to Phil Lobbes, who provided
several useful patches
and who performed valuable pre-release testing.
Fixed bug in parse_headers when connected to an Exchange server with
UID=>1. (Kudos to
Wilber Pol for that fix.)
Fixed bugs in parse_headers and tightened reliability of I/O engine by
implementing
many improvements suggested by Phil Lobbes, who also provided code for
same.
Added bugfix that under certain conditions caused server responses to be
"repeated"
when fast_io is turned on. Thanks to Jason Hellman for providing bug
report and
diagnostic data to fix this.
Added a "LastIMAPCommand" method, which returns the last IMAP client
command that was sent
to the server.
Removed the "=begin debugging" paragraph that somehow got included in
CPAN's
html pages (even though it shouldn't have).
Tested successfully against Cyrus v 2.0.7.
Tested unsuccessfully against mdaemon. This appears to be due to
mdaemon's
noncompliance with rfc2060 so future support for mdaemon should not be
expected
any time soon.
Good luck and happy New Year!
David Kernen
The Kernen Group, Inc.
------------------------------
Date: 26 Dec 2000 21:17:12 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: converting code to mod perl (should I use globals?)
Message-Id: <m3ae9ibobb.fsf@mumonkan.sunstarsys.com>
tim@degree.ath.cx (Tim Hammerquist) writes:
> The following is valid:
>
> : sub func1 {
> : my $a = 7;
> : # stuff
> : sub func2 {
> : $a++;
> : }
> : func2();
> : }
>
> And all of this code should compile under mod_perl.
But it *will* produce a warning, and it probably won't
work the way you expect. See
http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S
for a lucid discussion of the issue.
HTH.
--
Joe Schaefer
------------------------------
Date: Wed, 27 Dec 2000 02:34:43 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: converting code to mod perl (should I use globals?)
Message-Id: <slrn94ilee.9cd.tim@degree.ath.cx>
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> But it *will* produce a warning, and it probably won't
> work the way you expect. See
>
> http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S
>
> for a lucid discussion of the issue.
Thank you for pointing that out. I'd overlooked the closure
possibility.
ATTN: The article demonstrates the potential problems with nested subs as well
as and _solutions_, so anyone reading this thread should not assume that
you can't nest subs under mod_perl.
--
-Tim Hammerquist <timmy@cpan.org>
God made the Idiot for practice, and then He made the School Board.
-- Mark Twain
------------------------------
Date: Wed, 27 Dec 2000 02:12:23 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: declaring variables
Message-Id: <3A495122.190C2383@rochester.rr.com>
John Michael wrote:
>
> I am using this input routine to pull variables into a script at runtime.
> It gives me the opportunity to add variables into the script at runtime
> without changing the script.
>
> sub assign_values {
> my @array = @_;
> my ($name,$value);
>
> foreach (@array) {
> chomp;
> ($name, $value) = split(/=/);
> $$name = $value;
> push (@vars,$name);
> }}
>
> If I want to run the script with
> use strict;
> How can I declare those variables so that they do not cause an error or do I
> even have to?
...
> --
> John Michael
The purpose of use strict; is to flag attempts to write crap like that.
Why is it crap? Consider what will happen to your program if your input
array contains the name of a variable you otherwise use, or maybe a
Perl-defined variable, or maybe a string that is not legal for a
variable name. What should you do instead? Use a hash -- that's what
hashes were made for. Like, for example, $hash{name}=$value; instead of
$$name=$value;. Using a hash is like having your own private variable
name space, which you can use as you please without cruding up the
package symbol table.
--
Bob Walton
------------------------------
Date: Wed, 27 Dec 2000 02:39:32 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: declaring variables
Message-Id: <slrn94ilnf.9cd.tim@degree.ath.cx>
John Michael <johnm@acadiacom.net> wrote:
> If I want to run the script with use strict;
> How can I declare those variables so that they do not cause an error
> or do I even have to?
You're using symbolic references, which is one of the things that 'use
strict' specifically prohibits. You can tell the strict pragma to let
you use symbolic refs and otherwise be strict, but sym refs are
rarely a good idea and can almost always be avoided.
--
-Tim Hammerquist <timmy@cpan.org>
The little I know I owe to my ignorance.
-- Sacha Guitry
------------------------------
Date: Wed, 27 Dec 2000 02:05:31 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: FAQ 6.21: What's wrong with using grep or map in a void context?
Message-Id: <slrn94ijnl.9cd.tim@degree.ath.cx>
John Lin <johnlin@chttl.com.tw> wrote:
> Hey, map and grep, you can save the trouble of building up a return list
> when (not defined wantarray), right? Don't blame the programmers.
Um, you can just use a for loop instead of map. Then you don't waste
the return list. The chances that the implementation of grep() and
map() will be changed are very slim with a construct so similar and
frequently used already in existence.
--
-Tim Hammerquist <timmy@cpan.org>
A child of five would understand this.
Send someone to fetch a child of five.
-- Groucho Marx
------------------------------
Date: 27 Dec 2000 02:47:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: FAQ 6.21: What's wrong with using grep or map in a void context?
Message-Id: <slrn94im24.mi8.abigail@tsathoggua.rlyeh.net>
Tim Hammerquist (tim@degree.ath.cx) wrote on MMDCLXXV September MCMXCIII
in <URL:news:slrn94ijnl.9cd.tim@degree.ath.cx>:
?? John Lin <johnlin@chttl.com.tw> wrote:
?? > Hey, map and grep, you can save the trouble of building up a return list
?? > when (not defined wantarray), right? Don't blame the programmers.
??
?? Um, you can just use a for loop instead of map. Then you don't waste
?? the return list. The chances that the implementation of grep() and
?? map() will be changed are very slim with a construct so similar and
?? frequently used already in existence.
Because one way of doing it in favour of another is all in the
spirit of Perl, right?
Besides, who needs both for, while, until, map, grep and bare blocks
when you can just use goto. Then you don't waste anything!
(when not using the loop variable, for should be shunned as well, it's
such a waste assigning a variable AT EACH ITERATION, and not doing
anything with it - not a good way to treat a language)
The fact that map in void context is inefficient is a bug in perl, the
implementation. Not the language. Cure the disease, don't ridicule
someone for the symptoms.
Abigail
------------------------------
Date: Wed, 27 Dec 2000 03:23:38 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Help with searching flat files & CGI
Message-Id: <3A4960D8.C18B61FB@wsb.com>
wendywds@my-deja.com wrote:
> I've swiped a webmonkey script that searches a text file, but I can
> only get it to work if the text file is in the same directory as
> the .cgi file.
>
> open (DATA, "movies.dat");
> my @data = <DATA>;
> close (DATA);
Have you tried using the full path to your file? In your example, try:
open (DATA, "/wendywds.tripod.com/photos/20000117DennyEmerson.dat");
> This is probably more Unix than Perl, but how do I get it to open a
> file that's in a different directory?
You specify the directory. Perl will find your file, even if you are
using relative paths, like "../../photos/20000117DennyEmerson.dat" or
whatever.
> I have to get it to back up one
> level, then go down a different path. If I put in a path, it expects
> to find it underneath cgi-bin where the script lives. I think.
Then make sure that your relative paths are still pointing to the proper
directory. On a virtual host like tripod, relative paths are probably
better than absolute paths anyway since tripod may decide, on a whim, to
completely restructure the directory tree, thus rendering you absolue
paths moot. (BTW, what's with the double forward slash at the front of
your paths in your post? Unix boxes won't like that and Win32 boxes
will interpret that as a UNC name (Unix boxen may, too). Only one slash
is needed.)
> I also have Matthew Wright's 'Simple Search' which currently searches
> the *.html files.
Danger, Will Robinson! Matt Wright's scripts are generally regarded as
somewhat below fecal matter among the denizens of this here newsgroup
(myself included). Even mentioning them might get you placed in
killfiles around the world. Even as a newbie, you could probably whip
up something better if you read the documentation provided. Seriously.
> I think I can swipe the section that gathers up all
> the html files and make it find the .dat files. Between both of these
> scripts, I think I can get this to work eventually.
>
> And once it does work, I should be able to build the page of links
> using 1) My "domain" at tripod, plus /photos/ 2) the filename of
> the .dat file (as the subdirectory) 2) the individual lines within that
> file that had a match, the first part of that line being the filename.
Post some code that isn't working and let us find the problem. Given
what you've told us (especially with the double-slash thing mentioned
above), there could be any number of problems with your script.
> if ($data[$i] =~ /-- $movie{'title'} --/i)
> The webmonkey script is looking for an exact title within --
> separators. I want to find the word or phrase they entered anywhere on
> the line. Obviously I need to go brush up on regular expressions.
This is syntactically correct (assuming you are looking for a value
padded by two dashes on the outside and a space on the inside). The
question is, what are you doing with this data. Again, post the full
code since your bug may well be lurking inside.
> My first Perl/CGI project. Perhaps it's a bit ambitious...
Not really. This seems fairly simple. The problem is probably
something trivial (this spoken by someone who spent better than an hour
today hunting down a bug today that I could should shoot myself for. :)
)
> I have the O'Reilly Perl CD Bookshelf coming... hopefully it will
> arrive today. If what I'm asking is in there, just say so and I'll sit
> on my hands until it gets here. (Impatient? Me?)
The solution you seek is probably documented within said books. The
problem is we don't know where since there isn't much code in your post
(hint, hint.)
JH
------------------------------
Date: Wed, 27 Dec 2000 03:29:40 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Help with searching flat files & CGI
Message-Id: <3A496242.E1C9F9DE@wsb.com>
Sorry, it's been a long day and I'm tired. Thus I missed an obvious
check...
Jeff Helman wrote:
>
> wendywds@my-deja.com wrote:
>
> > I've swiped a webmonkey script that searches a text file, but I can
> > only get it to work if the text file is in the same directory as
> > the .cgi file.
> >
> > open (DATA, "movies.dat");
> > my @data = <DATA>;
> > close (DATA);
>
> Have you tried using the full path to your file? In your example, try:
>
> open (DATA, "/wendywds.tripod.com/photos/20000117DennyEmerson.dat");
Are you checking the return value of your call to open()? Something
like...
open (DATA, "/somedir/somefile.dat") or die("Failed to open file because
$!");
If the open() fails, it will return the specific problem it had in $!.
Granted, you are using an account which may not necessarily have access
to this information, but if you are starting your script with:
use CGI::Carp 'fatalsToBrowser';
Then the requisite error messages will be displayed in your browser when
you access the script. Chances are it is a directory problem, but you
never know.
Sorry for missing this...hope this helps,
JH
(Who's going to bed now...)
------------------------------
Date: Wed, 27 Dec 2000 04:19:50 GMT
From: georgebailey@my-deja.com
Subject: How to delete items from an array?
Message-Id: <92bql3$hhk$1@nnrp1.deja.com>
I've tried to find an answer to this in various places, and forgive me
if I'm missing something, but:
* say I have an array with ten items
* I want to delete items 1,3,5, and 7
* not just make them empty but end up with 4 fewer items in my array
what's the smart way to do it?
I can *do* it, by doing a
for (each item to be deleted), item = ''
kind of thing, then reading the array into another array like this:
if the item ne '', push() it into the new array
but I'm sure I'm missing something -- is there a more elegant way?
This exercise also taught me something which comes up in POD -- that
just because something eq '', doesn't mean it's undef...
--
~~ ...and dance by the light of the moon
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 27 Dec 2000 04:43:59 GMT
From: Mike Wescott <wescott@conterra.com>
Subject: Re: How to delete items from an array?
Message-Id: <osg0jaiicg.fsf@eriadne.sc.rr.com>
georgebailey@my-deja.com writes:
> I've tried to find an answer to this in various places, and forgive me
> if I'm missing something, but:
>
> * say I have an array with ten items
> * I want to delete items 1,3,5, and 7
> * not just make them empty but end up with 4 fewer items in my array
>
> what's the smart way to do it?
Use splice. See
perldoc -f splice
--
Mike Wescott
wescott@conterra.com
------------------------------
Date: Tue, 26 Dec 2000 22:35:49 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to delete items from an array?
Message-Id: <slrn94iosl.ddd.tadmc@magna.metronet.com>
georgebailey@my-deja.com <georgebailey@my-deja.com> wrote:
>I've tried to find an answer to this in various places, and forgive me
>if I'm missing something, but:
>
> * say I have an array with ten items
> * I want to delete items 1,3,5, and 7
> * not just make them empty but end up with 4 fewer items in my array
>
>what's the smart way to do it?
perldoc -f splice
>I can *do* it, by doing a
>
> for (each item to be deleted), item = ''
>
>kind of thing, then reading the array into another array like this:
>
> if the item ne '', push() it into the new array
Err, but you wouldn't do that when there's grep() around:
@array = grep length, @array; # remove zero-length elements
You do not need a "new" array either, you can put right back
where you got it from.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 27 Dec 2000 06:15:45 GMT
From: abigail@foad.org (Abigail)
Subject: Re: How to delete items from an array?
Message-Id: <slrn94j28h.1s2.abigail@tsathoggua.rlyeh.net>
Tad McClellan (tadmc@metronet.com) wrote on MMDCLXXV September MCMXCIII
in <URL:news:slrn94iosl.ddd.tadmc@magna.metronet.com>:
&& georgebailey@my-deja.com <georgebailey@my-deja.com> wrote:
&& >I've tried to find an answer to this in various places, and forgive me
&& >if I'm missing something, but:
&& >
&& > * say I have an array with ten items
&& > * I want to delete items 1,3,5, and 7
&& > * not just make them empty but end up with 4 fewer items in my array
&& >
&& >what's the smart way to do it?
&&
&&
&& perldoc -f splice
That's a bit awkward.
@array = @array [0, 2, 4, 6, 8 .. $#array];
Or, if there are no undefined elements:
delete @array [1, 3, 5, 7];
@array = grep {defined} @array;
For M deletions of separate elements in an array of size N, use of
splice would be O (NM), while the method below (and above) takes O (N).
&& >I can *do* it, by doing a
&& >
&& > for (each item to be deleted), item = ''
&& >
&& >kind of thing, then reading the array into another array like this:
&& >
&& > if the item ne '', push() it into the new array
&&
&&
&& Err, but you wouldn't do that when there's grep() around:
&&
&& @array = grep length, @array; # remove zero-length elements
&&
&& You do not need a "new" array either, you can put right back
&& where you got it from.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: Wed, 27 Dec 2000 07:44:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How to delete items from an array?
Message-Id: <x7bstyb95a.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@foad.org> writes:
A> @array = @array [0, 2, 4, 6, 8 .. $#array];
A> Or, if there are no undefined elements:
A> delete @array [1, 3, 5, 7];
A> @array = grep {defined} @array;
well, since you always use map in a void context, here is a solution
using map in a list context:
my $i ;
@array = map { $i++ % 2 ? $_ : () } @array ;
you can switch the order of () and $_ to get the other elements. and it
works for any size array.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Wed, 27 Dec 2000 06:15:42 GMT
From: shwekhaw@my-deja.com
Subject: How to have three dimentional array
Message-Id: <92c1ec$m5k$1@nnrp1.deja.com>
I have having newbie trouble, I just testiong simple script from book
which is basically not working
It is the script which search through a papragraph for a word and print
out the location of that word under Line and Column.
The problem is if there are two same words ,which are being searched ,
in same line, it print out only last word as it overwrite the array
content with same line.
Let's see the code
#!/usr/local/bin/perl
%finds = ();
$line = 0;
print "\n Enter word to search for:";
$word = <STDIN>;
chop ($word);
print "\n Enter file to search in:";
$fname = <STDIN>;
chop($fname);
open (IFILE, $fname) || die "Cannot open $fname $!\n";
print "Search for :$word: \n";
$count=1;
while (<IFILE>) {
$thispos = 0;
$nextpos = 0;
while (1) {
$nextpos = index($_,$word,$thispos);
if ($nextpos == -1) {
$count++;
last;}
$finds{"$count"} = "$nextpos"; ##$count is line number but it
is overwrite when there is another word found.##
$thispos = $nextpos + 1;
}
}
close IFILE;
print "\nLn : Column";
while(($key,$value) = each(%finds)) {
print "\n $key : $value \n";
}
Input
-----
hey hey hey
line the line
the the play way the
stop stop stop kyaw
hehehe hahaha
the
OutPut
------
Ln : Column
2 : 5
3 : 17
6 : 0
OutPut I want
-------------
Ln : Column
2 : 5
3 : 0
3 : 4
3 : 17
6 : 0
I THINK I CAN SOLVE BY USING THREE DIMENTIONAL ARRAY.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 27 Dec 2000 01:10:51 -0600
From: anmcguire@ce.mediaone.net (Andrew N. McGuire)
Subject: Re: Is there an overhead using long variable names?
Message-Id: <86hf3qe3us.fsf@hawk.ce.mediaone.net>
>>>>> "LS" == Logan Shaw <logan@cs.utexas.edu> writes:
LS> In article <3a3a4279@cs.colorado.edu>,
LS> Tom Christiansen <tchrist@perl.com> wrote:
>> In article <91c9sn$e8f$1@boomer.cs.utexas.edu>,
>> Logan Shaw <logan@cs.utexas.edu> wrote:
>>> Can't you measure compile time of some code by doing something
>>> like the following?
>>
>> That assumes you can get to within the margin of error caused
>> by quantum fluctuation. Which is highly unclear.
LS> Huh? Are you saying that you expect the variation to be so small
LS> that it would be hard to ensure one tests enough iterations to
LS> find a difference?
LS> I did see a difference when I ran that benchmark. The ones with the
LS> print statement took about 20% longer than the ones without. Granted,
LS> this difference is probably much larger than the difference for
LS> examining symbols of two different sizes. But then, while it may not
LS> ultimately answer the question of whether there is an overhead for
LS> using long variable names, if the difference is so small that it's
LS> difficult to measure, then that does give sort of a practical answer.
LS> Of course, you could always exaggerate the difference by using
LS> obscenely long variable names. (Is there a maximum?)
251 chars would appear to be the max on my system...
[anm@hawk ~] uname -a [0 ttyp0]
FreeBSD hawk.ce.mediaone.net 4.1-RELEASE FreeBSD 4.1-RELEASE #0: Sun Dec 24 18:48:24 CST 2000 root@hawk.ce.mediaone.net:/usr/src/sys/compile/FreeBSD_4.1-RELEASE i386
[anm@hawk ~] [0 ttyp0]
thank God for vi! (251ix<ESC>). :-)
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Wed, 27 Dec 2000 00:06:50 -0600
From: "Dave Webb" <dwebb@cvalley.net>
Subject: Re: my cgi scripts starts a download? urgent help needed
Message-Id: <92c0p5$3h0$1@einstein.greenhills.net>
or if its a win32 machine, perl hasn't been properly set up in the
registry...
<egwong@netcom.com> wrote in message
news:OQ526.23447$bw.1592656@news.flash.net...
> Create232 <create232@aol.com> wrote:
> > This sounds like a permissions problem. You must make sure the
script(s) are
> > set as executable..
>
> I haven't seen the original post, but if your cgi script is starting
> a download then it sounds like you're sending the wrong mime-type in
> your header. If you're using CGI.pm, it's just
>
> print $cgi->header(); # if using objects
>
> or
> print header(); # if not (:standard)
>
> If you're not using CGI.pm (you should be) it's
>
> print "Content-type: text/html\x0d\x0a\x0d\x0a";
>
>
------------------------------
Date: 27 Dec 2000 00:29:13 -0600
From: anmcguire@ce.mediaone.net (Andrew N. McGuire)
Subject: Re: Parsing
Message-Id: <86n1die5s6.fsf@hawk.ce.mediaone.net>
>>>>> "TM" == Tad McClellan <tadmc@metronet.com> writes:
TM> mountain_arts <mountain_arts> wrote:
>> abigail@foad.org (Abigail) wrote:
>>
>>> Simon Stiefel (SiStie@nuclear-network.de) wrote on MMDCLXXIII September
>>> MCMXCIII in <URL:news:Pine.LNX.4.31.0012252154170.3664-100000@server.stiefel.priv>:
>>> // I want to parse the output of "finger".
>>> // The output could be something like this:
>>> //
>>> // sistie Simon Stiefel *3 - Mon 20:12
>>> // ^^^^^^^^^^|^^^^^^^^^^^^^^^^^^^^|^^^^^^^^^^^^|^^^^^|^^^^^^^^^^
>>> // $1 $2 $3 $4 $5
>>> unpack
>> why not split?
TM> split() is for data with separators, finger(1)'s data does not
TM> have separators.
TM> unpack() is for fixed-width fields, finger(1)'s data is
TM> fixed-width fields.
would it not be faster still to use substr(), i dont think that
finger will produce huge amounts of output (on most systems).
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Tue, 26 Dec 2000 18:21:30 -0700
From: "Michael Stearns" <michael@datahost.com>
Subject: regex question: putting back references in another variable
Message-Id: <5sc26.729$e6.445781@news.uswest.net>
Say I have the following:
$text= "foobar";
$find = "(foo)(bar)";
$replace="$2$1";
I want to have a regular expression that will allow me to end up with $text
set to "barfoo". I was hoping I could do something like the following:
$text=~s^$find^$replace^s;
However, when I do this, $replace is interpreted literally as "$2$1" and
that is what I end up with.
Is there a way, in the above scenario to have the $1 and $2 evaluated as
backreferences instead of as literal text?
Thanks,
Michael
------------------------------
Date: Wed, 27 Dec 2000 07:29:58 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: regex question: putting back references in another variable
Message-Id: <slrn94j703.2m9.rgarciasuarez@rafael.kazibao.net>
Michael Stearns wrote in comp.lang.perl.misc:
> Say I have the following:
>
> $text= "foobar";
> $find = "(foo)(bar)";
> $replace="$2$1";
You probably mean
$replace='$2$1';
> I want to have a regular expression that will allow me to end up with $text
> set to "barfoo". I was hoping I could do something like the following:
>
> $text=~s^$find^$replace^s;
>
> However, when I do this, $replace is interpreted literally as "$2$1" and
> that is what I end up with.
One way is to use eval() to force evaluation at runtime:
#!/usr/local/bin/perl -l
$text = "foobar";
$find = "(foo)(bar)";
$repl = '$2$1';
$text =~ s/$find/eval(qq("$repl"))/e;
print $text; # prints "barfoo"
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Wed, 27 Dec 2000 03:05:28 GMT
From: hongdou@my-deja.com
Subject: want to fetch html files without LWP
Message-Id: <92bm9m$ei9$1@nnrp1.deja.com>
I wnat to fetch html file from other sites,
but I can't use LWP in my website,
so I write a CGI to do this, the source is under here:
---------------------------------------------------
#!/usr/bin/perl
use Socket;
use IO::Socket;
$port=80;
$remote='www.perl.com';
$uri='http://www.perl.com/';
socket(hpSOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
if(!connect(hpSOCK, sockaddr_in($yport, inet_aton($remote))))
{
print "cannot connect";
exit(1);
}
hpSOCK->autoflush();
print hpSOCK "GET ".$uri."\r\n";
print <hpSOCK>;
close(hpSOCK);
-------------------------------------------------------------
when set $remote to my website, $uri to the html files of my website,
it works well, but when I want to fetch html files from other website,
it cannot work, and show "cannot connect" to me.
what wrong with it?
any ideas to me?
thanks.
Hongdou
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 27 Dec 2000 05:17:53 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: want to fetch html files without LWP
Message-Id: <5Ye26.481$B9.170956800@news.frii.net>
In article <92bm9m$ei9$1@nnrp1.deja.com>, <hongdou@my-deja.com> wrote:
>I wnat to fetch html file from other sites,
>but I can't use LWP in my website,
>so I write a CGI to do this, the source is under here:
>---------------------------------------------------
>#!/usr/bin/perl
>use Socket;
>use IO::Socket;
>$port=80;
>$remote='www.perl.com';
>$uri='http://www.perl.com/';
>socket(hpSOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
>if(!connect(hpSOCK, sockaddr_in($yport, inet_aton($remote))))
>{
> print "cannot connect";
> exit(1);
>}
>hpSOCK->autoflush();
>print hpSOCK "GET ".$uri."\r\n";
>print <hpSOCK>;
>close(hpSOCK);
>-------------------------------------------------------------
>when set $remote to my website, $uri to the html files of my website,
>it works well, but when I want to fetch html files from other website,
>it cannot work, and show "cannot connect" to me.
>what wrong with it?
>any ideas to me?
>thanks.
>
>Hongdou
>
Is there a firewall or proxy between you and the internet? If
there is then you probably will want to find a way to use LWP. Or
in the worst case, study how lwp does it and write something similar
yourself.
--
This space intentionally left blank
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 5204
**************************************