[11924] in Perl-Users-Digest
Perl-Users Digest, Issue: 5524 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 30 02:07:20 1999
Date: Thu, 29 Apr 99 23:00:24 -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, 29 Apr 1999 Volume: 8 Number: 5524
Today's topics:
a better way??? (Meling Mudin)
Re: Beginner question regarding @INC (Ronald J Kimball)
Re: Calling functions iteratively (Tad McClellan)
Re: Calling functions iteratively <uri@sysarch.com>
Re: Count Linenumber <uri@sysarch.com>
data mining program? <mush@iex.net>
Directory Listing with Win32 and IIS slg1l@cc.usu.edu
Re: Directory Listing with Win32 and IIS <tim@timbury.com>
How to change effective GID <carriec@doc.state.vt.us>
how to use require? <judak@yahoo.com>
Re: importing a namespace from an arbitrary file <walton@frontiernet.net>
Re: Is this the best way to get a substring? (Ronald J Kimball)
Re: Is this the best way to get a substring? (Larry Rosler)
Re: matching a quoted string (Mike Brittain)
Re: May 3rd, SV.pm First Meeting!! <ebohlman@netcom.com>
Re: Passing Params <walton@frontiernet.net>
Re: PERL & Y2K (Ronald J Kimball)
Re: perl and Relational Databases (Tad McClellan)
Re: Perl Conference (Ronald J Kimball)
Re: Perl Weekday Script (Cyberine2k)
Re: Problem with Date::Manip and Holidays... (Ronald J Kimball)
Re: Question: Opening and closing files. (Ronald J Kimball)
Re: RegExp for the following string, w/o using split (Tad McClellan)
Re: RegExp for the following string, w/o using split (Ronald J Kimball)
Re: search string syntax (Mike Brittain)
Re: Searching a Text File by key (Tad McClellan)
Re: Searching a Text File by key <jeff@vpservices.com>
Re: single quotation " erases REST OF TEXT (Sam Holden)
Re: single quotation " erases REST OF TEXT <ebohlman@netcom.com>
Re: Using a reference to an array (Tad McClellan)
Re: What does this error message mean? (Ronald J Kimball)
Re: What does this error message mean? (Ronald J Kimball)
Re: what's wrong with $x = $y or "" (Ronald J Kimball)
Re: What's wrong with this code? (Ronald J Kimball)
why /g gets me wrong search results? <hcchen@pobox.com>
Re: Why paranthesis change logical expression (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Apr 1999 03:52:57 GMT
From: mudin@expert.cc.purdue.edu (Meling Mudin)
Subject: a better way???
Message-Id: <7gb9ep$jov$1@mozo.cc.purdue.edu>
Can anyone suggests a better way of doing this .... I am losing
my head and errrghhh!!!!
When the program runs, it's suppose to look for user(s) that is/are
connected from different hosts. I have initialization error
pointing to the line:
if (exists ($hash{$user}{$from}))
Anyone have any idea how to fix it?
-mel
---- code ---
# check if a user is remotely logged in from
# two different host
use strict;
my $cmd = "/bin/who";
my $line = "";
my $user;
my $from;
my @myline = ();
my %hash = ();
my $count = 0;
my $from_here ="";
open (WHO, "$cmd |") or die "can't execute who: $!\n";
while (<WHO>) {
# split the lines
@myline = split /[((\t)+)((\s)+)]+/;
$user = $myline[0];
$from = $myline[5];
# store the stuff into a hash
if (exists ($hash{$user}{$from})) {
$hash{$user}{$from}++;
}
else {
$hash{$user}{$from} = 0;
}
}
foreach $user (sort keys %hash) {
$count = 0;
$from_here = "";
foreach $from (sort keys %{$hash{$user}}) {
$count++;
$from_here.="$from ";
# print "$user==>$from \n";
}
# print $count."\n";
if ($count > 1) {
print "$user : $from_here\n";
}
}
------------------------------
Date: Fri, 30 Apr 1999 01:03:49 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Beginner question regarding @INC
Message-Id: <1dr1lxf.h6ffu0p4ztogN@p247.block1.tc4.state.ma.tiac.com>
Brian Yeoh <byeoh@panix.com> wrote:
> Could anyone tell me
> how I can modify the default values of @INC? I've flipped through the
> camel and tried undeffing @INC and assigning it new values like so:
>
> undef @INC
> @INC = {/usr/lib/, etc}
The correct ways to modify @INC are:
% perl -I/path/to/dir -I/path/to/other/dir
% set PERL5LIB /path/to/dir:/path/to/other/dir
% perl
use lib '/path/to/dir';
use lib '/path/to/other/dir';
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 29 Apr 1999 17:58:36 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Calling functions iteratively
Message-Id: <cmkag7.cm2.ln@magna.metronet.com>
Slav Inger (vinger@ford.com) wrote:
: I have a special situation where I'm forced to call functions from
^^^^^^
You don't tell us what is forced.
You are forced to store the function names and args in a
data structure?
You are forced to store the function names and args in an array?
You are forced to store the function names and args in an array
like you have shown?
We cannot suggest alternatives if we do not know which parts
we are allowed to change...
: within an array that stores the function names and parameters, like
: this:
: @subs = ('test1("a")', 'test2("b")');
: foreach(@subs) {
eval $_; # works, but dangerously and slowly
How about using anonymous arrays with the code reference
followed by the arguments?
-------------------
#!/usr/bin/perl -w
use strict;
my @subs = ( [ \&test1, 'a', 'A' ], [ \&test2, 'b', 'B']);
foreach (@subs) {
my($coderef, @args) = @$_;
&$coderef(@args);
}
sub test1 {
my(@args) = @_;
local $" = ',';
print "test1(@args)\n";
}
sub test2 {
my(@args) = @_;
local $" = ',';
print "test2(@args)\n";
}
-------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 29 Apr 1999 23:38:05 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Calling functions iteratively
Message-Id: <x7n1zq7p7m.fsf@home.sysarch.com>
>>>>> "AA" == Andrew Allen <ada@fc.hp.com> writes:
AA> Nope on both counts; correct as written. $#$_ returns the index of the
AA> last element of the list reference contained in $_. $$_[0] returns the
AA> first element in the list referenced by $_, which is a reference to
AA> sub, therefore ->( is still necessary. May want to double-check using
AA> the interpreter before (mis)correcting people on the newsgroup.
my bad. i am still recovering from the perl tutorials and too many
hours of class and hanging out (drinking) with various hackers.
24 hours of that in 2 days (while slightly ill with a throat cold) will
make you lose most of your perl skills for a while!
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: 29 Apr 1999 23:42:56 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Count Linenumber
Message-Id: <x7k8uu7ozh.fsf@home.sysarch.com>
>>>>> "s" == sstarre <sstarre@my-dejanews.com> writes:
s> How about this- no loop:
s> open F,'./x';
s> my $count=my @l=<F>;
s> print "$count\n";
s> close F;
but as others have stated, that slurps the entire file into memory which
can be a pig.
and if you wanted this to be shorter, and it is only one program, you
don't need F, just use <>
$count = @l = <>;
print "$count\n";
my one liner without the obsfucation that abigail created works fine
without any explicit loops either.
>> perl -ne 'END{print "$.\n"'}'
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, 29 Apr 1999 21:08:08 -0600
From: Randy Murrish <mush@iex.net>
Subject: data mining program?
Message-Id: <37291E98.AEEFBC6F@iex.net>
I've lost my reference to a program that basically mined different web
sites and generated an HTML page with the mined data. It was used by
the developer to build customized home pages that included data from new
sources (news.com, slashdot.com) along with other custom information.
The program supported an easy to use plugin architecture that allowed
other developers to easily plug in other data mining modules.
I believe the program was developed by a professor at a university.
If you know of any such program, I would be eternally greatfull if you
passed the location or web page on to me. Email or post here is fine, I
just want to find the developer.
Thanks ... Randy
--
Randy Murrish
mush@iex.net
http://www.iex.net/~mush
------------------------------
Date: 29 Apr 99 21:49:17 MDT
From: slg1l@cc.usu.edu
Subject: Directory Listing with Win32 and IIS
Message-Id: <BsHswyns8iw+@cc.usu.edu>
I'm being forced against my will to use an IIS server for my webpages.
Can someone tell me how to get the following to work:
for $file (`dir *.ssi /b`)
{
print $file;
}
(As was mentioned by someone on this group...)
This works perfectly from the command line. However, when I access it thru
the web server it doesn't return anything.
Can anyone help me?
Is this the difference between my Win98 test machine and my NT IIS server?
-Cae
------------------------------
Date: Fri, 30 Apr 1999 01:10:24 -0400
From: "Tim" <tim@timbury.com>
Subject: Re: Directory Listing with Win32 and IIS
Message-Id: <925449060.231.9@news.remarQ.com>
Being the daring(read "foolish") type, I took your code exactly as you gave
it
and saved it as iis.pl in my c:\InetPub\scripts directory. I the accessed it
from
another pc on the net (http://myserver/scripts/iis.pl) in IE4 and it threw
out
a CGI error because I didn't write any headers. However, it also spit out
the
correct file listing, so it works fine (if I cared to write headers). What
result
are you getting? Feel free to email me as this is really off-topic here.
Tim K.
slg1l@cc.usu.edu wrote in message ...
>I'm being forced against my will to use an IIS server for my webpages.
>
>Can someone tell me how to get the following to work:
>
>
>
>
>for $file (`dir *.ssi /b`)
>{
> print $file;
>}
>
>
>
>(As was mentioned by someone on this group...)
>This works perfectly from the command line. However, when I access it thru
>the web server it doesn't return anything.
>
>Can anyone help me?
>
>Is this the difference between my Win98 test machine and my NT IIS server?
>
>
>-Cae
>
------------------------------
Date: Thu, 29 Apr 1999 22:22:40 -0400
From: Carrie Coy <carriec@doc.state.vt.us>
Subject: How to change effective GID
Message-Id: <372913F0.735138BE@doc.state.vt.us>
How do I change the effective GID of a user in a perl script?
The user belongs to several groups. This script creates a file which I
want to be owned by one of the user's supplemental groups.
?? Thanks,
Carrie Coy
------------------------------
Date: Thu, 29 Apr 1999 22:45:25 -0700
From: judak <judak@yahoo.com>
Subject: how to use require?
Message-Id: <37294375.D389A7E2@yahoo.com>
Hi, I try to do this simple thing. I typed up this predefined html
header and footer so every time when I want to draw a web page it'll
save me a little trouble. I put the subroutines header and footer in a
file called html.pl
and try to use it by typing " require "html.pl" " and the error I
get is
"html.pl did not return a true value at test.pl line 2."
here is actual codes:
#html.pl
#makes the header and footer of a html document
#header part
sub html_header
{
print "Content-type: text/html", "\n\n";
print "<HTML>", "\n\n";
print "<HEAD>", "\n\n";
print "<TITLE>", "@_", "</TITLE>", "\n\n";
print "</HEAD>", "\n\n";
}
#footer part
sub html_footer
{
print "\n", "</BODY>", "\n\n";
print "</HTML>", "\n\n";
}
Here is how I called the file:
#test.pl
require "html.pl";
&html_header;
print "Content-type: text/html", "\n\n";
print "<BODY>", "\n";
print "<H1><center>HAHAHAHAHA</center></H1>", "\n";
print "<br><hr>", "\n";
&html_footer;
Would someone please help me out? I did what the book told me to and it
did not work out. Thanks a lot!!!
------------------------------
Date: Thu, 29 Apr 1999 23:08:10 -0400
From: Bob Walton <walton@frontiernet.net>
To: sstarre@my-dejanews.com
Subject: Re: importing a namespace from an arbitrary file
Message-Id: <37291E9A.D0936419@frontiernet.net>
Check out @INC in the perlvar doc. It might be convenient to use the -I switch
when starting perl, or to include a push on @INC in a BEGIN block.
sstarre@my-dejanews.com wrote:
> I read Camel, permod, and perldoc for this info but I don't see this topic
> even mentioned nor any relavent examples given.
>
> I wish to import variables from a module in another directory. Right now I do
> something like:
>
> require '../mydir/modx.pm';
>
> which works OK, but I'd prefer to use "use", as in
>
> use modx qw(varx);
>
> for its additional control over what is loaded.
>
> How can I tell the compiler to look for modules in ../mydir or any other
> specific dir? I folled aroud with system('PATH') but
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 30 Apr 1999 01:03:55 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Is this the best way to get a substring?
Message-Id: <1dr1plj.1v7shou1jk2higN@p247.block1.tc4.state.ma.tiac.com>
Jerome O'Neil <jeromeo@atrieva.com> wrote:
> > Never look at $1 unless you are inside a conditionally executed
> > chunk of code dependant on the success of your match of interest.
>
> When that particular question is asked, I'll be sure to direct them to
> the appropriate documentation for next and unless.
And you can bet that if this particular poster asks that question, it is
because you provided him with code that exhibits that particular error.
We already have to advise new programmers who are creating their own
mistakes in their Perl code. We don't need experienced posters giving
them more mistakes by providing poor examples.
Don't depend on the values of any of the special regex variables, unless
you know that the match succeeded.
P.S. (The other) Larry did it too. :(
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 29 Apr 1999 22:29:40 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Is this the best way to get a substring?
Message-Id: <MPG.1192dfa4aa238ffc98997d@nntp.hpl.hp.com>
In article <1dr1plj.1v7shou1jk2higN@p247.block1.tc4.state.ma.tiac.com>
on Fri, 30 Apr 1999 01:03:55 -0400, Ronald J Kimball
<rjk@linguist.dartmouth.edu> says...
...
> Don't depend on the values of any of the special regex variables, unless
> you know that the match succeeded.
>
> P.S. (The other) Larry did it too. :(
I was lying low, hoping no one noticed. :(
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 30 Apr 1999 03:29:15 GMT
From: britts@pyro.net (Mike Brittain)
Subject: Re: matching a quoted string
Message-Id: <37292273.13291413@news.pyro.net>
On Fri, 30 Apr 1999 02:43:12 GMT, koch9@home.com (Jon) wrote:
>I am using the following code to find an existing string in a line of input,
>then replace it with another string.
>
>if($line =~ /$compare/) {
> $line =~ s/$compare/$newstr/eg;
>}
Why are you using /e in your substitution? Is it necessary for what
you are doing here?
Also, I don't know if you need to check for the match. If you just
run the substitute line on the $line var, then the substitution will
be made if $compare is found, and it simply won't if $compare is not
found.
>
>This works fine unless the string is contained inside double quotes in the line
>of input. In that case, no match is found. How do you stop the double quotes
>in the input line from affecting the string match and substitution?
>
Try running the following code and see if you get the replacement in
both cases... I did (running on activestate under win95 (sorry!))
Hope this addresses your need! Mike
#!/usr/local/bin/perl5 -w
print $input1 = 'this is the first line of input', "\n";
print $input2 = "this is not the first line of input", "\n\n";
print "making a sub for input 1\n";
$input1 =~ s/first/FOO/g;
print $input1, "\n\n";
print "making a sub for input 2\n";
$input2 =~ s/first/FOO/ge;
print $input2;
------------------------------
Date: Fri, 30 Apr 1999 05:40:28 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: May 3rd, SV.pm First Meeting!!
Message-Id: <ebohlmanFAzMFG.2Cn@netcom.com>
Craig R. Belcham <crb@highpoint.co.uk> wrote:
: fxia@yahoo.com wrote:
: > Next Meeting Monday, May 3, 1999 7:00 pm
: A PERL mongers meeting on my birthday, Im touched!:)
Chicago.pm's next meeting is on my birthday (May 17), too.
------------------------------
Date: Thu, 29 Apr 1999 23:40:41 -0400
From: Bob Walton <walton@frontiernet.net>
To: "news.boeing.com" <jim.ray@west.boeing.com>
Subject: Re: Passing Params
Message-Id: <37292639.A891F106@frontiernet.net>
Hmmm...your URL will cause your web server to use the GET method. If your Unix
system is using a server that uses the standard CGI stuff, the string ME should
appear in environment variable QUERY_STRING (in %ENV{QUERY_STRING} in perl),
and envorinment variable REQUEST_METHOD should be set to GET. If this stuff is
appearing in the argument list to your CGI script, your Unix server is not
using standard CGI. You don't say what web server you are using on NT, but if
it uses standard CGI (which is probably does, as most web servers do), you
should look in the environment variables listed above. Try printing out
everything in %ENV with something like:
for(sort keys %ENV){print "$_=%ENV{$_}\n";}
and go from there.
"news.boeing.com" wrote:
> I am migrating my UNIX perl scripts over to NT. So far it has not beena big
> deal. The problem is how NT perl handles Parms.
>
> I have a code the goes something like this. passme.cgi?ME
>
> In UNIX using the $ARGV[0] store the value "ME". In NT $ARGV[0] never gets
> passed. What is the command in Active Perl 5 that works the same?
>
> Thank you.
>
> --
> Jim Ray
> Delta Program NT Administrator
> The Boeing Company
> 714-896-2038
> jim.ray@west.boeing.com
------------------------------
Date: Fri, 30 Apr 1999 01:03:58 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: PERL & Y2K
Message-Id: <1dr1q67.2tou0v1fyes5zN@p247.block1.tc4.state.ma.tiac.com>
Bill Jones <bill@fccj.org> wrote:
> What is REALLY scary is that I got e-mailed 'spam' from
> some company (unravel.com, I believe) saying they had
> a perl code scanner which helps you fix all perl Y2k issues.
>
> They charge a $3,000 if I remember correctly.
>
> I e-mailed them back and asked "So, it is a programmer mind reader?"
> The guy mailed me back and said people are buying it.
Hmmm....
#!/usr/local/bin/perl
$| = 1;
# configuration
$REPEAT = 5_000_000;
print "Please wait while Perl Y2K Scanner checks for Y2K errors.\n";
# we could sleep() here, but we want to make it look like
# we're doing something. so just hit the disk a bunch
# of times
open(IN, $0) # if the open fails, output a cryptic error message
or die
"Fatal error: unable to find a valid grobnitz\n" .
"Call 1-900-PERL-Y2K for technical support.\n";
# and we can charge $20/hr for tech support
for ($i=0; $i<$REPEAT; ++$i) {
while (<IN>) {
# if this program really did anything, there might be some
# code in this while loop
}
seek(IN,0,0);
}
print "No Y2K errors were detected." .
"Thank you for using our Perl Y2K scanner.\n";
# wait, don't let them get away yet
print "Our Super Gold version can detect even more Y2K errors.\n" .
"Call 1-900-PERL-Y2K for details.\n";
# I bet we can find suckers to pay $3000 for this script!
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 29 Apr 1999 17:34:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: perl and Relational Databases
Message-Id: <h9jag7.cm2.ln@magna.metronet.com>
wax_man@my-dejanews.com wrote:
: Is there a way to use Perl to connect to a Relational Database? I am using
: Informix RDMS and would like to use Perl/cgi to add data directly to a table.
Perl FAQ, part 8:
"How do I use an SQL database?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 30 Apr 1999 01:04:00 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl Conference
Message-Id: <1dr1qva.1ecqbip13qeuv4N@p247.block1.tc4.state.ma.tiac.com>
Gala Grant <gala@sonic.net> wrote:
> Does anyone know when registration for the Perl Conference in Monterey is
> going to start? I contacted O'Reilly before and was told March. But I
> still can't find any info about registering.
Neither can I. You can sign up for O'Reilly's conference mailing list
by sending email to oscon@oreilly.com
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 30 Apr 1999 04:52:16 GMT
From: cyberine2k@aol.com (Cyberine2k)
Subject: Re: Perl Weekday Script
Message-Id: <19990430005216.21611.00000252@ng68.aol.com>
Thanks! I'll check out the modules.>Perl Modules are your friend.
Void where prohibited.
------------------------------
Date: Fri, 30 Apr 1999 01:04:02 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Problem with Date::Manip and Holidays...
Message-Id: <1dr1rue.1ib8hh3gix7ltN@p247.block1.tc4.state.ma.tiac.com>
Hemant Shah <shah@xnet.com> wrote:
> I am using Date::Manip Version 5.33, and I am having truoble wiht
> global config file. I have a global config file that lists all
> holidays until 2010, it seems that Date:Manip ignores the year part of
> the dates in the config file.
As documented:
CUSTOMIZING DATE::MANIP
[...]
All lines are of the form:
DATE = HOLIDAY
HOLIDAY is the name of the holiday (or it can be blank in which case
the day will still be treated as a holiday... for example the day
after Thanksgiving or Christmas is often a work holiday though
neither are named).
DATE is a string which can be parsed to give a valid date in any
year.
Note, "in any year". Apparently Date::Manip does not handle
year-specific holidays. Sorry.
> How can I fix the problem?
Email the author, I guess; you could even send him a patch if you're
feeling motivated. The problem would be that with year specific
holidays, you would probably need a much larger data structure.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 30 Apr 1999 01:04:03 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Question: Opening and closing files.
Message-Id: <1dr1s55.1g9q8421wawzh5N@p247.block1.tc4.state.ma.tiac.com>
Tony Bowden <tony@blackstar.co.uk> wrote:
> Abigail <abigail@fnx.com> wrote:
> > David Cassell (cassell@mail.cor.epa.gov) wrote on MMLXII September
> > MCMXCIII in <URL:news:37210A44.47C2D26A@mail.cor.epa.gov>:
>
> The 2562nd of September 1993?
http://www.dejanews.com/getdoc.xp?AN=348636187
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 29 Apr 1999 19:12:16 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: RegExp for the following string, w/o using split
Message-Id: <g0pag7.fs2.ln@magna.metronet.com>
Michael Shavel (mshavel@erols.com) wrote:
: " 4","123456","19990423","","","","","This is the text field","","",""
: I need to always parse what is between the first and second comma, so in
: this case I want to get 123456 into a variable.
: I've tried various regular
: expressions but can't seem to get it right.
Let's see them.
We cannot fix code that we cannot see...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 30 Apr 1999 01:04:04 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: RegExp for the following string, w/o using split
Message-Id: <1dr1s81.11bo0pi1l4vutlN@p247.block1.tc4.state.ma.tiac.com>
David Cassell <cassell@mail.cor.epa.gov> wrote:
> > Split is what you want. 250,000 lines is pretty trivial.
> >
> > while(<>){
> > my($one,$two,@rest) = split(/,/);
> > # Etc...
> > }
> >
> > Good Luck!
>
> Or, if you don't need the rest of the line after the second field,
> you could specify the LIMIT like this:
>
> my ($one,$two) = split(/,/,$_,2);
That will split into two elements. So $one will contain the first
column, and $two will contain all the other columns joined together.
You meant:
my ($one,$two) = split(/,/,$_,3);
But when you omit LIMIT, Perl supplies for you a LIMIT that is one
greater than the number of variables on the LHS of the assignment. So
you really meant:
my ($one,$two) = split(/,/);
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 30 Apr 1999 03:36:55 GMT
From: britts@pyro.net (Mike Brittain)
Subject: Re: search string syntax
Message-Id: <372924e1.13913072@news.pyro.net>
> Could someone please help me with the syntax to match the following :
>
> $string = "mobile internet communications"
>
> and I want to check to see if the word "mobile" is in that string, I also
>would like to be able to check if the word "operating systems" in the string.
Jae, you should look into regular expressions in perl for a large
variety of possibilities (endless!) for pattern matching.
Here is a very quick syntax for matching your strings.
#!/usr/local/bin/perl5 -w
print $string = "mobile internet communications", "\n";
if ($string =~ /mobile/) {
print "found mobile", "\n";
} else {
print "did not find mobile", "\n";
}
if ($string =~ /operating systems/) {
print "found operating systems", "\n";
} else {
print "did not find operating systems", "\n";
}
------------------------------
Date: Thu, 29 Apr 1999 17:31:17 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Searching a Text File by key
Message-Id: <53jag7.cm2.ln@magna.metronet.com>
Brand Hilton (bhilton@tsg.adc.com) wrote:
: In article <x7d80n8h54.fsf@home.sysarch.com>,
: Uri Guttman <uri@sysarch.com> wrote:
: >>>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:
: >
: > RLS> With a name like Randal Schwartz, I'm guaranteed to not get it right.
: >
: >i would think you would have learned to spell your own name correctly by
: >now.
: >your spelling of schwartz is the most common variation i know. it is the
: >dropped l that seems to most folks in trouble.
: >
: >and i can say these things since i have had my name mangled,
: >mispronounced and besmirched in countless ways.
: I have to chime in here. I've had my share of name-mangling. Very
: few people get "Brand" right the first time. My favorite was what
: Selective Service did with my name. I got letters from them until
: well into college informing me that "Brano Hiltor" had not registered
: for the draft.
I get mail for "Mr. Clellan" from time to time.
I file it appropriately.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Apr 1999 20:58:36 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Searching a Text File by key
Message-Id: <37292A6C.8C5FA28D@vpservices.com>
Randal L Schwartz <merlyn@stonehenge.com> writes:
> With a name like Randal Schwartz, I'm guaranteed to not get it right.
Well, mea culpa, I spelled it Randall. I stuck in an extra 'L' from
glancing at your middle initial too quickly. But, hey, it could be
worse: with a last name like Zucker, I have had some rather
embarrassing misspellings (s/Z/F/), one of which even made it through
the U.S. postal service on a nicely printed but poorly spell-checked
envelope.
--
Jeff Zucker
------------------------------
Date: 30 Apr 1999 03:20:43 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: single quotation " erases REST OF TEXT
Message-Id: <slrn7ii8cb.56i.sholden@pgrad.cs.usyd.edu.au>
On Fri, 30 Apr 1999 02:08:37 GMT, NOSPAMcrstlblu@planet.eon.net wrote:
>On Thu, 29 Apr 1999 08:00:31 GMT, bart.lateur@skynet.be (Bart Lateur) wrote:
>>>NOSPAMcrstlblu@planet.eon.net wrote:
>>> $content=~ s/"/"/d; > > TRIED YOUR IDEA HERE AND GOT AN ERROR
>>
>>That "d" must be a "g" (as in "global": ALL occurences of '"' are
>>replaced).
>> $content=~ s/"/"/g;
>> Bart.
>
> thanks Bart, unfortunately IT DON'T WORK either, :(
>
>again:
>
>(a) a dbm file has a text string INSIDE it that reads:
> I am 5'10" tall
>
>(b) ONE script extracts this into a $variable then passes it
> in a hidden form field to a SECOND script
>
>(c) the SECOND script parses values and then saves the
> value into a NEW DBM file!
>
>now if you VIEW the actual contents of this NEW dbm file,
>you will see that the ONLY THING THAT GOT SAVED is:
> I am 5'10
>
>EVERYTHING after the quotation mark in the middle got LOST!
>
>Don't do ANY HTML codeing in the scipts - to keep the flamers away -
>don't worry about trying to "print" to the browser any values this is
>100% strictly PERL programming!
So you manage to pass $variable in a hidden form but not do any HTML
coding. That's amazing. How do you get the browser to see the form
without sending it any HTML. How do you send it HTML if you haven't
produced any.
In the post I replied to last you said you where following the HTML
specification, how do you do that if you don't code any HTML?
Have a look at the HTML that you print out and you will see what everyone
has been saying milliona and millions of times that you seem just
to ignore because you think you know best.
It will contain the following :
<input type=hidden value="I am 5'10" and some more text for 200 characters">
If you actually read the post I spent considerable time typing up you will
see that this will result in the value being "I am 5'10". The rest of the
text is not part of the value because the quotes have been closed.
So escape the bloody quotes.
Do what everyone has said at least 10 times each.
Listen to the answers to your questions.
>
>I apologize for not FRAMING my original problem so as to prevent wanderings.
>:)
Listening to the bloody the answers would be more useful.
You still don't understand, but your question is actually about HTML. You
want to escape a quote in the value attribute of some HTML. You just don't
believe it when people who obviously know more than you tell you that
is what you want to do.
--
Sam
Of course, in Perl culture, almost nothing is prohibited. My feeling is
that the rest of the world already has plenty of perfectly good
prohibitions, so why invent more? --Larry Wall
------------------------------
Date: Fri, 30 Apr 1999 05:22:52 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: single quotation " erases REST OF TEXT
Message-Id: <ebohlmanFAzLM4.118@netcom.com>
NOSPAMcrstlblu@planet.eon.net wrote:
: (a) a dbm file has a text string INSIDE it that reads:
: I am 5'10" tall
: (b) ONE script extracts this into a $variable then passes it
: in a hidden form field to a SECOND script
"Passes it in a hidden form field" just so happens to imply "translates it
into HTML." If you are going to use HTML as a notation for transmitting
data between two applications (which is what you're doing), that data is
going to have to obey HTML's syntax rules. One of those rules says that
you can't embed a literal double-quote inside a double-quoted
attribute-value string; you have to escape it (though the SGML term, which
applies because HTML is an SGML application, is "entify" it). Your code
is trying to do what the HTML syntax rules say you can't do. Tad and
others have been telling you how to modify your code so that it produces
HTML that follows the rules.
: (c) the SECOND script parses values and then saves the
: value into a NEW DBM file!
Yes, and if the input that the values are parsed from doesn't follow the
HTML syntax rules, it won't get parsed correctly!
: now if you VIEW the actual contents of this NEW dbm file,
: you will see that the ONLY THING THAT GOT SAVED is:
: I am 5'10
: EVERYTHING after the quotation mark in the middle got LOST!
Because the input (which was in HTML) didn't get parsed properly, because
it didn't follow the syntax rules.
: Don't do ANY HTML codeing in the scipts - to keep the flamers away -
: don't worry about trying to "print" to the browser any values this is
: 100% strictly PERL programming!
There's Perl (the language) and perl (the interpreter for the language),
but there's no PERL. Yes, saying that verges on flaming here, but your
obstinancy is really provoking people. You've thoroughly convinced
yourself that the fault in your code can't be where everybody else thinks
(based on rational consideration of the evidence) that it is, and you
won't listen to anybody because doing so would force you to admit you
were wrong about something.
Get any psychology textbook and look at the section on "cognitive
dissonance"; what we're seeing here is a classic case of inability to
resolve cognitive dissonance (BTW, the study of cognitive dissonance began
in the 1950s when Leon Festinger was studying a religious sect that
believed that the world would end on a certain date. "Common sense" would
predict that when that date came around and the world was still there, the
members would become less committed to their group's belief system.
Instead, Festinger found that they became *more* committed to it).
Cognitive dissonance theory explains a large percentage of the cases where
smart people behave stupidly; the well-known phenomenon of "throwing good
money after bad" is a classic example. In programming, the usual
manifestation of this is for a programmer to waste huge amounts of time
trying to salvage a bad design instead of starting over and rewriting the
thing from scratch; just about all of us have either done this ourselves
or watched somebody do it. But this is the first time I've seen
cognitive dissonance cause a programmer to deny the existence of a
blatantly obvious bug like this.
------------------------------
Date: Thu, 29 Apr 1999 18:01:00 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Using a reference to an array
Message-Id: <sqkag7.cm2.ln@magna.metronet.com>
Daniel Grisinger (dgris@moiraine.dimensional.com) wrote:
: daniel.mendyke@digital.com (Daniel) writes:
: > my @xarray = qw( A B C D E );
: > my $xreference = \@xarray;
: >
: > How can I find the size of the array referenced
: > by $xreference?
: You were close.
: $#$xreference
Except that that does not find the size of the referenced array.
It finds the index of the last element of the array.
heh, heh...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 30 Apr 1999 01:04:06 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: What does this error message mean?
Message-Id: <1dr1sp3.slva371rukn8mN@p247.block1.tc4.state.ma.tiac.com>
Ala Qumsieh <aqumsieh@matrox.com> wrote:
> Ok .. what you say makes sense. But why is the line number
> misreported, and why is the behaviour different from:
The line number was misreported because of a bug. :)
Which has been fixed in 5.005.
> % perl -wc
> open F, "somefile";
> do {} while $i = <F>;
> Value of <HANDLE> construct can be "0"; test with defined() at - line 2.
> __END__
> Name "main::i" used only once: possible typo at - line 2.
> - syntax OK
>
> and why does the second case report the correct line number?
Because the bug didn't affect the second case.
> Shouldn't both produce the exact same opcode? Or is this irrelevant?
I would not be surprised if they are different opcodes. One is a loop
construct, which includes a block. The other is a statement modifier,
which follows a statement. But I don't really know.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 30 Apr 1999 01:04:07 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: What does this error message mean?
Message-Id: <1dr1sv9.iojgwb40fw4rN@p247.block1.tc4.state.ma.tiac.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> Usually Perl doesn't make a difference between numerical context and
> string context. Sometimes it does. Take logical false, for example,
> which returns zero in numerical context, and the empty string in string
> context. Or notice the difference in result between:
>
> print 16 | 2; # 18
> and
> print "16" | "2"; # "36"
The behavior of the bitwise logical operators depends on the scalar
types of the _operands_, not on the context.
print 0 + (16 | 2); # numeric context - 18
print '' . (16 | 2); # string context - "18"
print 0 + ("16" | "2"); # numeric context - 36
print '' . ("16" | "2"); # string context - "36"
> So why wouldn't Perl be allowed to treat "0" as true, and 0 as false?
There are very few areas where Perl cares whether a scalar value is a
scalar value is a string or a number (as we saw above, the bitwise
logical operators are an example). Making Perl distinguish between
string and number for truth and falsehood would, I think, cause many
more problems than it would solve.
[Even though I have been bitten by '0' as false.]
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 30 Apr 1999 01:04:09 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: what's wrong with $x = $y or ""
Message-Id: <1dr1tr8.1liuxon1eu7wbhN@p247.block1.tc4.state.ma.tiac.com>
Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> wrote:
> Abigail wrote:
> >
> > EXPR1 ?? EXPR2 would be EXPR1 if EXPR1 is defined, EXPR2 otherwise.
>
> That would appear to be a useful addition. But as Bart points out, it
> probably couldn't be called ??.
Why couldn't it be called ??? Er, make that...
Why couldn't it be called ?? ?
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 30 Apr 1999 01:04:12 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: What's wrong with this code?
Message-Id: <1dr1u5r.13nlrgn1rcns2bN@p247.block1.tc4.state.ma.tiac.com>
tfinn <tfinn@hotmail.com> wrote:
> $path=`find . -name myfile -print`; # find where myfile is
> push(@myfile, $path); # make $path string into an array
> $count=grep(/x/i, @myfile); # count number of times x occurs in path
> print $count; # print no. of times x occurs
@myfile contains only one element. $count will be either 0 or 1,
depending on whether $path contains no 'x's, or some 'x's.
I think you wanted
$path =~ tr/x//;
tr/// is explained in the perlop documentation.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 30 Apr 1999 11:38:26 +0800
From: "H.C. Chen" <hcchen@pobox.com>
Subject: why /g gets me wrong search results?
Message-Id: <925443985.15408@proxy2.acer.net>
Problem shown as below simple program and results,
Run: perl defect.pl data
Get different results for /i switch (correct) and
/ig switch (wrong), I'd like to know why? Thank you
in advance.
H.C. Chen
hcchen@pobox.com
=== defect.pl ========
#!perl -wn
print if m/defect/ig;
======================
Data m/defect/i; m/defect/ig;
------------ ------------- --------------
Defect 01 Defect 01 Defect 01
defect 02 defect 02 defEct 03
defEct 03 defEct 03 defEct 05
defect 04 defect 04 dEfect 07
defEct 05 defEct 05 defect 09
defect 06 defect 06
dEfect 07 dEfect 07
defEct 08 defEct 08
defect 09 defect 09
dEfect 10 dEfect 10
------------------------------
Date: Fri, 30 Apr 1999 01:04:14 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Why paranthesis change logical expression
Message-Id: <1dr1uty.1vo8gtg1vs0p2lN@p247.block1.tc4.state.ma.tiac.com>
Tad McClellan <tadmc@metronet.com> wrote:
> In list context the input operator reads _all_ of the
> remaining lines.
>
> The first two lines go into the list you provided, the
> rest of the lines are discarded.
It's a shame <> doesn't work more like split. It could have been
implemented to only read in as many lines as there are variables on the
LHS of the assignment. But maybe there would have been other issues
that way. Anyway, backwards compatibility would prevent such an
implementation now.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
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 5524
**************************************