[11620] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5220 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 24 20:01:33 1999

Date: Wed, 24 Mar 99 17:00:23 -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           Wed, 24 Mar 1999     Volume: 8 Number: 5220

Today's topics:
    Re: [AJM] CGI.pm Cookie question (Murphy)
        [AJM] Need assistance with sockets and Perl (Murphy)
    Re: Can you use a hash slice reference? (Larry Rosler)
    Re: Can you use a hash slice reference? <asquith@macconnect.com>
    Re: Can you use a hash slice reference? <uri@home.sysarch.com>
    Re: Can you use a hash slice reference? <uri@home.sysarch.com>
    Re: Can you use a hash slice reference? (Larry Rosler)
        Deep Recursion error in a tie'd variable (Kelly E Jones)
        Foreign Languages. <jcokos@ccs.net>
    Re: HELP: Confused about Hash Table. (Tad McClellan)
        How to create a new directory <dales@enhanced-performance.com>
    Re: How to interpolate subroutines in here-documents? (Larry Rosler)
    Re: How to interpolate subroutines in here-documents? <jglascoe@giss.nasa.gov>
        How to make my database? <NOSPAMpenner@jps.net>
    Re: Keeping place in a file <metcher@spider.herston.uq.edu.au>
    Re: MS Access and Perl -- help! <metcher@spider.herston.uq.edu.au>
    Re: NET::ESP Where? (Alastair)
    Re: NET::ESP Where? (Jeffrey Drumm)
    Re: NET::ESP Where? (I R A Aggie)
    Re: never mind... <jglascoe@giss.nasa.gov>
    Re: never mind... (Bob Trieger)
    Re: never mind... <uri@home.sysarch.com>
        New @ Perl, Need a Good Tutorial <webmaster@bnicewd.com>
    Re: New @ Perl, Need a Good Tutorial <jglascoe@giss.nasa.gov>
    Re: New Bee Alert <jglascoe@giss.nasa.gov>
    Re: New Bee Alert <asquith@macconnect.com>
    Re: New Bee Alert <cassell@mail.cor.epa.gov>
    Re: New Bee Alert <uri@home.sysarch.com>
    Re: New Bee Alert <grichard@uci.edu>
    Re: New Bee Alert <jglascoe@giss.nasa.gov>
    Re: Perl/DBI/MS-Access: Problems inserting an integer.. <metcher@spider.herston.uq.edu.au>
    Re: regular expression with "*" (Mick Farmer)
    Re: retrieve the first hyperlink from an html file (Mick Farmer)
    Re: return codes in Win32 Perl <cassell@mail.cor.epa.gov>
    Re: What is wrong with this code? (Tad McClellan)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 25 Mar 1999 03:34:51 GMT
From: jt45@tir.com (Murphy)
Subject: Re: [AJM] CGI.pm Cookie question
Message-Id: <36f9e418.5580769@news.supernews.com>

>> Here's the code.
>> -------------
>> $cookie1=cookie(-name=>'name',-value=>$fname);
>> $cookie2=cookie(-name=>'nic',-value=>$nic);
>> print header(-cookie=>[$cookie1,$cookie2]);
>> -------------
>   GENERATING A REDIRECTION INSTRUCTION
>
>       print $query->redirect('http://somewhere.else/in/movie/land');
>The documentation is less explicit about this, but you can use the same named
> parameters to redirect() that you can to header():
>
>print redirect(-uri=>'http://main/mainmenu.html',
>                 -cookie=>[$cookie1,$cookie2]);

Ok, thanks.  But this doesn't explain why my script won't send the
cookie info to the browser.  If I use traditional methods of sending
cookies through Perl or through JavaScript, there's no problem.  But
as soon as I try to use the above mentionned (original) code, it
doesn't do squat.

Any more hints/tips?

Thanks




------------------------------

Date: Thu, 25 Mar 1999 03:35:03 GMT
From: jt45@tir.com (Murphy)
Subject: [AJM] Need assistance with sockets and Perl
Message-Id: <36f8ed23.7839808@news.supernews.com>

I'm messing around with some server apps, and have a couple of
questions.  The following works well if I launch the server on
MachineA and the client on MachineA.  But if I try to use the client
on MachineB and the server on MachineA, I get an error.   Both
machines see other (they can Ping each other).

Anybody want to clue me in on what I'm missing?

----------------------------
------->Client1.pl<--------
#!/usr/bin/perl -w
use Socket;

$NETFD = &makeconn($ARGV[0], $ARGV[1]);
sysread $NETFD, $message, 32768 or die "error getting message: $!";
print "$message \n";
close $NETFD;

sub makeconn {

 	my ($host, $portname, $server, $port, $proto, $servaddr);
	$host = $_[0];
	$portname = $_[1];
	$server = gethostbyname($host) or
		die "gethostbyname: cannot locate host: $!";
	$port = getservbyname($portname,'tcp') or
		die "getservbyname: cannot get $portname : $!";
	$proto = getprotobyname('tcp') or
		die "getprotobyname: cannot get proto : $!";
	$servaddr = sockaddr_in($port,$server);
	socket(CONNFD, PF_INET, SOCK_STREAM, $proto);
	connect(CONNFD, $servaddr) or die "connect : $!";
	return CONNFD;
}
------------------------------------
------>Server1.pl<----------
#!/usr/bin/perl
use Socket;

$hello = "Welcome to the test server";
$LISTFD = &makelisten("test");

LOOP: while(1) {
    unless($paddr = accept(NEWFD, $LISTFD)) {
       next LOOP;
      }
	syswrite(NEWFD,$hello,length($hello));
	close NEWFD;
}

sub makelisten {

	my ($portname, $port, $proto, $servaddr);
	$portname = $_[0];
	$port = getservbyname($portname,'tcp') or
		die "getservbyname: cannot get port : $!";
	$proto = getprotobyname('tcp') or
		die "getprotobyname: cannot get proto :$!";
	socket(LISTFD,PF_INET,SOCK_STREAM,$proto);
	bind(LISTFD,sockaddr_in($port,INADDR_ANY)) or die "bind: $!";
	listen(LISTFD,SOMAXCONN) or die "listen: $!";
	return LISTFD;
}




------------------------------

Date: Wed, 24 Mar 1999 14:49:37 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Can you use a hash slice reference?
Message-Id: <MPG.11630bd8892f73939897bf@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <36F95294.C3160DF6@lucent.com> on Wed, 24 Mar 1999 15:01:08 -
0600, Burton Kent <burton.not.spam@lucent.com> says...
> I'm trying to assign several values to a hash slice.  I 
> want to use a hash reference to get the slice.  Code
> follows:
> 
> # @list contains 6 copies of the same string.  
> # $wo_info is a hash reference (\%):
> @{$wo_info}->{path_name, src_name, proc_title, pt, doc_ppss, chapter} =
>    @list;

  @$wo_info{qw(path_name src_name proc_title pt doc_ppss chapter)} =
     @list;

The hash dereference to an array is simply @$wo_info, and the special 
quoting dispensation for a hash element does not apply for a hash slice.

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 24 Mar 1999 16:14:58 -0600
From: "William H. Asquith" <asquith@macconnect.com>
Subject: Re: Can you use a hash slice reference?
Message-Id: <7dbofu$1op8@enews1.newsguy.com>

It is not possible to dereference a hash or array slice.  Because 
{path_name, src_name, proc_title, pt, doc_ppss, chapter} is an comma
enumerated list, "chapter" is used {"chaper"} because the last element of a
list is used in a scalar context.  I believe that you will have to write a
loop to build the slice.

----------
In article <36F95294.C3160DF6@lucent.com>, Burton Kent
<burton.not.spam@lucent.com> wrote:


> I'm trying to assign several values to a hash slice.  I
> want to use a hash reference to get the slice.  Code
> follows:
>
> # @list contains 6 copies of the same string.
> # $wo_info is a hash reference (\%):
> @{$wo_info}->{path_name, src_name, proc_title, pt, doc_ppss, chapter} =
>    @list;
>
>
> I check this by seeing if anything was assigned to the second
> element of the hash slice:
>
> die "This did not work" unless $wo_info->{src_name};
>
>
> It dies every time.  I've tried MANY variations to try
> getting the reference and hash slice just right.  Does
> anyone know the correct one, or is this just not doable?
>
> Thanks,
>
> Burton


------------------------------

Date: 24 Mar 1999 19:15:59 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Can you use a hash slice reference?
Message-Id: <x7pv5ya0g0.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> [Posted and a courtesy copy mailed.]
  LR> In article <36F95294.C3160DF6@lucent.com> on Wed, 24 Mar 1999 15:01:08 -
  LR> 0600, Burton Kent <burton.not.spam@lucent.com> says...
  >> I'm trying to assign several values to a hash slice.  I 
  >> want to use a hash reference to get the slice.  Code
  >> follows:
  >> 
  >> # @list contains 6 copies of the same string.  
  >> # $wo_info is a hash reference (\%):
  >> @{$wo_info}->{path_name, src_name, proc_title, pt, doc_ppss, chapter} =
  >> @list;

  LR>   @$wo_info{qw(path_name src_name proc_title pt doc_ppss chapter)} =
  LR>      @list;

i would put {} around $wo_info when dereferencing as a style point,
especially in a complex expression.

  LR> The hash dereference to an array is simply @$wo_info, and the

i think you mean to say, to dereference a hash ref to a hash slice you
use:

	@{$hash_ref}{ <slice keys> }

@$hash_ref by itself is illegal if $hash_ref is not an array ref.

there doesn't seem to be any mention of how to use hash slices in the
pod docs. this needs to be corrected. in fact both hash and array slice
basics should be in the FAQ.

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: 24 Mar 1999 19:19:13 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Can you use a hash slice reference?
Message-Id: <x7k8w6a0am.fsf@home.sysarch.com>

>>>>> "WHA" == William H Asquith <asquith@macconnect.com> writes:

  WHA> It is not possible to dereference a hash or array slice.  Because
  WHA> {path_name, src_name, proc_title, pt, doc_ppss, chapter} is an
  WHA> comma enumerated list, "chapter" is used {"chaper"} because the
  WHA> last element of a list is used in a scalar context.  I believe
  WHA> that you will have to write a loop to build the slice.

that is totally wrong. see larry rosler's answer and my followup to
that. you can take a slice using a hash or array ref. you just need
to know the correct syntax.

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: Wed, 24 Mar 1999 16:12:12 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Can you use a hash slice reference?
Message-Id: <MPG.11631f33ed7cde0c9897c1@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7dbofu$1op8@enews1.newsguy.com> on Wed, 24 Mar 1999 16:14:58 
-0600, William H. Asquith <asquith@macconnect.com> says...
> It is not possible to dereference a hash or array slice.  Because 
> {path_name, src_name, proc_title, pt, doc_ppss, chapter} is an comma
> enumerated list, "chapter" is used {"chaper"} because the last element of a
> list is used in a scalar context.  I believe that you will have to write a
> loop to build the slice.

Sorry.  Everything you say is wrong.  It is a list context, not a scalar 
context.  And you don't have to write a loop to build the slice.

As you made no attempt to verify your assertions, I will post a tiny 
program that I used to verify my assertions (which I posted earlier).

#!/usr/local/bin/perl -w
use strict;

my $hashref = { a => 0, b => 1, c => 2 };
print @$hashref{qw(a b c)}, "\n";

@$hashref{qw(a b c)} = (3 .. 5);
print @$hashref{qw(a b c)}, "\n";
__END__

012
345

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 25 Mar 1999 00:31:32 GMT
From: kejones@ptdcs2.intel.com (Kelly E Jones)
Subject: Deep Recursion error in a tie'd variable
Message-Id: <7dc054$9cs@news.or.intel.com>

Hi Folks:

I'm new to using 'tie' (and, for that matter, hard references), and
I'm having a problem with some code.  In a nutshell, what I want to do
is have a tied variable x.  The 'STORE' method would just do a normal
store.  The 'FETCH' method returns some function of x and some other
variable y.  So I write the following:


sub TIESCALAR {
    my ($pkg, $xref1, $xref2) = @_;
    return(bless [$xref1,$xref2], $pkg);
}
sub STORE {
    my ($obj, $val) = @_;
    return $val;
}
sub FETCH {
    my ($obj) = @_;
    my ($xref1, $xref2) = @{$obj};
    my $x1 = $$xref1;
# Is this a recursive reference?
    my $x2 = $$xref2;
    return(function($x, $y);
}

in Main I do:

tie $x, 'TIE', \$x, \$y;


This seems to work OK, despite what MIGHT be a recursive reference in
the FETCH method.

The problem arises when I try to write a similar package to handle
elements of an array:

sub TIEARRAY {
    my ($pkg, $ref1, $ref2) = @_;
    return(bless [$ref1, $ref2], $pkg);
}
sub FETCH {
    my ($obj, $subscript) = @_;
    my ($xref1, $xref2) = @{$obj};
    my $x1 = $$xref1[$subscript];
#This is recursive!
    my $x2 = $$xref2[$subscript];
    return(function($x1, $x2);

}

sub STORE {
    my ($obj, $val) = @_;
    return $val;
}

This time, I get a 'Deep Recursion' warning from the line referencing
$$xref1[$subscript], presumably because it is recursively using this
FETCH method to obtain the value.

But, I don't want it to use FETCH to get this value, I just want it to
dereference the pointer.

Is this the expected behaviour?  Why does it work for a scalar
reference, but not an array element reference?

Is there a better way to do this, use a tied variable to return
something that is a function of the variable and some other variable?

Thanks for any pointers, 

Kelly



------------------------------

Date: Wed, 24 Mar 1999 18:01:41 -0500
From: "John Cokos" <jcokos@ccs.net>
Subject: Foreign Languages.
Message-Id: <7dbrhb$259@dfw-ixnews12.ix.netcom.com>

How does perl handle / does it support foreign languages using non-standard
character sets (like polish, chinese, etc)

Thanks

John




------------------------------

Date: Wed, 24 Mar 1999 11:54:43 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP: Confused about Hash Table.
Message-Id: <jc5bd7.3a3.ln@magna.metronet.com>

KEhlar (KEhlarQUASH@SPAMMERtheglobe.com) wrote:

: I can create a hash table with code like this one:

:  $index = 0;
:  foreach $element (@list1) {
:   $hash1{$index} = $element;
:   $index++;
:  }


   Well OK, but that looks like an array (indexed by a number)
   masquerading as a hash (indexed by a string) to me.


: OR like this one:

:  %hash1 = ('1', 'element1', '2', 'element2'....so on);


   The first one defined $hash1{0}, this one does not...


: In the latter, I can actually split the hash using the "," as the delimiter.  


   Eh?

   "split the hash"??

   What does that mean?

   There are *no* commas in %hash1.

   Are you processing Perl source code or something?


: How about the first method?  Is there a delimiter that I can use?


   Sorry. I can make no sense of your question...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Wed, 24 Mar 1999 16:48:06 -0800
From: Dale Sutcliffe <dales@enhanced-performance.com>
Subject: How to create a new directory
Message-Id: <36F987C5.46B17A1A@enhanced-performance.com>

What is the command for creating a new directory from within a perl/cgi
script?

What is the command for deleting a directory?

What is the command for deleting a file?

Thanks.



------------------------------

Date: Wed, 24 Mar 1999 14:58:28 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to interpolate subroutines in here-documents?
Message-Id: <MPG.11630df1a3b775379897c0@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <36F965CA.4C1C0B10@Paramin.COM> on Wed, 24 Mar 1999 15:23:06 
-0700, J. S. Jensen <jsjensen@Paramin.COM> says...
> How do I interpolate subroutine references within a here-document?

This interpolates into any 'double-quotish' string the return value from 
a subroutine evaluated in scalar context:

${\foo('bar', 'baz')}

This is the same, but the subroutine is evaluated in list context:

@{[foo('bar', 'baz')]}

As usual, unravel them from the inside out, and they should become 
clear.

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 24 Mar 1999 18:08:47 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: "J. S. Jensen" <jsjensen@Paramin.COM>
Subject: Re: How to interpolate subroutines in here-documents?
Message-Id: <36F9707F.FA721C2F@giss.nasa.gov>

[courtesy copy of post sent to cited author]

"J. S. Jensen" wrote:
> 
> How do I interpolate subroutine references within a here-document?
> 
> $a = "I";
> print <<EOF;
> hello, it is $a talking.
> EOF
> 
> will appropriately substitute "me" where $a is.  Now how do I
> interpolate (substitute subroutines/functions into the here-doc?)
> 
> sub aa {
>     print "I";
> }
> $aaref = \&aa();
> print <<EOF;
> hello, it is $aaref talking.
> EOF

$aaref = \&aa();

This is probably not what you want.
Here, "$aaref" is a scalar reference to
the value "1" (assuming "print()" was successful).

You want:

$aaref = \&aa;
print << "EOF";
hello, it is @{ [$aaref->()] } talking.
EOF

Which, of course, gives "Ihello, it is 1 talking\n"...
thus showing that "$aaref->()" is evaluated before the
here-doc is printed...  interesting.

sub aa { return "I" }
$aaref = \&aa;
print << "EOF";
hello, it is @{ [$aaref->()] } talking.
EOF

> Ihello,it is SCALAR(0x80b6020) talking.
> 
> Which kind of makes sense that perl is dumping the physical scalar
> reference.
> 
> So:  How do I do this?  And how do I provide arguments to the
> subroutine?  use the {} somehow?

"@{ [ $aaref->('foo', "bar") ] }"

or

"@{ [ &$aaref('foo', "bar") ] }"

but I like the "->" notation:

$hash_ref->{$key}
$array_ref->[$index]
$sub_ref->(@args)

	Jay Glascoe
-- 
"Fascinating. Live long and perspire."
  --Wacko Warner


------------------------------

Date: Wed, 24 Mar 1999 15:52:02 -0800
From: "Nathan" <NOSPAMpenner@jps.net>
Subject: How to make my database?
Message-Id: <36f9f08e.0@news1.jps.net>

Hello,

I am going to be making a database in perl.  The database will be a list of
links, and each site will have maybe about 15 fields providing information.
The total length of the info for each site would be at most 1200 characters
(rough estimate).  I will have about 200 sites indexed.  Anyway, I was
wondering what the best way to store this information would be.  Would using
a simple text file with field separators be too slow for the information
(site name|creator|URL|etc.|etc.)?  I would need the ability to search and
sort by each category.  If this would be too slow, would I be better off
using a hash of arrays or has of hashes?  I would need to store the
information in a file (of course :-) ).  My problem with this is that I am
not confident enought to install and use MLDBM :-).  Also, is it possible to
install MLDBM in my account's space?

Thank you for your help.  I would appreciate if you also reply by e-mail to
NOSPAMpenner@jps.net (remove the NOSPAM)

-Nathan




------------------------------

Date: Thu, 25 Mar 1999 09:45:16 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Keeping place in a file
Message-Id: <36F9790C.BDED27CD@spider.herston.uq.edu.au>

I know this isn't what you asked, but there is perhaps a better way to
do this.  

As you scan the file, cache all the name anchors.  You might have to
subclass HTML::Parser to do this.  When you hit a link that has a URL
"fragment" (i.e. the part after the # ), split off the fragment and
cache that along with the base URL.  You can check the base URL at this
point.

When you've finished traversing the document tree (or single document),
you can compare your name cache with your relative link cache.  If all
is well, the former will be a superset of the latter.

This approach has the advantage that any file is only scanned once,
which is a big advantage when you scale from a single document to a
whole document tree.  

There are any number of link checkers out there - and why not, they're
fun to write!  Let me know if you'd like me to send you mine.

-- 
Jaime Metcher
Gala Grant wrote:
> 
> I am writing a program that searchs a file for links, and then checks them.
> My problem is that if the link is within the same page (an anchor tag) I
> need to have a subroutine check if the anchor is on the page. When I do
> this, I have to read the file, further down, losing my place.  My question
> is, is there a way to return to the same place within the file after I test
> for the anchor tag?  I know about using seek to rewind the file to where I
> need to go, but how would I know exactly where I had been.  Actually, I
> would need to be right after the last thing I checked.
> 
> Thank You,
> Gala Grant


------------------------------

Date: Thu, 25 Mar 1999 09:55:40 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: MS Access and Perl -- help!
Message-Id: <36F97B7C.B41DC078@spider.herston.uq.edu.au>

WHOA!  Just so it's on the record, HD couldn't be more wrong.  Pete
Schrieb is having trouble building iODBC on Linux.  Win32::ODBC is an
interface to the ODBC drivers on *Win32* (funnily enough).

-- 
Jaime Metcher

HD wrote:
> 
> Pete,
> 
> you have to use the module Win32::ODBC instead of DBI, ok ?
> 
> Hans
> 
> Pete schrieb in Nachricht <7d7dn1$ce7$1@mark.ucdavis.edu>...
> >Dear all,
> >
> >I'm having trouble understanding all the steps necessary to get perl to
> >'talk' with a MS Access database.   Here's what I've done so far:
> >
> >1- I installed DBI ver 1.06
> >2- At this point, I tried installing DBD-ODBC-0.20
> >3- When I ran perl Makefile.pl it told me that I need an ODBC Driver
> >     Manager.
> >
> >I'm confused because I thought that DBD-ODBC *was* the driver.  If it's
> >not, what exactly is it?  Anyhow, it said:
> >
> >   If you do not have an ODBC Driver Manager you can try building
> >   the free iODBC Driver Manager in the iodbcsrc directory.
> >
> >OK.  so i cd to iodbcsrc and follow the instructions to the letter.  This
> >is what I get:
> >
> ># ./build linux-elf
> >autoconfig linux-elf
> >make
> >gcc -O -fPIC -ansi -I. -DDLDAPI_SVR4_DLFCN  -DVERSION=\"2.12.0\"    -c
> >dlf.c -o dlf.o
> >In file included from dlf.c:16:
> >dlf.h:4: windows.h: No such file or directory
> >
> >I'm having a rough time here.  Can some kind soul please help me get this
> >running?
> >
> >Much thanks!
> >Peter
> >
> >--
> >---------------------------------------------------------------
> >http://landau.ucdavis.edu/psalzman
> >psalzman@landau.ucdavis.edu
> >One world, one web, one program. -- Microsoft Ad Campaign
> >Ein Volk, ein Reich, ein Fuhrer. -- Nazi Ad Campaign
> >Prevent world domination, Install Linux today!
> >---------------------------------------------------------------
> >  The best way to accelerate a win95 system is at 9.81 m/s^2
> >


------------------------------

Date: Thu, 25 Mar 1999 00:01:00 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: NET::ESP Where?
Message-Id: <slrn7fiva0.5h.alastair@calliope.demon.co.uk>

Christopher Fairbairn <lgcl01@es.co.nz> wrote:
>Hi,
>
>In an early reply to my post about producing a search engine for a site
>which doesn't have CGI support someone suggested I use the NET::ESP module
>to get access to the HTML files from a server which has CGI support (I have
>another server with CGI support).

Oops. It's not even April 1st. 'ESP' stands for 'extra sensory perception'.
Something Perl can't quite handle yet. I think you've 'had' ...


-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


------------------------------

Date: Thu, 25 Mar 1999 00:27:05 GMT
From: jdrumm@blazenetme.net (Jeffrey Drumm)
Subject: Re: NET::ESP Where?
Message-Id: <36f98015.172637185@news.blazenetme.net>

[posted to comp.lang.perl.misc and mailed]

On Wed, 24 Mar 1999 13:57:25 +1200, "Christopher Fairbairn"
<lgcl01@es.co.nz> wrote:

>Hi,
>
>In an early reply to my post about producing a search engine for a site
>which doesn't have CGI support someone suggested I use the NET::ESP module
>to get access to the HTML files from a server which has CGI support (I have
>another server with CGI support).
>
>I have looked in CPAN etc but can't find any reference to this module. Can
>any one provide any help? I havn't used perl modules before and to make
>matters worse I don't have shell access to a server (as of yet) so I can't
>see error messages from Perl or read the man pages.
>
>Thanks,
>Christopher Fairbairn.

Oh, it's there . . . right next to module The::Force.  As in:

use The::Force qw(luke);


Itsa Isay itsa itsa Isay itsa joke, son . . . 

-- 
 - Jeff



------------------------------

Date: 25 Mar 1999 00:44:02 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: NET::ESP Where?
Message-Id: <slrn7fj28u.2tu.fl_aggie@stat.fsu.edu>

On Thu, 25 Mar 1999 00:01:00 GMT, Alastair
<alastair@calliope.demon.co.uk> wrote:


+ Oops. It's not even April 1st. 'ESP' stands for 'extra sensory perception'.
+ Something Perl can't quite handle yet. I think you've 'had' ...

Nice cover story. The Agency thanks you. The rain in Spain.

James

arrangements quiche class struggle security Delta Force BATF Ft. Meade
cracking spy KGB Peking counter-intelligence [Hello to all my fans in
domestic surveillance] FBI Clinton


------------------------------

Date: Wed, 24 Mar 1999 18:16:50 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: kwoody@citytel.net
Subject: Re: never mind...
Message-Id: <36F97262.24D52DA8@giss.nasa.gov>

[courtesy copy sent to cited author]

Keith Woodworth wrote:
> 
> if (not defined $var) {
>    do something
> } else {
>      do someting else
> }

you can also:

unless (defined $var) { bleah() } else { blarch() }

unfortunately, there is no "elsunless", so we must

unless (FOO1) {
    BAR1
} else {
    unless (FOO2) {
        BAR2
    } else {
        unless (FOO3) {
           BAR3
        } [...]
                else { "last option" }
	  [...]
    }
}

	Jay Glascoe
-- 
ping.


------------------------------

Date: Thu, 25 Mar 1999 00:25:55 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: never mind...
Message-Id: <7dbvrr$a65$3@birch.prod.itd.earthlink.net>

kwoody@citytel.net wrote:
>
>as is the case just about every time I post to this group or some other
>because after much fscking about trying to figure something out I figured
>it out...
>
>if (not defined $var) {
>   do something
>} else {
>     do someting else
>} 
>is right, not
>
>if not (defined $var) 


$var?do something:do something else;

will work but I am hoping somebody will tell me why it shouldn't be done this 
way.

Bob Trieger
sowmaster@juicepigs.com       



------------------------------

Date: 24 Mar 1999 19:56:35 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: never mind...
Message-Id: <x7bthi9ykb.fsf@home.sysarch.com>

>>>>> "BT" == Bob Trieger <sowmaster@juicepigs.com> writes:

  BT> kwoody@citytel.net wrote:
  >> if (not defined $var) {
  >> do something
  >> } else {
  >> do someting else
  >> } 

  BT> $var?do something:do something else;

  BT> will work but I am hoping somebody will tell me why it shouldn't
  BT> be done this way.

because that is a conditional expression which is meant to return a
value. using it in a void context instead of a proper conditional is
very bad style.

this is along the lines of never use map/grep in a void context. they
will work but it is misleading and poor style.

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: Wed, 24 Mar 1999 18:31:53 -0500
From: "Brian \"BNice\" Byrdsong" <webmaster@bnicewd.com>
Subject: New @ Perl, Need a Good Tutorial
Message-Id: <7dbs2a$h3e$1@camel29.mindspring.com>

Hi,
    I'm new to Perl and would like to know if there are any good tutorials
out there for beginners.  I have experience with html, javascript, asp and
others but no Perl.  Very Eager to learn.

--
---------------------------------------------------------------------------
Go Play, BNice
The Un-Official Falcon 4.0 Command Center
http://www.bnicewd.com/falcon4/f4home.htm
---------------------------------------------------------------------------




------------------------------

Date: Wed, 24 Mar 1999 18:44:41 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Brian \"BNice\" Byrdsong <webmaster@bnicewd.com>
Subject: Re: New @ Perl, Need a Good Tutorial
Message-Id: <36F978E9.7AD57B87@giss.nasa.gov>

[courtesy copy of post sent to cited author]

Brian \"BNice\" Byrdsong wrote:
> 
> Hi,
>     I'm new to Perl and would like to know if there are any good tutorials
> out there for beginners.  I have experience with html, javascript, asp and
> others but no Perl.  Very Eager to learn.

I don't think you'll find a high-quality tutorial online
(read "free").  You (or your company) are going to have
to shell out some bucks for a bona fide Perl book.

probably your best bet is _Learning_Perl_, 2nd Ed., by Tom
Christiansen and Randal Schwartz.  My first Perl book was
Jon Orwant's _Perl_5_Interactive_Course_.  It's a rather
large-ish tutorial and offers much insight on programming
in general.

check 'em out:
http://www.amazon.com/exec/obidos/ASIN/1565922840/qid=922318879/sr=1-1/002-8698706-0035016
http://www.amazon.com/exec/obidos/ASIN/1571691138/qid=922318750/sr=1-1/002-8698706-0035016

If you're on a WinDos system, take a look at 
_Learning_Perl_on_Win32_Systems_

	Jay Glascoe
-- 
	"It's okay to grow up--just as long as you
	 don't grow old.  Face it... you are young."

	 -- Pulp, http://www.rise.co.uk/pulp


------------------------------

Date: Wed, 24 Mar 1999 17:53:37 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Gabriel Richards <grichard@uci.edu>
Subject: Re: New Bee Alert
Message-Id: <36F96CF1.CC509286@giss.nasa.gov>

[courtesy copy of post sent to cited author]

Gabriel Richards wrote:
> 
> Be gentle with me, please...

open FH, "< $file_name" or die "urf: $!";
while ($line = <FH>) {
    # do something with "$line"
}

There's many ways to read in a file:

# read all lines into an area
my @lines = <FH>;

# read file contents as single string
my $slurp = do { undef local $/; <FH> };

As for printing a file's contents:

# nice and succinct
print while <FH>;

# hmm...
print do { undef local $/; <FH> };

> [...] Perl seems to ignore blank lines.
> Is that right?

no.

> Why? 

because blank lines are just as significant
as non-blank ones...

> I assume I must add something like: if ($_ eq \n) {print "\n"}  ?

no.

> 
> Gabe

	Jay Glascoe
-- 
"Try not! there is no *try*, only *do*."
        --Yoda


------------------------------

Date: Wed, 24 Mar 1999 16:12:31 -0600
From: "William H. Asquith" <asquith@macconnect.com>
Subject: Re: New Bee Alert
Message-Id: <7dbobe$1omg@enews1.newsguy.com>

You might have an undesirable chomp;

while(<FH>) {
  chomp;
  ## do stuff
}

You might have seen this idiom somewhere and your repeating it.  chomp; or
chomp($_); take just \n off the end of a line (if it is there).  If you read
in a "\n" line then the chomp makes $_ = ""; which is nothing.

Also if($_ eq "\n") is a preferred idiom instead of if($_ eq \n)

Perl does not ignore blank lines, unless you want her too.
----------
In article <7dbn5v$h60@news.service.uci.edu>, "Gabriel Richards"
<grichard@uci.edu> wrote:


> Be gentle with me, please...
>
> I'm reading in a text file which contains blank lines. I would like Perl to
> print the file's contents literally, but Perl seems to ignore blank lines.
> Is that right? Why? I assume I must add something like: if ($_ eq \n) {print
> "\n"}  ?
>
> Gabe
>
> 


------------------------------

Date: Wed, 24 Mar 1999 15:38:35 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: New Bee Alert
Message-Id: <36F9777B.ECB90452@mail.cor.epa.gov>

Gabriel Richards wrote:
> Be gentle with me, please...

It's okay to be a beginner.  Next time, don't put 'newbie' in
your header though.  A more meaningful subject line will get you
more help.  More useful, correct help.
 
> I'm reading in a text file which contains blank lines. I would like Perl to
> print the file's contents literally, but Perl seems to ignore blank lines.
> Is that right? Why? I assume I must add something like: if ($_ eq \n) {print
> "\n"}  ?

Perl doesn't ignore the blank lines, unless you (explicitly or implicitly)
tell it to do so.  Did you chop or chomp the line, leaving nothing there,
then neglect to add a newline back on before doing a print?

BTW, your nit of code has a slight problem.  'eq' is correct for comparing
strings [you get points for that], but you'll want to put double quotes around
the \n.

Why don't you post a cut-and-paste of your code, and we'll take a look...

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: 24 Mar 1999 19:22:20 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: New Bee Alert
Message-Id: <x7g16ua05f.fsf@home.sysarch.com>

>>>>> "JG" == Jay Glascoe <jglascoe@giss.nasa.gov> writes:

  JG> # read all lines into an area

s/area/array/

PL/I has support for areas. perl does not. :-)

  JG> # read file contents as single string
  JG> my $slurp = do { undef local $/; <FH> };

no need for the undef. localized vars are undef'ed

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: Wed, 24 Mar 1999 16:38:47 -0800
From: "Gabriel Richards" <grichard@uci.edu>
Subject: Re: New Bee Alert
Message-Id: <7dc0dj$lor@news.service.uci.edu>

> Why don't you post a cut-and-paste of your code, and we'll take a look...

Ya know...I've never met a more prompt helpful group of computer folk...ya
guys are all great...OK...I explained the wrong problem, but I still have a
problem.

while (<THREAD>) {
    #if...etc
    elsif ($_ eq "\n") { print "<br>"}
    else { print "$_ \n"}
}

Perl was in fact printing the blank lines, but I'm outputting HTML and I
forgot that browsers ignore extra spaces and lines. So, I want to make up
for that by printing the <br> tag where the originating text file has a
blank line. For some reason this isn't working and I'm not chopping or
chomping anything. The originating text file looks as follows:

This is a line of text followed by a blank line then more text.

This is the second line of text (paragraph).

Gabe




------------------------------

Date: Wed, 24 Mar 1999 19:38:22 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Uri Guttman <uri@home.sysarch.com>
Subject: Re: New Bee Alert
Message-Id: <36F9857E.9A7354C5@giss.nasa.gov>

Uri Guttman wrote:
> 
> >>>>> "JG" == Jay Glascoe <jglascoe@giss.nasa.gov> writes:
> 
>   JG> # read all lines into an area

where did that come from ?

>   JG> my $slurp = do { undef local $/; <FH> };
> 
> no need for the undef. localized vars are undef'ed

okay, I like this better  ;^)

my $slurp = do { local $/ or <FH> };

	Jay Glascoe
-- 
The Larch.


------------------------------

Date: Thu, 25 Mar 1999 09:50:50 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Perl/DBI/MS-Access: Problems inserting an integer...
Message-Id: <36F97A5A.40E5EB32@spider.herston.uq.edu.au>

You could try explicitly specifiying the type of the parameter using
bind_param.  See the DBI docs.

-- 
Jaime Metcher

dgeorgop@home.com wrote:
> 
> It sounds basic enough but I've been having no luck.  I'm not sure if
> this is a perl or an MS-Acess related problem.  I've searched the usual
> places for help but came up short.  I'm desperately hoping that someone
> can point me in the right direction.  Here's my problem:
> 
> I'm trying to insert an integer into an Ms-Access 97 table and on the
> execute, I get this error:
> 
> DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access 97
> Driver] Data type mismatch in criteria expression. (SQL-22005)(DBD:
> st_execute/SQLExecute err=-1) at register3.pl line 84.
> 
> Here's a snipet of the code:
> ...
> $employeeID = 21;
> 
> $cursor = $dbh->prepare(q{SELECT * FROM EMP WHERE EMPID = ?})
>  || die $dbh->errstr;
> $cursor->execute($employeeID);
> 
> EMP table's EMPID colum is a Long Integer data type (indexed without
> dups).  It seems as though $employeeID is being interpreted as a string
> and not an integer on execute.  So I tried "typecasting" the variable,
> as seen below, but that didn't work:
> 
> $cursor->execute(int($employeeID));
> 
> I also read in DejaNews that doing $employeeID*=1 forces perl to
> evaluate employeeID as an integer.  That didn't work.
> 
> Another thing I tried was change the data type of the column to
> Integer.  That didn't work.
> 
> If you've got any clue on this one, please throw your ideas my way.
> 
> TIA,
> Dino
> 
> Config:  Active State 5.09, Perl for Win32 on Win98


------------------------------

Date: Tue, 23 Mar 1999 17:32:00 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: regular expression with "*"
Message-Id: <F9261C.AC1@mail2.ccs.bbk.ac.uk>

Dear Zhiliang,

You're testing for equality and I think you should be
looking for patterns in your strings.  This should work (you
can make it fancier).

	if ($FORM{terms} =~ /\*/) ...

Regards,

Mick


------------------------------

Date: Tue, 23 Mar 1999 17:37:01 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: retrieve the first hyperlink from an html file
Message-Id: <F9269p.AFs@mail2.ccs.bbk.ac.uk>

Hi,

Here's a snippet out of a script I use to validate web
sites.  It produces a list of links which you can then
process.  I think you need to "use HTML::LinkExtor;"
explicitly.

	$parser = HTML::LinkExtor->new();
        $parser->parse(get($url));
        @link = $parser->links;

Regards,

Mick


------------------------------

Date: Wed, 24 Mar 1999 15:22:32 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: return codes in Win32 Perl
Message-Id: <36F973B8.F749ED18@mail.cor.epa.gov>

Cameron Dorey wrote:
> I haven't gotten the original post from this thread, so I may be
> sticking my foot into my mouth, but I always use $! instead of $? for
> getting error messages from this type of situation, such as:
> 
> unlink $filename or die "Could not delete file: $!";
> 
> This at least gives me something in English, and (after I figure it out
> in context) it makes sense.
> 
> > Phil Mak schrieb:
> > >
> > > Hi,
> > >
> > > I've set up a Perl program to delete certain files from a directory
> > > running under Windows NT.  For some reason, it is not doing it.  When I
> > > check the $? variable to find out the return code, it gives me the value
> > > '65280'.  Does anyone know what this means?  Or can somebody direct me
> > > to a web page that would contain a list of all the return codes and
> > > their meanings?  Just need someone to point me in the right direction.

Right.  If you 'use English;' you'll be able to refer to them by names
that may be more meaningful:
$!   $ERRNO or $OS_ERROR
$?   $CHILD_ERROR
$@   $EVAL_ERROR

So, oddly enough, if you check $? when you should be checking $! you
won't get a meaningful answer.  :-)

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Wed, 24 Mar 1999 13:02:01 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What is wrong with this code?
Message-Id: <pa9bd7.6c3.ln@magna.metronet.com>

Lou M (lmoran@wtsg.com) wrote:
: I copied it from O'reilly Perl for Win32 (as I am trying to learn it)

: ie no matter what answer you give "What is the secret word?" it
: answers "Wrong, try again. What is the secret code?"

: @words = qw(camel gecko alpaca);
   ^^^^^
   ^^^^^
: 		if ($word[$i] eq $guess) { #right?
                     ^^^^
                     ^^^^  where's the 's' ?


: Any ideas?  


   Yes.

   *Always* enable warnings with the -w switch on every Perl program.

   Really.

   Every one of them.

   It would have pointed out the problem immediately...


   And, format your code so that it reveals the structure of
   your code rather than the style you are using, which hides
   the structure of your code.


: email me at lmoran@wtsg.com


   Ask it here, get the answer here.


--
    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 5220
**************************************

home help back first fref pref prev next nref lref last post