[18562] in Perl-Users-Digest
Perl-Users Digest, Issue: 730 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 20 18:05:42 2001
Date: Fri, 20 Apr 2001 15:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <987804314-v10-i730@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 20 Apr 2001 Volume: 10 Number: 730
Today's topics:
ActivePerl problem <cochise@sky.net>
Re: ActivePerl problem <tad@geekmasters.com>
Re: ActivePerl problem <bart.lateur@skynet.be>
Re: Anyone know how i can extract <Title> </title> from <bart.lateur@skynet.be>
Re: Calling a subroutine with two Hashes Of Hashes <jesse@uchicago.edu>
Re: Calling an ASP from a Perl CGI <jmoon@uab.edu>
Re: Combining hierarchical and alphabetical sorting? <dharding@uiuc.edu>
cutting columns from a text file <taskiran@ecn.purdue.edu>
Re: cutting columns from a text file (Dave Murray-Rust)
Re: cutting columns from a text file (Craig Berry)
Re: cutting columns from a text file <taskiran@ecn.purdue.edu>
Re: FAQ 9.7: How do I fetch an HTML file? <jboes@nexcerpt.com>
Re: GD/TrueType weirdness (CODE SAMPLE) <dharding@uiuc.edu>
Re: GD/TrueType weirdness (CODE SAMPLE) <bcoon@sequenom.com>
Re: GD/TrueType weirdness. <dharding@uiuc.edu>
Re: Grabbing file date and time (Cosmic Cruizer)
Re: Idiom: the expression of a copied & substituted str (John Joseph Trammell)
Is it a hash or not? <glenn@surveystar.com>
Re: Is it a hash or not? <krahnj@acm.org>
Re: Is it a hash or not? <glenn@surveystar.com>
Re: Is it a hash or not? <dperham@dperham.eng.tvol.net>
Re: Is it a hash or not? <krahnj@acm.org>
Re: Is it a hash or not? <bart.lateur@skynet.be>
Re: List comparison <jboes@nexcerpt.com>
Re: LWP, getting the default index page name from a web (Craig Berry)
m$ sql server access from perl <timour@pivotaldynamics.com>
Re: m$ sql server access from perl <projectobjects@earthlink.net>
Re: m$ sql server access from perl <bart.lateur@skynet.be>
Re: Net::POP3 <mnm@mnm.com>
Re: Net::SMTP <gellyfish@gellyfish.com>
Re: Perl & PHP programmer available. (David H. Adler)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 20 Apr 2001 13:28:52 -0500
From: Steve <cochise@sky.net>
Subject: ActivePerl problem
Message-Id: <3AE07FE4.9D7FABFD@sky.net>
I just installed ActivePerl on my Win98 computer.
I can run programs (ie: "Hello World", etc.) from the command line OK.
When I try and run a program (program.cgi or program.pl) from my browser
... both Explorer and Netscape try to Open the file rather than run the
script.
Why won't something simple like this (which runs fine on-line) send the
.html line to my browser?
#!/usr/local/bin/perl
require "cgi-lib.pl";
print &PrintHeader;
print &HtmlTop;
print "Hello world!!";
print &HtmlBot;
If this is really a Windows questions, sorry.
Steve
------------------------------
Date: Fri, 20 Apr 2001 14:28:16 -0600
From: Tad Pepperling <tad@geekmasters.com>
To: Steve <cochise@sky.net>
Subject: Re: ActivePerl problem
Message-Id: <3AE09BE0.7197B840@geekmasters.com>
Now download and install Apache and it will work.. You need a web
server..
Tad Pepperling
WebTech
GeekMasters.com
Steve wrote:
>
> I just installed ActivePerl on my Win98 computer.
>
> I can run programs (ie: "Hello World", etc.) from the command line OK.
>
> When I try and run a program (program.cgi or program.pl) from my browser
> ... both Explorer and Netscape try to Open the file rather than run the
> script.
>
> Why won't something simple like this (which runs fine on-line) send the
> .html line to my browser?
>
> #!/usr/local/bin/perl
>
> require "cgi-lib.pl";
>
> print &PrintHeader;
> print &HtmlTop;
>
> print "Hello world!!";
>
> print &HtmlBot;
>
> If this is really a Windows questions, sorry.
>
> Steve
------------------------------
Date: Fri, 20 Apr 2001 21:28:11 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: ActivePerl problem
Message-Id: <au91etkf49fvc0d3dh31m5dsiqanlrq176@4ax.com>
Steve wrote:
>I can run programs (ie: "Hello World", etc.) from the command line OK.
>
>When I try and run a program (program.cgi or program.pl) from my browser
>... both Explorer and Netscape try to Open the file rather than run the
>script.
Of course they do. It's because you don't have a web server. If you
didn't have perl, the IndigoPerl distribution (<www.indigostar.com>)
comes with a binary install of Apache. But, since you have, try this:
<http://httpd.apache.org/dist/httpd/binaries/win32/>. I haven't done
this myself, I use IndigoPerl.
When you installed and started up Apache, point your browser to
<http://localhost>. That should get you started. There likely will be
some sample CGI scripts as well, which will likely be in a decidated
directory, commonly called "cgi-bin". But as I said: I haven't taken
this route myself, and I don't know the details for this distribution.
--
Bart.
------------------------------
Date: Fri, 20 Apr 2001 18:52:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Anyone know how i can extract <Title> </title> from html source
Message-Id: <1a11et0cr7c5oah8al7qau7cnrlq458lpd@4ax.com>
Chile wrote:
>I have the html source but i am not very good at those =~ yet so if anyone
>knows how i could extract the webpages title in between the <title> </title>
>tags then it would be great.
Check out HTML::HeadParser (-> HTML::Parser).
SYNOPSIS
require HTML::HeadParser;
$p = HTML::HeadParser->new;
$p->parse($text) and print "not finished";
$p->header('Title') # to access <title>....</title>
DESCRIPTION
The *HTML::HeadParser* is a specialized (and lightweight)
*HTML::Parser* that will only parse the <HEAD>...</HEAD> section
of an HTML document.
--
Bart.
------------------------------
Date: Fri, 20 Apr 2001 15:11:55 -0500
From: Jesse James Jensen <jesse@uchicago.edu>
Subject: Re: Calling a subroutine with two Hashes Of Hashes
Message-Id: <3AE0980B.F477A1F1@uchicago.edu>
Ren Maddox wrote:
>
> On Thu, 19 Apr 2001, rogerp@ipass.net wrote:
>
> > # Tell Perl to help me
> > use diagnostics -verbose;
> > use strict 'refs';
> > use strict 'subs';
>
> What, no strict 'vars' ??
He probably wanted it to shut up while he tried different things to make
it work.
------------------------------
Date: Fri, 20 Apr 2001 13:38:19 -0500
From: "Jim" <jmoon@uab.edu>
Subject: Re: Calling an ASP from a Perl CGI
Message-Id: <9bpvmr$cs$1@SonOfMaze.dpo.uab.edu>
> I have to call a page at the enf of a Perl CGI (in the specific
> case is an ASP, but I think HTML is the same).
>
> How can I do?
I'm here with the same question.
Can someone help both of us?
Thanks!
Jim
------------------------------
Date: Fri, 20 Apr 2001 13:20:56 -0500
From: Dan Harding <dharding@uiuc.edu>
Subject: Re: Combining hierarchical and alphabetical sorting?
Message-Id: <3AE07E08.F52F51CE@uiuc.edu>
Tad McClellan wrote:
> >Assume data
> ^^^^^^
>
> Why?
>
> Why not *give* us the data that you used?
>
> (that is, in fact, why I did not break my usual policy as I had
> started to do. When I went to work on it, I didn't have any data
> and was disinclined to generate some, so I just deleted the email.
> )
You are correct; my bad. I assumed the same data format as the original
thread, but I was not obvious in stating such (and I didn't stop
to think that my providing specific data would have made it easier for
those potentially trying to test/help).
> >========== BEGIN CODE =============
Solution worked like a charm. Thanks again!
-Dan
------------------------------
Date: Fri, 20 Apr 2001 13:51:20 -0500
From: CuneytTaskiran <taskiran@ecn.purdue.edu>
Subject: cutting columns from a text file
Message-Id: <3AE08528.A72D3E0B@ecn.purdue.edu>
Hi,
I want to code a simpler version of the UNIX cut command.
Currently I have:
@mask = (1,1,0,0,0,0,0,0,0,0,0,0,0,0);
while( <INPUTFILE> ) {
chop;
@elements = split;
for( $i=0; $i<14; $i++ ) {
push( @line, $elements[$i] ) if $mask[$i];
}
push( @fileLines, @line ) ;
}
which tries to extract the cols that are 1 in the mask. Problem is this
is way too
slow on large files (>15000 lines).
Is there an easier way of doing this?
Thanks,
Cuneyt
------------------------------
Date: Fri, 20 Apr 2001 21:28:45 +0100
From: dave@mo-seph.com (Dave Murray-Rust)
Subject: Re: cutting columns from a text file
Message-Id: <slrn9e16vt.jen.dave@flop.localnet>
On Fri, 20 Apr 2001 13:51:20 -0500,
CuneytTaskiran <taskiran@ecn.purdue.edu> wrote:
>Hi,
>
>I want to code a simpler version of the UNIX cut command.
>Currently I have:
>
> @mask = (1,1,0,0,0,0,0,0,0,0,0,0,0,0);
> while( <INPUTFILE> ) {
> chop;
I tend to use chomp, as it only removes newlines (or whatever is in
$/)
> @elements = split;
> for( $i=0; $i<14; $i++ ) {
> push( @line, $elements[$i] ) if $mask[$i];
> }
> push( @fileLines, @line ) ;
Here you are making one large array full of all the lines in the file.
Is this what you want? If not, you could print each line as you go
along - this will probably speed things up a lot.
HTH, Dave
--
------------------------------
Date: Fri, 20 Apr 2001 21:03:27 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: cutting columns from a text file
Message-Id: <te190vm8larh5b@corp.supernews.com>
CuneytTaskiran (taskiran@ecn.purdue.edu) wrote:
: I want to code a simpler version of the UNIX cut command.
: Currently I have:
:
: @mask = (1,1,0,0,0,0,0,0,0,0,0,0,0,0);
I would make @mask list the column numbers you want instead, like this:
@mask = (0, 1);
: while( <INPUTFILE> ) {
: chop;
chomp is preferred. See the doc.
: @elements = split;
: for( $i=0; $i<14; $i++ ) {
: push( @line, $elements[$i] ) if $mask[$i];
: }
: push( @fileLines, @line ) ;
Using my definition of mask, the code above reduces to:
push @fileLines, (split)[@mask]
: }
Note by the way that, using your algorithm, all the columns from all the
lines end up strung together in one flat list, @fileLines...is that really
what you want?
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: Fri, 20 Apr 2001 16:26:50 -0500
From: Cuneyt M Taskiran <taskiran@ecn.purdue.edu>
Subject: Re: cutting columns from a text file
Message-Id: <3AE0A99A.636B778C@ecn.purdue.edu>
Hi,
What I actually want is to have each row to be an element of @fileLines,
i.e.,
if the file contains
a1 a2 a3
b1 b2 b3
and if we have @mask = (0, 1) then I want to have $fileLines[0]=(a1,a2) and
$fileLines[1]=(b1,b2).
Thanks,
Cuneyt
Craig Berry wrote:
>
> I would make @mask list the column numbers you want instead, like this:
>
> @mask = (0, 1);
>
>
> : @elements = split;
> : for( $i=0; $i<14; $i++ ) {
> : push( @line, $elements[$i] ) if $mask[$i];
> : }
> : push( @fileLines, @line ) ;
>
> Using my definition of mask, the code above reduces to:
>
> push @fileLines, (split)[@mask]
>
> : }
>
> Note by the way that, using your algorithm, all the columns from all the
> lines end up strung together in one flat list, @fileLines...is that really
> what you want?
>
> --
> | Craig Berry - http://www.cinenet.net/~cberry/
> --*-- "When the going gets weird, the weird turn pro."
> | - Hunter S. Thompson
------------------------------
Date: Fri, 20 Apr 2001 15:52:26 -0400
From: Jeff Boes <jboes@nexcerpt.com>
Subject: Re: FAQ 9.7: How do I fetch an HTML file?
Message-Id: <3AE0937A.31305AE7@nexcerpt.com>
PerlFAQ Server wrote:
> How do I fetch an HTML file?
>
> # or print ASCII from HTML from a URL
> # also need HTML-Tree package from CPAN
> use LWP::Simple;
> use HTML::Parser;
> use HTML::FormatText;
> my ($html, $ascii);
> $html = get("http://www.perl.com/");
> defined $html
> or die "Can't fetch HTML from http://www.perl.com/";
> $ascii = HTML::FormatText->new->format(parse_html($html));
> print $ascii;
>
I believe this FAQ needs to be updated. When I cut and paste this code,
I get
Undefined subroutine &main::parse_html called at lwp.pl line 11.
I'm using Perl 5.6.1, LWP::Simple v 1.34, HTML::Parser v 3.21, and
HTML::FormatText v 1.18.
--
Jeff Boes vox 616.226.9550
Database Engineer fax 616.349.9076
Nexcerpt, Inc. jboes@nexcerpt.com
------------------------------
Date: Fri, 20 Apr 2001 14:00:33 -0500
From: Dan Harding <dharding@uiuc.edu>
Subject: Re: GD/TrueType weirdness (CODE SAMPLE)
Message-Id: <3AE08751.E0AB3437@uiuc.edu>
Here's the PERL code I'm running.
Thanks,
-Dan
================ BEGIN SAMPLE ======================
#!/usr/bin/perl -w
use GD;
$textstring = "Hello";
$im = new GD::Image(100,100);
$background = $im->colorAllocate(255,255,238);
@bounds =
GD::Image->stringTTF($background,"/INETPUB/FONTS/AVGARDMI.TTF",10,0,1,10,$textstring);
$stringwidth = $bounds[2] - $bounds[0];
# just printing some of the parameters returned.
print("$@\n");
print ("@bounds\n");
print ("@bounds[0,1]\n");
print ("@bounds[2,3]\n");
print ("@bounds[4,5]\n");
print ("@bounds[6,7]\n");
print ("$stringwidth\n");
print("$textstring\n");
# continue
$final = new GD::Image($stringwidth,16);
$background = $final->colorAllocate(255,255,238);
$brown = $final->colorAllocate(159,30,0);
$green = $final->colorAllocate(0,132,51);
$final->rectangle(0,0,$stringwidth+9,15,$green);
@bounds =
$final->stringTTF($brown,"/INETPUB/FONTS/AVGARDMI.TTF",10,0,1,10,$textstring);
$output = $final->png;
open (IMAGE,">../wwwroot/madeimages/test.png") || die;
binmode IMAGE;
print IMAGE $output;
close (IMAGE);
======================= END SAMPLE =======================
------------------------------
Date: Fri, 20 Apr 2001 13:42:09 -0700
From: Bryan Coon <bcoon@sequenom.com>
Subject: Re: GD/TrueType weirdness (CODE SAMPLE)
Message-Id: <3AE09F21.4D7F5A72@sequenom.com>
Dan Harding wrote:
> Here's the PERL code I'm running.
>
> Thanks,
>
> -Dan
>
> ================ BEGIN SAMPLE ======================
>
> #!/usr/bin/perl -w
>
> use GD;
>
> $textstring = "Hello";
>
> $im = new GD::Image(100,100);
>
> $background = $im->colorAllocate(255,255,238);
>
> @bounds =
> GD::Image->stringTTF($background,"/INETPUB/FONTS/AVGARDMI.TTF",10,0,1,10,$textstring);
>
> $stringwidth = $bounds[2] - $bounds[0];
>
> # just printing some of the parameters returned.
>
> print("$@\n");
> print ("@bounds\n");
> print ("@bounds[0,1]\n");
> print ("@bounds[2,3]\n");
> print ("@bounds[4,5]\n");
> print ("@bounds[6,7]\n");
> print ("$stringwidth\n");
> print("$textstring\n");
>
> # continue
This seems okay so far.....
>
> $final = new GD::Image($stringwidth,16);
>
But why a new image? I see no copy of this image ($final) onto the original ($im)....
>
> $background = $final->colorAllocate(255,255,238);
> $brown = $final->colorAllocate(159,30,0);
> $green = $final->colorAllocate(0,132,51);
>
> $final->rectangle(0,0,$stringwidth+9,15,$green);
>
> @bounds =
> $final->stringTTF($brown,"/INETPUB/FONTS/AVGARDMI.TTF",10,0,1,10,$textstring);
>
> $output = $final->png;
>
> open (IMAGE,">../wwwroot/madeimages/test.png") || die;
> binmode IMAGE;
> print IMAGE $output;
> close (IMAGE);
>
> ======================= END SAMPLE =======================
When I executed this code, it worked okay (meaning it printed some text in a tiny little
box).
Try this:
#!/usr/bin/perl -w
use GD;
$im = new GD::Image(400,400);
$im->colorAllocate(255,255,238);
$brown = $im->colorAllocate(159,30,0);
$textstring = "Hey this thing works!";
$im->stringTTF($brown,"/usr/share/fonts/default/TrueType/arial.ttf",10,1,200,200,$textstring);
open (IMAGE,"> test.png") || die;
print IMAGE $im->png;
close (IMAGE);
Altering paths for your stuff. If you continue to have problems, then I maintain that
you have GD lib problems, as this works fine for me.
A note: the can_do_ttf() returns true if -GD.pm- is compiled with truetype support. This
does NOT mean that libgd has been compiled with truetype support. Again, by default,
libgd is not (on RH 7.0 anyway). In this case, you need to recompile libgd with truetype
support....
Good luck!
Bryan
------------------------------
Date: Fri, 20 Apr 2001 13:26:01 -0500
From: Dan Harding <dharding@uiuc.edu>
Subject: Re: GD/TrueType weirdness.
Message-Id: <3AE07F39.FC5F64DA@uiuc.edu>
> I dont think so... I cant say for sure in windoze what version of GD.pm is installed, but
> I do know that in unix the default version is not compiled with truetype support. So
> chances are great that you need to rebuild the GD library to support truetype. Sadly,
> I can tell you exactly how to do this in unix, but I have no clue in windows.
>
> You can verify this by using the can_do_ttf() method included in the GD::Text module, but
> I am 99.9% sure this is the problem.
>
> The docs in GD::Text will tell you about this as well.
TrueType support is indeed turned on. can_do_ttf returns true.
It's bizarre. It's obviously finding the .ttf file (or the procedure
would break).
The $image->stringTTF() routine is "printing" the correct number of
characters, just
boxes....
AUGH!
------------------------------
Date: Fri, 20 Apr 2001 18:20:04 -0000
From: c_cruizer@my-deja.com_nospam (Cosmic Cruizer)
Subject: Re: Grabbing file date and time
Message-Id: <Xns90897318F1927ccruizermydejacom@207.126.101.100>
trammell@bayazid.hypersloth.invalid (John Joseph Trammell) wrote in
<slrn9e0r9s.kk3.trammell@bayazid.hypersloth.net>:
>On Fri, 20 Apr 2001 17:35:16 -0000, Cosmic Cruizer wrote:
>> I am reading file names from a unix directory into an array. I would
>> also like to read the date and time info into an array.
>
>You'd probably save some time if you used the builtin stat()
>function, or perhaps the File::stat module.
>
>
Well... at least I learned quite a bit by trying to do it the hard way. :)
stat() works like a charm. Thnx
------------------------------
Date: Fri, 20 Apr 2001 18:09:08 GMT
From: trammell@bayazid.hypersloth.invalid (John Joseph Trammell)
Subject: Re: Idiom: the expression of a copied & substituted string
Message-Id: <slrn9e0skk.km1.trammell@bayazid.hypersloth.net>
On Fri, 20 Apr 2001 13:18:05 +0800, John Lin <johnlin@chttl.com.tw> wrote:
> I would like to learn the idiomatic way of expressing this:
>
> my $original = 'Good %, sir.';
> my $copied1 = 'Good morning, sir.'; # s/%/morning/;
> my $copied2 = 'Good afternoon, sir.'; # s/%/afternoon/;
I don't know about idiomatic, but why not use [s]printf if the
substitution is that simple?
my $template = "Good %s, sir.\n";
my $one = sprintf $template, "morning";
my $two = sprintf $template, "afternoon";
> print ((my $copied = $original) =~ s/%/morning/);
>
> the result is "1". If we push it to an array, or pass it as a parameter,
> whatever, we are dealing with the "1" not the copied string.
printf $template, "evening";
push @foo, sprintf($template,"grief");
my %bar = ( x => sprintf($template,'to see you') );
--
According to the Genesis account, the tower of Babel was man's second
major engineering undertaking, after Noah's ark. Babel was the first
engineering fiasco.
- F. Brooks, _The Mythical Man-Month_
------------------------------
Date: Fri, 20 Apr 2001 18:35:55 GMT
From: Glenn Davis <glenn@surveystar.com>
Subject: Is it a hash or not?
Message-Id: <3AE08100.E24120A2@surveystar.com>
I have a subroutine that deals with lists -- the list name is a variable
that can be either a simple array or a hash. However, I need to handle
these slightly differently.
I am using...
if (keys(%$listname)) {
$hash=1;
}
if ($hash) ...
...which seems to work fine in my testing, but I wonder whether this
will always work, or if there are any risks of using the % syntax in
situations where $listname is not a hash.
Thoughts?
------------------------------
Date: Fri, 20 Apr 2001 19:48:23 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Is it a hash or not?
Message-Id: <3AE09280.4C2E489C@acm.org>
Glenn Davis wrote:
>
> I have a subroutine that deals with lists -- the list name is a variable
> that can be either a simple array or a hash. However, I need to handle
> these slightly differently.
>
> I am using...
>
> if (keys(%$listname)) {
if ( ref( $listname ) eq 'HASH' ) {
> $hash=1;
> }
> if ($hash) ...
>
> ...which seems to work fine in my testing, but I wonder whether this
> will always work, or if there are any risks of using the % syntax in
> situations where $listname is not a hash.
perldoc -f ref
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 20 Apr 2001 20:17:51 GMT
From: Glenn Davis <glenn@surveystar.com>
Subject: Re: Is it a hash or not?
Message-Id: <3AE098F8.F1923C05@surveystar.com>
ref() didn't work.
tried...
$reftype=ref($listname);
print"$listname is $reftype";
...reftype is empty. ???
"John W. Krahn" wrote:
> Glenn Davis wrote:
> >
> > I have a subroutine that deals with lists -- the list name is a variable
> > that can be either a simple array or a hash. However, I need to handle
> > these slightly differently.
> >
> > I am using...
> >
> > if (keys(%$listname)) {
>
> if ( ref( $listname ) eq 'HASH' ) {
>
> > $hash=1;
> > }
> > if ($hash) ...
> >
> > ...which seems to work fine in my testing, but I wonder whether this
> > will always work, or if there are any risks of using the % syntax in
> > situations where $listname is not a hash.
>
> perldoc -f ref
>
> John
> --
> use Perl;
> program
> fulfillment
------------------------------
Date: 20 Apr 2001 16:42:39 -0400
From: Doug Perham <dperham@dperham.eng.tvol.net>
Subject: Re: Is it a hash or not?
Message-Id: <81wv8fwbeo.fsf@wgate.com>
Glenn Davis <glenn@surveystar.com> writes:
> I have a subroutine that deals with lists -- the list name is a variable
> that can be either a simple array or a hash. However, I need to handle
> these slightly differently.
>
> I am using...
>
> if (keys(%$listname)) {
> $hash=1;
> }
> if ($hash) ...
>
how about
$hash = ref($listname) eq 'HASH';
if ($hash) ...
> ...which seems to work fine in my testing, but I wonder whether this
> will always work, or if there are any risks of using the % syntax in
> situations where $listname is not a hash.
>
> Thoughts?
--
Doug Perham o{..}o
dperham@wgate.com moo! (oo)___
WorldGate Communications, Inc. (______)\
/ \ / \
------------------------------
Date: Fri, 20 Apr 2001 21:16:57 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Is it a hash or not?
Message-Id: <3AE0A748.61EBFDDC@acm.org>
[Please post your reply _after_ the message you are quoting]
[Please do not quote .sigs]
Glenn Davis wrote:
>
> "John W. Krahn" wrote:
>
> > Glenn Davis wrote:
> > >
> > > I have a subroutine that deals with lists -- the list name is a variable
> > > that can be either a simple array or a hash. However, I need to handle
> > > these slightly differently.
> > >
> > > I am using...
> > >
> > > if (keys(%$listname)) {
> >
> > if ( ref( $listname ) eq 'HASH' ) {
> >
> > > $hash=1;
> > > }
> > > if ($hash) ...
> > >
> > > ...which seems to work fine in my testing, but I wonder whether this
> > > will always work, or if there are any risks of using the % syntax in
> > > situations where $listname is not a hash.
> >
> > perldoc -f ref
>
> ref() didn't work.
> tried...
> $reftype=ref($listname);
> print"$listname is $reftype";
> ...reftype is empty. ???
Then $listname does not contain a reference.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 20 Apr 2001 21:41:11 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Is it a hash or not?
Message-Id: <ota1etsgftm0esndg011jem7s994kk6n1q@4ax.com>
Glenn Davis wrote:
>I am using...
>
> if (keys(%$listname)) {
> $hash=1;
> }
> if ($hash) ...
>
>...which seems to work fine in my testing, but I wonder whether this
>will always work, or if there are any risks of using the % syntax in
>situations where $listname is not a hash.
Yup. If it's not a hash ref, then this will croak.
Check if ref($hash) is "HASH" (only of not blessed), if $ref as a string
contains "=HASH", or, better still, use the UNIVERSAL method isa:
print UNIVERSAL::isa($ref, "HASH")?'y':'n';
--
Bart.
------------------------------
Date: Fri, 20 Apr 2001 15:37:39 -0400
From: Jeff Boes <jboes@nexcerpt.com>
Subject: Re: List comparison
Message-Id: <3AE09003.E38439C9@nexcerpt.com>
Jim F wrote:
> I have a file with a list on each line, if I load it into a hash or array is
> there a way I can compare the contents of the whole list at once instead of
> iterating through each?
>
> I would like to do something like
>
> if $string is found in $list then print $string
Perhaps you need "perldoc -f grep" as a starting point. If the "list" on
each line is indeed a sequence of separate things (say, a
comma-separated list, or a set of keywords with whitespace between
them), then grep() is the way to go. If the "list" on each line is in
fact just a string, then index() is more appropriate as suggested
elsewhere in this thread.
Just a code snippet:
while (defined($line = <>)) {
next unless @list = split(/something/, $line);
print "$string found on line #$.\n" if grep(/$string/i, @list);
}
--
Jeff Boes vox 616.226.9550
Database Engineer fax 616.349.9076
Nexcerpt, Inc. jboes@nexcerpt.com
------------------------------
Date: Fri, 20 Apr 2001 21:27:43 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: LWP, getting the default index page name from a web directry.
Message-Id: <te1aeflgv3cibc@corp.supernews.com>
Steve (steve@zeropps.uklinux.net) wrote:
: >This has nothing to do with Perl.
:
: If you're trying to get the results with perl it has everything to
: do with perl!
Oh, what a relief! I use a perl script to index my recipes, and I just
can't work out how to keep my Bernaise from separating. What should I do,
perl gurus???
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: 20 Apr 2001 18:31:37 GMT
From: Timour Ezeev <timour@pivotaldynamics.com>
Subject: m$ sql server access from perl
Message-Id: <3AE0807D.DDA080CD@pivotaldynamics.com>
Hello all,
Need to query M$ SQL Server from perl script running on Solaris box...
Please hlp to find correct module. Tnx.
------------------------------
Date: Fri, 20 Apr 2001 21:04:01 GMT
From: "dkh" <projectobjects@earthlink.net>
Subject: Re: m$ sql server access from perl
Message-Id: <5v1E6.1730$J74.203273@newsread1.prod.itd.earthlink.net>
See this URL, http://www.activestate.com/ASPN/Mail/msg/perl-DBI:293367 , for
configuring iODBC on NT to support remote connection from Solaris.
regards,
dale
"Timour Ezeev" <timour@pivotaldynamics.com> wrote in message
news:3AE0807D.DDA080CD@pivotaldynamics.com...
> Hello all,
> Need to query M$ SQL Server from perl script running on Solaris box...
> Please hlp to find correct module. Tnx.
>
>
------------------------------
Date: Fri, 20 Apr 2001 21:33:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: m$ sql server access from perl
Message-Id: <mia1eto02njm3geulkgkvq1jtqe9d3hbl8@4ax.com>
Timour Ezeev wrote:
>Need to query M$ SQL Server from perl script running on Solaris box...
>Please hlp to find correct module. Tnx.
ODBC. Nuff' said. Look here:
<http://tlowery.hypermart.net/perl_dbi_dbd_faq.html>
--
Bart.
------------------------------
Date: Fri, 20 Apr 2001 08:56:47 -0700
From: "Matt" <mnm@mnm.com>
Subject: Re: Net::POP3
Message-Id: <9bq4kb$k4b$1@neptunium.btinternet.com>
http://www.perldoc.com/perl5.6/lib/Net/POP3.html
--
Matt
"JC Praud" <jc@nospampraud.com> wrote in message
news:rEYD6.491$TA5.646249@nnrp1.proxad.net...
> Hi all,
>
> I've a trouble with Net::POP3 module: I can read emails from my server
> (a QMail on Linux), but not from other servers...
>
> Here the source:
>
> $pop=Net::POP3->new($popserver);
> $nbmesg=$pop->login($popaccount,$poppasswd);
> ## returned message number is empty
>
> ($nbmesg,$size)=$pop->popstat;
> ## returned info are also empty
>
> $messages=$pop->list;
> foreach $themail(keys(%$messages)){
> ...
>
> What did I miss ?
------------------------------
Date: 20 Apr 2001 20:54:34 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Net::SMTP
Message-Id: <9bq7ma$sgo$1@uranium.btinternet.com>
Darnell Kelly <dkelly@quisic.com> wrote:
> all,
>
> does this module support a cc: method...i tried to send emails with a
> cc; field and i get the nasty error
>
> can't find auto/NET/cc.al in @INC etc...
>
> but when i use the smtp->to($to) or smtp->from($from) objects the script
> is ok...
>
> is cc: not allowed or is it? if this module can't support this which one
> should i use? i searched CPAN but could not find one i need...
>
You should send the 'Cc:' header as part of the data in the datasend()
method .
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 20 Apr 2001 19:11:50 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: Perl & PHP programmer available.
Message-Id: <slrn9e12fn.djd.dha@panix2.panix.com>
In article <3adf7e98.3166055@news-server>, Gil G. wrote:
>
> I can help you with your scripts.
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :) (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
http://jobs.perl.org may be of more use to you
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I'd redesign my program to something less absurd.
- Abigail, in comp.lang.perl.misc
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 V10 Issue 730
**************************************