[11684] in Perl-Users-Digest
Perl-Users Digest, Issue: 5284 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 2 12:04:56 1999
Date: Fri, 2 Apr 99 09:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 2 Apr 1999 Volume: 8 Number: 5284
Today's topics:
=~tr / / /; problem <cplee@bigfoot.com>
Re: =~tr / / /; problem (Larry Rosler)
Re: =~tr / / /; problem <jdf@pobox.com>
Re: Can you return hashes in subroutines? <All@n.due.net>
cant run perl from windows mikecard@my-dejanews.com
Re: cant run perl from windows <mickv@home.com>
Re: check to see if directory exists <jdf@pobox.com>
Re: constructing a list of hashes (Sean McAfee)
Re: Easy(?) Riddle <ddelikat@protix.com>
Re: Easy(?) Riddle (Larry Rosler)
Hashes as configuration files, appending to @INC to fin <agianni@acsu.buffalo.edu>
Help with Sorting Routine <crowe@darkspiral.com>
Re: How to include a module? <Eric.L.Winter.1@gsfc.nasa.gov>
Re: How to remove repeated signs ? <jdf@pobox.com>
Re: How to remove repeated signs ? (Larry Rosler)
Re: How to remove repeated signs ? (Tad McClellan)
Re: How to remove repeated signs ? (Larry Rosler)
Re: I need help (To Unnanounced) <K.Steven@cableinet.co.uk>
I need help <K.Steven@cableinet.co.uk>
Re: I need help <K.Steven@cableinet.co.uk>
Re: I need help <K.Steven@cableinet.co.uk>
Re: I need help <K.Steven@cableinet.co.uk>
Re: Newbie ques. re cgi script testing wedrawforyou@my-dejanews.com
Number of hash entries... <louis@trapezoid.com>
Re: Number of hash entries... <ddelikat@protix.com>
PERL coredumps as tie but not as object <jg221597@concorde.cosd.fedex.com>
Re: Reading a line (Tad McClellan)
Re: Retrieving info after POSTing from a perl script <bill@fccj.org>
Re: Send Mail <tonylabb@infonline.net>
Setting BEGINLIBPATH on OS/2 <chad13@bellsouth.net>
Re: Setting directory privs in NT <carvdawg@patriot.net>
SQL help please (newbie question) <rnichols@airnet.net>
Telnet+Router+Command+Output kamez@my-dejanews.com
The ultimate challenge <tazmen@primary.net>
variable say $var having value "123" not 123 <mpb@kemmunet.net.mt>
Re: variable say $var having value "123" not 123 (Sam Holden)
Re: variable say $var having value "123" not 123 (Bob Trieger)
Re: Washington DC Area Job in E-Commerce (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 01 Apr 1999 23:04:09 +0800
From: Cplee <cplee@bigfoot.com>
Subject: =~tr / / /; problem
Message-Id: <37038AE9.D380DE6B@bigfoot.com>
Dear Netter friend
I write a program which allow visitor input data
I would like to convert " to " in" by use =~ tr/\" /in/;
but not successful
please help
Andrea
------------------------------
Date: Fri, 2 Apr 1999 07:48:48 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: =~tr / / /; problem
Message-Id: <MPG.116e86bcad68daf5989818@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37038AE9.D380DE6B@bigfoot.com> on Thu, 01 Apr 1999 23:04:09
+0800, Cplee <cplee@bigfoot.com >says...
> I would like to convert " to " in" by use =~ tr/\" /in/;
'tr' is useful only for single-character manipulations. When you want
to replace a character or a string by a string, you need to use 's'.
s/"/ in/
may be what you want, but the problem description is a bit murky,
because your first use of " seems to mean literally a double-quote
character, while your second and third uses seem to mean string
delimiters.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 02 Apr 1999 11:32:39 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: cplee@bigfoot.com
Subject: Re: =~tr / / /; problem
Message-Id: <m3yakbx9so.fsf@joshua.panix.com>
Cplee <cplee@bigfoot.com> writes:
> I would like to convert " to " in" by use =~ tr/\" /in/;
> but not successful
the tr// operator works on individual characters; it does not work on
arbitrary expressions. You'll need to learn about the s// operator,
documented in perlop.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 02 Apr 1999 16:56:35 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: Can you return hashes in subroutines?
Message-Id: <7F6N2.21$gr5.133@news.rdc1.ct.home.com>
Krusty276 <krusty276@aol.com> wrote in message
news:19990401200801.06059.00000981@ng101.aol.com...
: I'm having mad problems. Like I say:
: %get_hash_value= &sub_make_hash(@some_list);
: sub sub_make_hash{
: (local %return_this_hash);
: XXXXX(all function making %return_this_hash )
: return (%return_this_hash);
: }
:
: When I do this I get nothing back for get_hash_value.
: but in the main part I can get the values for %return_this_hash, if I use
that
: name, but I declared it local to the subroutine.
: Are hashes always global.
: This is Perl5, active Perl for win32
I am not sure what the problem is except that local should be a my. Hashes
are not global, see below. Here is an example that returns a hash tested
under Win98, activestate perl.
#!/usr/local/bin/perl -w
use strict;
my @ingredients = qw(first beef second potatoes third onions);
sub make_hash {
my %hash;
print "Warning, uneven number of elements in array.\n" if (@_ % 2 != 0);
for(my $i=0; $i <= $#_;$i+=2) {
$hash{$_[$i]} = $_[$i+1];
}
return %hash;
}
my %hash = make_hash(@ingredients);
print "$_ ingredient: $hash{$_}\n" foreach keys %hash;
HTH
AmD
------------------------------
Date: Fri, 02 Apr 1999 15:58:24 GMT
From: mikecard@my-dejanews.com
Subject: cant run perl from windows
Message-Id: <7e2per$irh$1@nnrp1.dejanews.com>
hi there
i'm new to perl. i am making my first web site and i want to give it some
interactivity, so i am trying to get my cgi scripts working before i put them
online.
i downloaded the perl program that runs on windows. i made a script very
basic script called first.pl and i open up the perl program. from the
command line i type perl first.pl and hit enter and nothing happens. how do
i run perl from windows
mike cardeiro
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 02 Apr 1999 16:28:44 GMT
From: "Michael Villeneuve" <mickv@home.com>
Subject: Re: cant run perl from windows
Message-Id: <0f6N2.9108$w4.227469@news.rdc1.on.wave.home.com>
Hi Mike,
Please see below....
mikecard@my-dejanews.com wrote in message
<7e2per$irh$1@nnrp1.dejanews.com>...
>hi there
>
>i'm new to perl. i am making my first web site and i want to give it some
>interactivity, so i am trying to get my cgi scripts working before i put
them
>online.
>
>i downloaded the perl program that runs on windows. i made a script very
>basic script called first.pl and i open up the perl program. from the
>command line i type perl first.pl and hit enter and nothing happens. how
do
>i run perl from windows
>
>mike cardeiro
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
I suppose the first place you would want to check is your autoexec.bat file
for the following line:
SET PATH=C:\PERL\BIN;%PATH%
This is of course assuming that you installed Perl in the default location.
If this is already set up, try changing the first line of you script from
#!/usr/bin/perl
to
#! ../perl
since this isn't running on a UNIX machine. Let me know if this helps.
Good Luck!
Mike Villeneuve
------------------------------
Date: 02 Apr 1999 08:47:23 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Stephen M. Shelly" <stephen@chiso.com>
Subject: Re: check to see if directory exists
Message-Id: <m34smzyw0k.fsf@joshua.panix.com>
"Stephen M. Shelly" <stephen@chiso.com> writes:
> if (!(-d "x:\\home\\$Name"))
> print ("Need to create homedir for $Name");
>
> this is not working though.....
The reason that doesn't work is that it's not Perl. The if () {}
construct always takes a BLOCK, delimited by braces.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 02 Apr 1999 15:54:05 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: constructing a list of hashes
Message-Id: <xK5N2.979$9Y5.4653368@news.itd.umich.edu>
In article <37040753.1965F145@giss.nasa.gov>,
Jay Glascoe <jglascoe@giss.nasa.gov> wrote:
>foreach my $rec (@record) {
> $_ = 0 foreach values %$rec;
>}
ITYM:
foreach my $rec (@record) {
$rec->{$_} = 0 foreach keys %$rec;
}
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Fri, 02 Apr 1999 08:40:13 -0600
From: David Delikat <ddelikat@protix.com>
Subject: Re: Easy(?) Riddle
Message-Id: <3704D6CD.446B@protix.com>
Adam wrote:
>
> A seemingly easy problem, my code:
>
> #############################################
>
> $var1 = "$5.99";
>
> $var1 =~ /\$(.*)/;
I would change this line to:
$var1 =~ /\$(.*)$/;
the second $ causes the whole expression to be matched.
the '*' matches zero or more times.
-dav
--
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/
------------------------------
Date: Fri, 2 Apr 1999 08:08:24 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Easy(?) Riddle
Message-Id: <MPG.116e8b48ee7422d1989819@nntp.hpl.hp.com>
In article <3704D6CD.446B@protix.com> on Fri, 02 Apr 1999 08:40:13 -
0600, David Delikat <ddelikat@protix.com >says...
> Adam wrote:
...
> > $var1 =~ /\$(.*)/;
>
> I would change this line to:
>
> $var1 =~ /\$(.*)$/;
>
> the second $ causes the whole expression to be matched.
> the '*' matches zero or more times.
Dipping your toe back in? Good.
I regret to note that those two regexes are identical. The .* matches
as many non-"\n" characters as possible. The second $ designates the
end of the string not including a possible terminating "\n".
Putting in a leading ^ would in fact require the whole string to be
matched, with or without the trailing $ .
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 02 Apr 1999 11:04:17 -0500
From: Andrew S Gianni <agianni@acsu.buffalo.edu>
Subject: Hashes as configuration files, appending to @INC to find them
Message-Id: <3704EA81.BA033E07@buffalo.edu>
So I'm working on a large project and as part of the project we have
many configuration files to keep track of (one per user actually) rather
than using character delimited files, I've decided to store the info in
files as perl hashes and just require the file. With benchmarking, this
seems to take about a quarter the time of splitting and storing (which
didn't shock me or anything) Any comments on this?
The other issue is how to find these. We gots lots of users here and
because the file system will only hold so many files per directory,
we're breaking things down by creating a directory for each two letter
combination and putting storing configuration files based on the first
two letters of a username (so yah 676 directories) The question is,
what's the best way to find which directory a user's configuration
information is in. My idea was to unshift all those directories onto
@INC and then just do a
require "<username>" and let perl do the math. I benchmarked this
against something like /([a-z][a-z]).*/; require "$1/<username>"; and
using @INC seems to come out being something like a sixth of the time.
Are there any drawbacks to doing something like this? Would it cause
problems if I'm also requiring other stuff, because @INC is so large at
this point, or are the performance issues minimal?
Any commentary appreciated...
Andrew
--
Andrew Gianni - Developer "You are about to be told one
UNIX Guy/Juggler Extraordinaire more time that you are America's
SUNY at Buffalo ACS/CIT most valuable natural resource...
ph:(716)645-3587x7009 Have you seen what they do to
fx:(716)645-3588 valuable natural resources?"
agianni@buffalo.edu -Utah Phillips
http://www.cs.buffalo.edu/~agianni/
------------------------------
Date: Fri, 2 Apr 1999 10:11:35 -0600
From: "The Crowe" <crowe@darkspiral.com>
Subject: Help with Sorting Routine
Message-Id: <mjsvqOSf#GA.228@newstoo.hiwaay.net>
I need some help with a sorting routine. I've read the sections in
Learning Perl, Programming Perl and the Perl Cookbook and I still
can't figure out how to get this to work.
Below is my script, it works as is. Its reading from a db file that looks
like this.
crowe:2
userx:42
blah:19
etc:21
What I want is a DB file that looks like this
crowe:2:texthere:moretexthere
userx:42:something:somethingelse
blah:19:moreinfo:evenmoreinfo
etc:21:almost:done
The below sorts on Numerical order by the second field in the db file
and then prints the NAME , then Number.
However, I'd like to be able to use EACH field as a variable and print
it with corresponding info.. like $field1 $filed2 $field3 $field4.
All the examples in the books are for sorting files with 2 fields...
Can someone help me figure out how to do it with multiples???
Thanx in advance, below is the current code!
Crowe
::::::::::BEGIN CODE::::::::::::::
#!/usr/bin/perl
#
# Sort Routine was written by Alex Krohn ( thanx a million )
# This script is little more than the sort routine. It
# Just takes the Keyword Mod and makes a nice pretty table
# out of it. Thought this would be useful if you wanted
# to show it to your users, or just make it easier to read.
#
# This script uses The Search Log mod found at
# http://www.monster-submit.com/mods01.html
# Its easy to install and counts each search.
#
# Send Feedback to crowe@darkspiral.com
#
#
############################################################
print "Content-Type: text/html\n\n";
# If greater than this number the script will highlight those entries.
$targetnumba = 5 ;
# Print out the HTML that Appears BEFORE the sorting.
print "<HTML><HEAD><TITLE>Keyword List Html Build</TITLE></HEAD><body
link=red vlink=red bgcolor=ffffff text=000000><center>\n";
print "<br><br><a href=keyword.cgi>Build Keywords</a><br><br><font
size=1>Currently Highlighting words greater than <font
color=RED>$targetnumba</font> searches.</font> <br><br>\n";
print "<table bgcolor=C0C0C0 width=600 border=1 cellpadding=0
cellspacing=0><tr><td bgcolor=E0E0E0 valign=top>Keyword</td><td
bgcolor=E0E0E0 valign=top>Number of Searches</td></tr>\n";
# Open The DB, Sorts and Print out the Results.
# I run mine from the same dir as my Keywords.txt file, change it
# to your full path if you want people to have access to it.
open (DB, "<keywords.txt") or die $!;
while (<DB> ) {
chomp;
($name, $score) = split /:/;
$scores{$name} = $score;
}
close DB;
foreach $word (sort { $scores{$b} <=> $scores{$a} } keys %scores) {
if ($scores{$word} > $targetnumba)
{
print "<tr><td valign=top><font
color=RED><b><em>$word</font></em></b></td><td valign=top><font
color=RED><b><em>$scores{$word}</font></em></b></td></tr>\n";
}
else {
print "<tr><td valign=top><font color=blue>$word </font></td><td
valign=top><font color=BLUE>$scores{$word}</font></td></tr>\n";
}
}
# Prints the End of the HTML
print "</table><br><br><font size=1>Search Log Table-izer by
Crowe\@darkspiral.com</font></center></body></html>\n";
------------------------------
Date: Fri, 2 Apr 1999 08:06:12 -0500
From: "Eric Winter" <Eric.L.Winter.1@gsfc.nasa.gov>
Subject: Re: How to include a module?
Message-Id: <7e2fea$ofq@post.gsfc.nasa.gov>
Mandeep,
Use the 'use lib' pragma in your script prior to the require (why use
require instead of use, BTW?). Alternatively, set your PERL5LIB environment
variable to include the root of the Perl library directory tree which
contains your module.
HTH,
Eric
Mandeep Singh <singh_mandeep@jpmorgan.com> wrote in message
news:3703AF3F.64BFB81F@jpmorgan.com...
>
> Hello,
>
> I want to include a module (CGI_Lite.pm) in my script.
> The problem is I don't want it to be installed i.e with Perl.
> I have the module in my local directory.
> How would I include it in my script?
> -----------------------------------------------------------
>
> #!/usr/local/bin/perl
>
> require "../perl_lib/CGI_Lite.pm";
> push (@INC, "/tmp/perl_lib"); #where CGI_Lite.pm resides
> push (@INC, ".");
> use CGI_Lite;
>
> print "Content-type: text/plain", "\n\n";
> print "This is an upload test";
>
> -----------------------------------------------------------
>
>
>
>
> The error I get is:
>
> Can't locate CGI_Lite.pm in @INC at upload.pl line 5.
> BEGIN failed--compilation aborted at upload.pl line 5.
>
> tia,
> Mandeep
>
------------------------------
Date: 02 Apr 1999 09:27:28 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Robert" <beton@topnet.pl>
Subject: Re: How to remove repeated signs ?
Message-Id: <m31zi3yu5r.fsf@joshua.panix.com>
"Robert" <beton@topnet.pl> writes:
> ABBA -> ABA
> WOOOOOOOOOOOOOOOOOOOOW -> WOW
> ?
perldoc perlop
search for the tr/SEARCHLIST/REPLACEMENTLIST/cds operator. You want
the /s modifier.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Fri, 2 Apr 1999 06:43:27 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to remove repeated signs ?
Message-Id: <MPG.116e776e21bca5d7989817@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <Ci%M2.4780$_u5.636588@news.tpnet.pl> on Fri, 02 Apr 1999
08:34:42 GMT, Robert <beton@topnet.pl >says...
> for example how to:
>
> ABBA -> ABA
> WOOOOOOOOOOOOOOOOOOOOW -> WOW
>
> etc.
Here are two ways:
s/(.)\1+/$1/gs;
tr/\x00-\xFF//s;
#!/usr/local/bin/perl -w
use Benchmark;
timethese(1 << (shift || 0), {
S => sub { (my $x = 'WOOOOOOOWWOOOOOOOOW') =~ s/(.)\1+/$1/gs },
Tr => sub { (my $x = 'WOOOOOOOWWOOOOOOOOW') =~ tr/\x00-\xFF//s },
});
__END__
Benchmark: timing 262144 iterations of S, Tr...
S: 30 wallclock secs (29.82 usr + 0.00 sys = 29.82 CPU)
Tr: 4 wallclock secs ( 3.35 usr + 0.00 sys = 3.35 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 2 Apr 1999 03:08:17 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to remove repeated signs ?
Message-Id: <htt1e7.6sb.ln@magna.metronet.com>
Robert (beton@topnet.pl) wrote:
: for example how to:
: ABBA -> ABA
: WOOOOOOOOOOOOOOOOOOOOW -> WOW
squish consecutive letter characters:
tr/a-zA-Z/a-zA-Z/s;
squish consecutive characters (or character sequences):
1 while s/(.)\1/$1/;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 2 Apr 1999 08:34:09 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to remove repeated signs ?
Message-Id: <MPG.116e915e86439ee998981a@nntp.hpl.hp.com>
In article <htt1e7.6sb.ln@magna.metronet.com> on Fri, 2 Apr 1999
03:08:17 -0500, Tad McClellan <tadmc@metronet.com >says...
> squish consecutive letter characters:
>
> tr/a-zA-Z/a-zA-Z/s;
The repeated character set is a supererogatory superfluous redundant
tautology.
> squish consecutive characters (or character sequences):
>
> 1 while s/(.)\1/$1/;
What an odd way to write the 'g' modifier! (As I posted, the 's' method
is hideously slower than the 'tr' method. But 'tr' won't work on
character sequences, as you say.)
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
If you put a space character after the two dashes, properly brought-up
newsreaders won't put your sig into the quoted response. (One of the
silliest conventions of all time -- an invisible trailing space
character with special semantics!)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 2 Apr 1999 16:42:44 +0100
From: "Ken" <K.Steven@cableinet.co.uk>
Subject: Re: I need help (To Unnanounced)
Message-Id: <7e2otq$a5f$1@news1.cableinet.co.uk>
Hi.
Could you let me know which browser you are using as I noticed that the
script crapped out at the place I was expecting it to.
For some reason, it lost the path variables. :(
ken
------------------------------
Date: Fri, 2 Apr 1999 15:33:32 +0100
From: "Ken" <K.Steven@cableinet.co.uk>
Subject: I need help
Message-Id: <7e2ks2$6c0$1@news1.cableinet.co.uk>
Hi all.
I have a few scripts running together which create a basic web site. All
seems to work fine with my versions of IE(4.72) and Netscape Navigator 4.04
and Communicator 4.04 but i have been told that they don't work in IE 4.71.
Bit of an odd problem......
When I run the script, it follows the paths by variables but when the script
is run under IE 4.71 it loses the paths. Any ideas how this can happen???
I would really appreciate it if some of you could log-on and try the script
out for me and give some feedback on them i.e. which browser are you using,
did the damn thing work!? and any other comments you may have.
It's at: http://detour.co.uk/alkazar/
UID alkazar
PASSWD preview
Thanks in advance to anyone who takes the time out on this (UK) Bank Holiday
Ken
K.Steven@detour.co.uk
------------------------------
Date: Fri, 2 Apr 1999 16:17:19 +0100
From: "Ken" <K.Steven@cableinet.co.uk>
Subject: Re: I need help
Message-Id: <7e2ne6$8j8$1@news1.cableinet.co.uk>
Should have mentioned, it is the Site Creator which is giving me problems.
Ken.
------------------------------
Date: Fri, 2 Apr 1999 16:40:36 +0100
From: "Ken" <K.Steven@cableinet.co.uk>
Subject: Re: I need help
Message-Id: <7e2opq$a3g$1@news1.cableinet.co.uk>
I've just noticed, it wont accept spaces in the user name ;( I'll fix that
soon but if you could please just use one word for the username for now.
Thanks Invited Tester!
Ken
------------------------------
Date: Fri, 2 Apr 1999 16:45:35 +0100
From: "Ken" <K.Steven@cableinet.co.uk>
Subject: Re: I need help
Message-Id: <7e2p35$aa6$1@news1.cableinet.co.uk>
I realise that this may seem like a backdoor into advertising the preview
but it really aint!
We will be launching the service soon but not before I get these damn
scripts to work!!
If I could just find out which browsers they cack out on it would be a great
help.
Ken
------------------------------
Date: Fri, 02 Apr 1999 09:04:48 GMT
From: wedrawforyou@my-dejanews.com
Subject: Re: Newbie ques. re cgi script testing
Message-Id: <7e217c$vq0$1@nnrp1.dejanews.com>
Thanks to all those who responded to my query,Sam G.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 02 Apr 1999 09:58:39 -0500
From: Louis Zuckerman <louis@trapezoid.com>
Subject: Number of hash entries...
Message-Id: <3704DB1F.ECD52FD0@trapezoid.com>
Is there a way to have Perl return how many key/value pairs are in a
hash? I know that accessing an array like a csalar will do this, but it
doesn't seemto work for hashes.
Thank you,
Louis Zuckerman
louis@trapezoid.com
------------------------------
Date: Fri, 02 Apr 1999 09:23:33 -0600
From: David Delikat <ddelikat@protix.com>
Subject: Re: Number of hash entries...
Message-Id: <3704E0F5.FF6@protix.com>
Louis Zuckerman wrote:
>
> Is there a way to have Perl return how many key/value pairs are in a
> hash? I know that accessing an array like a csalar will do this, but it
> doesn't seemto work for hashes.
>
> Thank you,
> Louis Zuckerman
> louis@trapezoid.com
how about scalar(keys %hash)?
perl -e 'print scalar(keys %ENV)'
-->
18
-dav
PS. Hey Larry, I took your advice, cool.
--
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/
------------------------------
Date: Fri, 02 Apr 1999 08:54:20 -0700
From: "James L. Gordon" <jg221597@concorde.cosd.fedex.com>
Subject: PERL coredumps as tie but not as object
Message-Id: <3704E82C.9F097D93@concorde.cosd.fedex.com>
I'm inheriting from a module that's implementing a hash tie and it (the
original module) works quite wonderfully. If I create a new instance of
my module (or just use the value returned from tie or tied), then I can
call FETCH and STORE and all the rest and it all works great. If I use
the tied hash however, it gets a bus error and dumps core. I'm using
perl -w and use strict (of course), but I get no warnings or errors.
my(%assoc);
my($obj) = tie %assoc, 'MyDir::MyClass';
These work all day long:
$obj->FETCH($key);
$obj->STORE($key,$value);
tied(%assoc)->FETCH($key);
(tied %assoc)->STORE($key,$value);
But these will crash:
$assoc{$key};
$assoc{$key} = $value;
The value returned by the first tie is another tie, but even if it's
just a string, it still crashes. In fact, even if I remove everything
and only overload the FETCH it crashes (if I overload nothing, it
works). I know we can inherit from tie classes, because that's what
Tie::Hash and Tie::StdHash are for, right? Besides, if I use it in an
OO way instead of as a tie it works perfectly.
The only thing my subclass does is change the keys using Date::Manip.
So I wondered if there was some rule against doing that, but I couldn't
see anyway that would be important and I've never read anything like
that.
Maybe one of the gurus can explain this. :-) If you need more info,
feel free to ask. I don't know that it's important, but I'm inheriting
from AsciiDB::TagFile and it's for a scheduling/calendar type object
(hence the use of Date::Manip). I would hate to write it all myself,
when there's already this object that I can inherit from that just needs
key translation.
Thanks for any help.
--
James L. Gordon
------------------------------
Date: Thu, 1 Apr 1999 20:19:12 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading a line
Message-Id: <gu51e7.jpb.ln@magna.metronet.com>
Tobias Weihmann (epyx.cjb.net@t-online.de) wrote:
: I am new to perl and would like to know if there is an
: easier way of reading lines from STDIN than to use
: the module Term::ReadKey as I do currently.
$line = <STDIN>; # read a line
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 02 Apr 1999 04:30:00 -0500
From: "Bill Jones" <bill@fccj.org>
Subject: Re: Retrieving info after POSTing from a perl script
Message-Id: <37048e25.0@usenet.fccj.cc.fl.us>
In article <37042D0B.76B5439F@BLAHNOSPAMBLAHxwebdesign.com>, Ketan Patel
<ketanp@BLAHNOSPAMBLAHxwebdesign.com> wrote:
> I've been fiddling around with this code, but I keep getting an error:
>
> my $response = $ua->request(POST
> "http://www.bu.edu/link/bin/uiscgi_studentlink",
> [Semester => 'FALL 99',
> CollegeCd => 'CAS',
> Dept => 'CS',
> Course => '113 ',
> Section => 'A2',
> MaxGetNbr => '1',
> StartKey => 'FALL 99CASCS113 A2',
> applpath => 'univschr.pl']);
>
Why did you go from using " to using ' on that POST statement ?
Just wondering,
-Sneex- :]
________________________________________________________________________
Bill Jones | FCCJ Webmaster | http://www.fccj.org/cgi/mail?webmaster
FCCJ | 501 W State St | Jacksonville, FL 32202 | 1 (904) 632-3089
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: Fri, 02 Apr 1999 07:59:10 -0500
From: Tony Labbiento <tonylabb@infonline.net>
Subject: Re: Send Mail
Message-Id: <3704BF1E.1D76CFF4@infonline.net>
You can always use the Net::SMTP module. I use this with my ActiveState
Perl (Win95). Here is a sample program:
use Net::SMTP;
$smtp = Net::SMTP->new('207.41.2.2'); #substitute your ISP's mail server
$smtp->mail('your_to_address@domain.com'); #this is the From field
$smtp->to('your_to_address@domain.com'); #your To field.
$smtp->data();
$smtp->datasend("Subject: Test\n");
#$smtp->datasend("From: your_address\@your_domain.net\n");
$smtp->datasend("To: your_to_address\@your_domain.net\n");
$smtp->datasend("\n");
$smtp->datasend("A simple test message\n");
$smtp->dataend();
$smtp->quit;
I hope this helps!
Greg Griffiths wrote:
>
> Dear All,
> everytime I try and use the sendmail prog that is listed in the PERL
> faq's :
>
> $mailprog = '/usr/lib/sendmail -oi -t -odq';
> open (MAIL, "|$mailprog") || die "Can't open $mailprog!\n";
> print MAIL "To: $To ($ToEmail)\n";
> print MAIL "Reply-to: CILP Staff Member ($FromEmail)\n";
> print MAIL "Subject: $Subject\n\n";
> print MAIL "$From on behalf of The Christian Internet Links Project
> sends you this Message \n";
> print MAIL "$Message \n";
> print MAIL "Christian Internet Links Project \n";
> print MAIL "http://www.aber.ac.uk/~scty12/links/";
> close (MAIL);
>
> I get the message
>
> Bad Command or File Name
>
> Any idea why, I assume that it is because the command is a Unix command
> and I'm using the Win32 PERL, is there an alternative without using any
> fancy Perl modules as my server won't llow any extras ?
--
****************************************
* Tony Labbiento *
* Infinity Online, Inc. *
****************************************
------------------------------
Date: Fri, 02 Apr 1999 09:10:38 -0500
From: Chad Holliday <chad13@bellsouth.net>
Subject: Setting BEGINLIBPATH on OS/2
Message-Id: <3704CFDE.D76A91B8@bellsouth.net>
Hello,
How would one go about modifying the extended library seach paths
BEGINLIBPATH and ENDLIBPATH on OS/2, such that subsequent system calls
will use the new path? Since these variables are not true environment
variables, in the sense that PATH and others are, the following cannot
be used:
$ENV{'BEGINLIBPATH'} = <some_new_path> . $ENV{'BEGINLIBPATH'}
The only way I have found to do it is prepend any system call with a
"set BEGINLIBPATH" statement, which isn't very clean. Is there a better
way? Perhaps some OS/2 specific module allowing access to these
variables?
Also, does anyone know where there is some good documentation for Perl
on OS/2 that may explain some of these issues and how they are handled?
Thanks,
Chad
------------------------------
Date: Fri, 02 Apr 1999 06:40:08 +0100
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: Setting directory privs in NT
Message-Id: <37045838.DE04260B@patriot.net>
If you want a pure Perl solution, try Dave Roth's
Win32::Perms module. I'm using it now, and it's fantastic!!
Martin Doxsey wrote:
> Alternatively you could use the cacls or xcacls NT commands. I think that
> the first is included with NT and the second comes with the NT Resource Kit.
>
> Martin Doxsey
------------------------------
Date: Fri, 2 Apr 1999 07:40:28 -0600
From: "R&K" <rnichols@airnet.net>
Subject: SQL help please (newbie question)
Message-Id: <vehK$4Qf#GA.219@newstoo.hiwaay.net>
Could somebody please point me to some internet resources using perl with an
sql database. Tutorials preferably.
Thanks alot
------------------------------
Date: Fri, 02 Apr 1999 14:28:21 GMT
From: kamez@my-dejanews.com
Subject: Telnet+Router+Command+Output
Message-Id: <7e2k5s$e3a$1@nnrp1.dejanews.com>
i wanna telnet to a router, checkout its interfaces status, and if they're
down , email the network administrator.
But i need to know how to get the result of my command on the router prompt
,in a file , that i can send on email ?
what that implies technically in terms of instructions, since the script
has to do all that automatically : connection + command + output in a file +
email.
Thanks a lot for you help guys.
Khalid.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 02 Apr 1999 08:08:07 -0600
From: William Tammen <tazmen@primary.net>
Subject: The ultimate challenge
Message-Id: <3704CF46.FBE6F4D2@primary.net>
I need a way to design a link that will query say like
.../cgi-bin/forum/forum.pl?preview and post a form at the same time. I
know all about links only being able to use get method and I know about
sending values with a query but that just does not cut it with text
areas in the form do to the get methods length limits. Now the normal
post method of a form submit will do the action of
.../cgi-bin/forum/forum.pl?preview and then submit to that url the form
data directly to stdin of the cgi now there has to be a way of doing
this using javascript or java to mimic this exact process via a true
link so that I can use the link as a perameter in a javascript function
which will load the resulting page sent back by the cgi into a div tag
layer on my site. This function buffers the page then transfers it to
said div layer to perform cross browser. The function buffers using
iframe for IE and a layer in Netscape. This works fine on any queried
responses from the cgi. I just can't sent text area data in a standard
query value link. This problem must be solved since dhtml can not be
integrated with cgi due to the natural static nature of cgi responses
wiping out the page they where called from. Now Dan Stienman has began
attempts at working out this problem but he has only implemented a cgi
communication example which handles a radio button form. The ultimate
goal is to do this with all form values especially text fields and text
areas and combinations of them all in the form. If anyone is
interested Dan is the true dhtml guru of the net, perhaps the best kept
secret of the net.
The url to his main page is
http://www.dansteinman.com/dynduo/
and the url to the cgi communication is
http://www.dansteinman.com/dynduo/cgicomm/cgicomm.html
Now those who love a cgi challenge take his radio form example and
corresponding perl script and add text fields, text areas, drop down
select menu, and check boxes, and get it to display the data posted back
to the pages div layer. Will take adapting the javascript function
submitform so javascript and perl talent needed. Dan is busy working on
IE5 compatibility and I am not having any luck. Thanks in advance Bill
------------------------------
Date: Fri, 02 Apr 1999 14:28:38 +0200
From: Mark Pace Balzan <mpb@kemmunet.net.mt>
Subject: variable say $var having value "123" not 123
Message-Id: <3704B7F6.376B@kemmunet.net.mt>
Hello All
If this is faq, forgive me but i'm not a perl wizard
suppose you have a variable $var="12345"
this will make the value of $var be 12345
so far so good now for the sticky bit.
what if you want to make the value of $var be "12345" not 12345 ?
so you can write "12345" to your file not 12345 ?
ps value of $var is being assigned from a fill in www form.
tanx a million
_______________________________________________________________
Mark Pace Balzan
mpb@kemmunet.net.mt
Some folks just sit and think, others just sit
------------------------------
Date: 2 Apr 1999 13:23:48 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: variable say $var having value "123" not 123
Message-Id: <slrn7g9h74.q43.sholden@pgrad.cs.usyd.edu.au>
Mark Pace Balzan <mpb@kemmunet.net.mt> wrote:
>what if you want to make the value of $var be "12345" not 12345 ?
>so you can write "12345" to your file not 12345 ?
$var = '"12345"';
--
Sam
Basically, avoid comments. If your code needs a comment to be
understood, it would be better to rewrite it so it's easier to
understand. --Rob Pike
------------------------------
Date: Fri, 02 Apr 1999 13:40:31 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: variable say $var having value "123" not 123
Message-Id: <7e2h91$dcb$1@ash.prod.itd.earthlink.net>
mpb@kemmunet.net.mt wrote:
@>Hello All
@>
@>If this is faq, forgive me but i'm not a perl wizard
@>
@>suppose you have a variable $var="12345"
@>this will make the value of $var be 12345
@>so far so good now for the sticky bit.
@>
@>what if you want to make the value of $var be "12345" not 12345 ?
@>so you can write "12345" to your file not 12345 ?
there are atleast 4 ways to do this:
$var = '"12345"';
$var = "\"12345\"";
$var = q("12345");
$var = qq("12345");
Check out the quote operators in perlop.
Good luck,
Bob Trieger
sowmaster@juicepigs.com
------------------------------
Date: Fri, 2 Apr 1999 04:36:17 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Washington DC Area Job in E-Commerce
Message-Id: <h232e7.6sb.ln@magna.metronet.com>
Craig Vitter (craig@vitter.com) wrote:
: Hey, somebody asked me today where we could find some experienced coders for
: our e-commerce development group and I thought... hey, we need another Perl
: person on board so here it goes, my lame attempt at writing an employment
: screening test...
: #!/usr/bin/perl
# see if there is a bug on the first line
if ( m@^#!\S*bin/perl(.*)@ ) {
die "Sorry, can't hire you. Thank you for your time.\n"
unless $1 =~ /-\w*w/;
}
# see if there is a bug on the second line
die "Sorry, can't hire you. Thank you for your time.\n"
unless /use\s+strict\s*;/;
:-)
: $your_points = 0;
: $extra_credit = 0;
: open(FILE, "you.db") || die "A very bad sign, maybe you should try again.\n";
: while(<FILE>) {
: $record = $_;
: chomp($record);
: ($experience, $attitude, $languages, $databases, $ecom_packages)
: = split(/\t/, $record);
^^^^^^ that should be an underscore
$your_points-- if (unnecessary copying to temporary variable);
: if($languages =~ /java/i || $languages =~ /c/ || $languages =~
^^
^^
: /javascript/) {
: $your_points++;
: }
You want to give points for "Visual Basic" and "Pascal" too then?
Maybe you wanted /\bc\b/i instead?
: if($languages !~ /sql/i || $languages !~ /html/i) {
: $your_points = $your_points - 2;
: }
Markup languages count the same as programming and query languages?
Seems a strange weight, as a fixed markup language like HTML
can be picked up by any competent programmer in a day or two.
I don't think you can get competence in SQL that quickly...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 5284
**************************************