[8152] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1770 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 30 13:10:35 1998

Date: Fri, 30 Jan 98 10:00:26 -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, 30 Jan 1998     Volume: 8 Number: 1770

Today's topics:
    Re: Another "uninitialized variable" problem <rootbeer@teleport.com>
    Re: Array and Split? <rootbeer@teleport.com>
    Re: C++ (Clay Irving)
    Re: C++ <ebohlman@netcom.com>
        Can PERL test for a process? <shaun@ms.com>
    Re: can variables be generated on the fly <cdkaiser@delete.these.four.words.concentric.net>
        DBM files in Perl <michaelr@titan.lndn.tensor.pgs.com>
        dc.pm.org (Philip Hood)
        Getting mail from a pop3 server with PERL WIN32 <Sebastian.Probst@usa.net>
    Re: Help needed: I cannot seem to get this variable to  <rootbeer@teleport.com>
    Re: Help with executing app on NT using PERL <rootbeer@teleport.com>
    Re: How do you setup named parameters in objects <ebohlman@netcom.com>
        la.pm.org (Clay Irving)
        Matching one line, then another <bill.weaver@lexis-nexis.com>
    Re: module variable scope <jdporter@min.net>
    Re: Open +< mode for read/write file <rootbeer@teleport.com>
    Re: open in append mode <rootbeer@teleport.com>
    Re: Perl upload function <rootbeer@teleport.com>
        PERL Win32 getting mail with a pop3 server <Sebastian.Probst@usa.net>
    Re: PERL Win32 getting mail with a pop3 server <jschrab@REMOVETHISroyle.com>
    Re: print<< into variable? (Andy Lester)
        Problem with IO::Select & Socket <sanct@dlc.fi>
        removing a line from a file <ccordero@wiley.csusb.edu>
    Re: Require or read offserver files? <rootbeer@teleport.com>
    Re: script does things as different user? <rootbeer@teleport.com>
    Re: Sending data to a printer?? <rootbeer@teleport.com>
    Re: Some possible bugs (Clay Irving)
    Re: TYP21D (was: substitute...) (Dave Till)
    Re: Where are all the scripts? <rootbeer@teleport.com>
    Re: Why can't I unzip? (Frank)
        Working directory when exec. Perl w/ Netscape Server pat.coutu@entrust.com
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 30 Jan 1998 08:29:54 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: faverNoSpam@austin.ibm.com
Subject: Re: Another "uninitialized variable" problem
Message-Id: <Pine.GSO.3.96.980130081732.1584B-100000@user1.teleport.com>

On 29 Jan 1998 faverNoSpam@austin.ibm.com wrote:

> Subject: Another "uninitialized variable" problem
> 
>   I am using Perl for some hardware bring-up code that controls
>   initialization.  Using Perl 5.002 on a Unix workstation with
>   the -w option.

I can't say whether this will help in your case, but perl 5.004 is smarter
than previous versions about the warnings it gives.

>     ($xnode_num)=($this_nca =~ /([0-9])/);

Note that this will leave $xnode_num undefined if the pattern fails to
match. Could that be happening? You could try this:

    unless (defined $xnode_num) { 
	print "\$this_nca didn't match; it contains ",
	    (defined($this_nca) ? "'$this_nca'\n" : "undef\n");
	die "Undefined \$xnode_num";	# or whatever
    }

>     if ($xnode_num eq '0')
>       {$fence_bits = ($fence_bits | "10000")}
>     elsif ($xnode_num eq '1')                  <<---ERROR ON THIS LINE

There's a bug in the way Perl calculates line numbers of some errors, so
the "real" error may be a little earlier. But since $fence_bits is set,
and since you're not getting repeated complaints about $xnode_num, I
suspect that it's a bug in (your version of) Perl itself. 

If this still happens with 5.004, see if you can make a small (say, ten
line) script which demonstrates it. Thanks! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/





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

Date: Fri, 30 Jan 1998 09:44:12 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Craig A. Keefner" <keefner@kinetic.com>
Subject: Re: Array and Split?
Message-Id: <Pine.GSO.3.96.980130094139.1584M-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Craig A. Keefner wrote:

> I want to run a dos program within perl and generate a return list of
> search finds, read that data into array and put it on the screen as
> formatted html. With just the print it comes in as one long string, and
> I also wanted to "hide" the part numbers which occur at the end. 

It sounds as if you want to loop through the array and do a s///
substitution (or some other transformation) on each line. 

> open(FINDSUBPART, "dospartfind.exe /p $part /m $model /s $year /w 70|")
> || error ("Could not open file /abc/data.txt"); 

I'm not sure that that string is the best possible diagnostic message! :-)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 30 Jan 1998 11:58:29 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: C++
Message-Id: <6at0rl$f3t@panix.com>

In <01baef1a$6d647c00$6e67f482@default> "DAN ALBERTSSON" <dan.albertsson@swipnet.se> writes:

>I don't know if there will be an object oriented perl in the near future
>but for a perl rookie it seems powerful enough.

Eh?

Have you looked at perltoot in the documentation?

  perltoot
  Perl OO tutorial
  http://www.perl.com/CPAN/doc/manual/html/pod/perltoot.html

>But is there an IDE for Unix (and/or Windows) out there with color syntax
>highlightning or someting like that.

Perl includes a debugger. See perldebug in the documentation.

  perldebug
  Perl debugging
  http://www.perl.com/CPAN-local/doc/manual/html/pod/perldebug.html


>Is it possible to create you own library with functions and call them from
>other perl programs. (How do I declare and call them).

Read about "use" in your documentation.

>There is maybe more than one way to do it.

That's for sure!

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Fri, 30 Jan 1998 17:40:23 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: C++
Message-Id: <ebohlmanEnLyFB.4us@netcom.com>

DAN ALBERTSSON <dan.albertsson@swipnet.se> wrote:
: I don't know if there will be an object oriented perl in the near future
: but for a perl rookie it seems powerful enough.

Well, there's one in the near past and in the present...

: But is there an IDE for Unix (and/or Windows) out there with color syntax
: highlightning or someting like that.

No, but there are programmer's editors that provide features like that; 
they've been discussed here in the past, so a DejaNews search of this 
group would probably give you some good leads.

: Which is the best book on CGI-Perl.

Your best bet is to learn Perl, period, first, and then learn about the 
CGI standard (which is extremely simple to learn once you're familiar 
with the language you're going to use it with).  I'd suggest _Learning 
Perl_ by Schwartz, et.al., but you may want to go over to 
<http://www.perl.com> and read the reviews of Perl books available there.

: Is it possible to create you own library with functions and call them from
: other perl programs. (How do I declare and call them).

Yep, they're called modules and they're a very powerful feature of Perl.


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

Date: Fri, 30 Jan 1998 11:26:49 -0500
From: Shaun Ledford <shaun@ms.com>
Subject: Can PERL test for a process?
Message-Id: <34D1FF49.96A99655@ms.com>

Trying to write a script that will test whether a process exists.

Something like this shell command:


if [ -x MY PROCESS ] ; then
  p = 1 # I need to start process
else 
  p = 0 # Process already running
fi


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

Date: 30 Jan 1998 16:16:11 GMT
From: Cameron Kaiser <cdkaiser@delete.these.four.words.concentric.net>
Subject: Re: can variables be generated on the fly
Message-Id: <6asucb$k7h@examiner.concentric.net>

aml@world.std.com (Andrew M. Langmead) writes:

>eedvab@eed.ericsson.se (Vjekoslav Balas) writes:

>>Subject: Re: can variables be generated on the fly

>Its a feature called symbolic references. The feature exists, but
>there use is strongly discouraged, and in most cases can be easily

Why? There's nothing in the New Testament aka Programming Perl that calls
symbolic references depreciated. Hard references are probably better, but
symbolic references are convenient, logical and effective. And they act
just as you would expect them to.

--
Cameron Kaiser
cdkaiser at concentric dot net (it hasn't helped the spam yet though)
*** visit the Spectre Server at www.sserv.com
*** C64 software lives! www.computerworkshops.home.ml.org


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

Date: Fri, 30 Jan 1998 16:32:04 +1100
From: Mike Renshaw <michaelr@titan.lndn.tensor.pgs.com>
Subject: DBM files in Perl
Message-Id: <34D165D4.A57F0819@titan.lndn.tensor.pgs.com>

Hi all,

simple question !!!!! I'm trying to use DBM hashes in a Perl program to
save writing
info to a file for repeated invocations of a perl script but when i use
"dbmopen"
I get......

No dbm on this machine at script_name line X

any idea how I can get this to work, sounds like something in my UNIX
setup
is not there ?????

cheers.

Mike



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

Date: 30 Jan 1998 12:13:34 -0500
From: hood@panix.com (Philip Hood)
Subject: dc.pm.org
Message-Id: <6at1nu$h4t@panix.com>

#################################################################
d	c	. 	p	m 	. 	o	r	g
#################################################################

If New York has and LA and Boston are gonna have
organized perl'ers, DC needs to have some as well!

more later ...
PH

#!/usr/bin/perl -dc.pm.org
My Sig Here!


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

Date: Fri, 30 Jan 1998 09:01:43 -0700
From: Sebastian Probst <Sebastian.Probst@usa.net>
Subject: Getting mail from a pop3 server with PERL WIN32
Message-Id: <34D1F967.D80F8D67@usa.net>

Hello all,

I am looking for a POP3 modul for PERL for WIN32. I only could find this
modul for UNIX. Contacting the author of this modul failed, because the
mail address in the modul description is not valid.

Does anybody know, if there is such a modul or how I can use the UNIX
modul with WIN95/NT?

Thanks
Sebastian


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

Date: Fri, 30 Jan 1998 09:38:33 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Sylvain Juneau <sjuneau@microtec.net>
Subject: Re: Help needed: I cannot seem to get this variable to substitute in this pattern
Message-Id: <Pine.GSO.3.96.980130092855.1584L-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Sylvain Juneau wrote:

> I cannot seem to get this variable to substitute in this pattern:
> /^$client_prod_list[$b]/

Have you checked to see what that variable actually is, at the time of the
substitution? You could either print it out, or you could check it in the
debugger.

>  $count1=@client_prod_list;
>  for($b=0;$b<=$count1;$b++)

This is preparing to iterate one more time than the number of elements in
@client_prod_list. That's probably not right. 

Also, as Randal says, "Real Perl programmers don't use subscripts." Unless
you need $b for something, the more Perlian way is something like this:

    for $item (@client_prod_list) { ... }

 ...although you may wish to choose a better name than $item.

>  {
>  open(PRODUCTFILE, ">> /usr/cmis/cmisx/prodfile") || die "Can't
> open:$!\n";
>  @ARGV="/users/operator/cislist";
>  while (<>)

Although using @ARGV and diamond like this is supported and useful, it's
almost certainly better to open the file "manually" here, rather than to
use the diamond operator. (That lets you explicitly control the error
message, if the file can't be opened, for example. Since this is being
done within a loop, you could exit the loop early, thereby shielding your
users from a series of error messages.)

>  {
>  if(/^$client_prod_list[$b]/)

It's nicer to those who read and maintain it if you indent your code to
show nesting levels. A programmers' editor will help you to accomplish
this.

By the way, if the elements of @client_prod_list aren't regular
expressions, you may want to use string comparisons instead of a
pattern match on this line.

> Use of uninitialized value at /usr/cmis/cmisx/cz line 79, <> chunk
> 915. (line 79 is if(/^$client_prod_list[$b]/)  )  

That happens when you exceed the array bounds (in the for loop). :-)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 09:08:30 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: swilson@nswc.navy.mil
Subject: Re: Help with executing app on NT using PERL
Message-Id: <Pine.GSO.3.96.980130090802.1584I-100000@user1.teleport.com>

On Thu, 29 Jan 1998 swilson@nswc.navy.mil wrote:

>    print 'my_app -a -b -c -l$i';

You may want to use backticks, documented in the perlop manpage. Hope this
helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 17:08:49 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: How do you setup named parameters in objects
Message-Id: <ebohlmanEnLwyp.2D2@netcom.com>

Patrick Hayes <Patrick.Hayes.CAP_SESA@renault.fr> wrote:

: I'm getting into heavy object usage for the first time and I've come up
: against a problem unanswered after rereading the FAQ and grepping through the
: pods.

: How are named parameters setup? Many object modules use named parameters.
: Term::Cap for example has the following:

:     $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };

Those curly braces create a reference to an anonymous hash with keys TERM 
and OSPEED and corresponding values undef and $ospeed.  This hash 
reference is then passed to the Tgetent method, which presumably shift()'s 
it into some variable (possibly $self), and then later dereferences it to 
extract the values.

[snip]

: The following code can be used to furthur illustrate my question:

: 	#!/usr/local/bin/perl
: 	package foo;

: 	sub new {
: 	    my $class   = shift;
: 	    my $self    = {};
: 	    bless $self, $class;
: 	
: 	    return $self;
: 	}

Your "new" method takes only one argument, the class name (which is 
automatically supplied when you call it).  It initializes $self to a 
reference to an empty hash.

: 	sub foo {
: 	    my $self = shift;
: 	 
: 	    print "This $self->{-this}\n";
: 	}

: 	package main;
: 	$x = foo->new(-this => "is it");

Since new() wasn't written to take any user-supplied arguments, it simply 
ignores the stuff in parens.

: 	$x->foo;

: Shouldn't this print "This is it\n"?

No, because $self is still a reference to an empty hash which has no 
"-this" key.

The code will work if you

1) In new(), change "my $self={}" to "my $self=shift" which will take a 
hash reference passed as an argument to new() and keep it.

2) In your calling code, put curly braces around the "-this => it" so 
that you'll actually be passing a hash reference.



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

Date: 30 Jan 1998 12:03:21 -0500
From: clay@panix.com (Clay Irving)
Subject: la.pm.org
Message-Id: <6at14p$fnd@panix.com>

Following the lead of ny.pm.org and the proposed boston.pm.org, is anyone
interested in forming a Los Angeles area branch. See http://ny.pm.org/ for
details on what fellow Perl M((o|u)ngers|aniacs)*/ are doing..

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Fri, 30 Jan 1998 11:38:23 -0500
From: "Bill Weaver" <bill.weaver@lexis-nexis.com>
Subject: Matching one line, then another
Message-Id: <6asvkr$66g@mailgate.lexis-nexis.com>
Keywords: perl, matching, sql

I need professional help. ;-)

There are two SQL output files that I would like to scan for successful
operations and for errors. (The most common error is attempting adding
duplicate ids.) The output files are of slightly different formats, and I
have a perl solution for each, but I think my way is ugly and sophomoric.
Can someone please suggest some better ways to do this?

Basically, I'm looking for ids that succeed and ids that fail. In the sample
data at the end of this message, the failed userid is ABC1230 (with a "1"
tacked on by SQL), the successful adds are ids ABC1234, and ABC1236.

Thanks for any assistance! -bill

#! /usr/local/bin/perl5
while (<>) {
 chop;
 if (/^           0/) {
  while (<>) {
   if (/^\t([^\s]+)\s+$/) {
    $last_good_id = $1;
    print "$last_good_id added successfully\n";
   }
   last;
  }
  next;
 }
 if (/duplicate USERID/) {
  while (<>) {
   if (/^\t([^\s]+)\s+$/) {
    $failed_id = $1;
    print "$failed_id failed\n";
    last;
   }
  }
  next;
 }
}




The data looks like this:




 rc          XID          YID
 USERID

 ----------- ------------ ------------
 -----------------------------------------------------------------------
 -----------------------------
           0       123450       023450
 ABC1234

 rc
 msg_to_user



 msg_to_applir


                                            severity    applir_error
 application XID
 USERID

 -----------
 -----------------------------------------------------------------------
 -----------------------------------------------------------------------
 -----------------------------------------------------------------------
 ------------------------------------------
 -----------------------------------------------------------------------
 -----------------------------------------------------------------------
 -----------------------------------------------------------------------
 ------------------------------------------ ----------- ------------
 ----------- -----------
 -----------------------------------------------------------------------
 -----------------------------
           1
 The User ID you provided is already in use.  Please provide a different
  User ID.


 duplicate USERID


                                                      1       ZZZZZ1
 AddCustomer           0
 ABC12301


 -----------
      0002
 rc          XID          YID
 USERID

 ----------- ------------ ------------
 -----------------------------------------------------------------------
 -----------------------------
           0       123456       023456
 ABC1236











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

Date: Fri, 30 Jan 1998 10:44:29 -0500
From: John Porter <jdporter@min.net>
Subject: Re: module variable scope
Message-Id: <34D1F55D.E0E@min.net>

Andrew M. Langmead wrote:
> 
> John Porter <jdporter@min.net> writes:
> 
> >"global" variables are variables in the "main" namespace.
> >Code that is also in the "main" namespace can access the
> >variables unqualified (as the lines after your "use Test_Mod"
> >do).
> 
> This is one of the reasons why pointing people to the documentation is
> better than giving off the cuff answers.
> 
> The only "global" variables in perl are (some or all of) the
> punctuation variables listed in the perlvar man page. Otherwise you
> have lexically scoped variables and package variables. For information
> on packages, see the perlmod man page.

Thanks for adding technical clarity to this thread.
I was really addressing what Thomas was referring to as "global"
variables, not what Perl considers global variables.
I think it's clear he wasn't interested in the actual globals,
but in main:: variables.  I believe my response was appropriate
to the knowledge level of the questioner.

> The "main" namespace is not anything special other than it is the
> default namespace until changed with the "package" statement. If you
> assume that a module is being called from "main" and you hardcode
> references to "main" in the module, you prevent another module from
> using yours.

Certainly a point worth remembering.  Now, is there an easy way
(i.e. not over the head of novice) to access variables in the
package of the caller?  Or should we simply say that this is
bad practice?

John Porter


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

Date: Fri, 30 Jan 1998 08:56:22 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com>
Subject: Re: Open +< mode for read/write file
Message-Id: <Pine.GSO.3.96.980130084725.1584F-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Dennis Kowalski wrote:

> seek TMP2, $offset, 0;
> $stat = read TMP2, $buf, $recsize;
> ($buf2 = $buf) =~ s/Record/RECORD/;
> $stat = syswrite TMP2, $buf2, $recsize, $offset; # $stat gets 0

I don't think that's the right use of $offset. But more than that, the
docs for syswrite explicitly recommend against mixing it with seek and
read. I think you want to use print instead. And many systems require you
to seek when you switch from reading to writing. With those changes, I can
get your code to work on my machine. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 08:30:59 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom Jenkins <TomJenkins@worldnet.att.net>
Subject: Re: open in append mode
Message-Id: <Pine.GSO.3.96.980130083036.1584C-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Tom Jenkins wrote:

> open( FILE, '>> test.file' ) ;

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 09:18:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Reimer AG <internet@reimer.ch>
Subject: Re: Perl upload function
Message-Id: <Pine.GSO.3.96.980130091805.1584K-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Reimer AG wrote:

> the server gives an error message (Server Error). 

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 09:05:59 -0700
From: Sebastian Probst <Sebastian.Probst@usa.net>
Subject: PERL Win32 getting mail with a pop3 server
Message-Id: <34D1FA67.FE2979AB@usa.net>

Hello all,

I am looking for a POP3 modul for PERL for WIN32. I only could find this
modul for UNIX. Contacting the author of this modul failed, because the
mail address in the modul description is not valid.

Does anybody know, if there is such a modul or how I can use the UNIX
modul with WIN95/NT?

Thanks
Sebastian


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

Date: Fri, 30 Jan 1998 11:38:04 -0600
From: Jeffrey Schrab <jschrab@REMOVETHISroyle.com>
Subject: Re: PERL Win32 getting mail with a pop3 server
Message-Id: <34D20FFC.B926C8F2@REMOVETHISroyle.com>



Sebastian Probst wrote:

> Hello all,
>
> I am looking for a POP3 modul for PERL for WIN32. I only could find this
> modul for UNIX. Contacting the author of this modul failed, because the
> mail address in the modul description is not valid.
>
> Does anybody know, if there is such a modul or how I can use the UNIX
> modul with WIN95/NT?
>
> Thanks
> Sebastian

 I too am looking for a solution to do fetching of mail within Perl on NT.
The Net module is not quite as "canned" as I would like it to be (for WinNT)
and I am quite new to Perl.  Is there another way to do this without the Net
module?

Is ActiveState planning more modules for NT?  O'Reilly?  Anyone?  Alpha
binaries, while your at it...;)

--

Jeffrey Schrab
Royle Communications, RDI
(608)837-5161 Ext. 257




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

Date: 30 Jan 1998 16:15:46 GMT
From: petdance@maxx.mc.net (Andy Lester)
Subject: Re: print<< into variable?
Message-Id: <6asubi$g9s$1@usenet87.supernews.com>

: Is there any way to use the print<<__EndOfQuote__
: syntax to print into a variable directly, rather 
: than to a file handle? (eg STDOUT)

Sure.  That's not just a syntax for print.  "Here documents" work
wherever.

my $foo = <<"END";
This goes into \$foo.
blah blah blah
END
print"[$foo]\n";

See page 43 of Camel II.

xoxo,
Andy

--
--
Andy Lester:        <andy@petdance.com>       http://tezcat.com/~andy/
Chicago Shows List: <shows@ChicagoMusic.com>  http://ChicagoMusic.com/



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

Date: Thu, 29 Jan 1998 22:19:46 +0200
From: Aleksi Asikainen <sanct@dlc.fi>
Subject: Problem with IO::Select & Socket
Message-Id: <34D0E462.E99EFD01@dlc.fi>

I wrote a litte script, using IO::Socket, and IO::Select. (And naturally
it 'requires' 5.002) Win32 build.

It worked well;

my $lis = IO::Socket::INET->new(Proto => 'tcp', LocalPort => 1234,
Listen => 1, Reurse => 1) || die $!;
my $select = IO::Select->new($lis);
while (@ready = $select->can_read)
{
  my $socket;
  for $socket (@ready)
    {
      if ($socket == $lis)
      {
        my $next_u = $lis->accept;
        $select->add($next_u);
 (some clipped code)

until this:
for $socket ($select->handles) 

It causes error "Can't locate object method "handles" via package
"IO::Select". Why? What can I do for it? Have I understood something
wrong? 

No, I can't find any information form CPAN (IO modules; All of these
modules are bundled with Perl) nor dejanews (11 matches for search
IO::Select comp.lang.perl.misc)

-aleksi asikainen


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

Date: Thu, 29 Jan 1998 16:33:54 -0800
From: Chad R Cordero <ccordero@wiley.csusb.edu>
Subject: removing a line from a file
Message-Id: <34D11FF2.41C67EA6@wiley.csusb.edu>

I am trying to remove a name from a list of names separated by newline
in a file.  I tried adapting an example of removing words in a string
using splice:

	open(FILE, "+>file");
                @list = split(/\n*/, <FILE>);
                $i = 0;
                while(defined($list[$i]))
                {
                        if($list[$i] eq "$name")
                        {
                                splice(@list, $i, 1);
                        }
                        else
                        {
                                $i++;
                        }
                }
                $line = join("\n", @list);
                print FILE ("$line\n");
        close(FILE);

Apparently, though, it ends up with a blank @list hence writing nothing
to the file effectively erasing it.  I'm glad I backed it up.  How can I
fix this, or am I completely off base?


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

Date: Fri, 30 Jan 1998 09:07:14 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Chuck <jacobsoc@grove.ufl.edu>
Subject: Re: Require or read offserver files?
Message-Id: <Pine.GSO.3.96.980130090632.1584H-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Chuck wrote:

> These files need to be read by the processor on a potentially (and
> probably) different server. 

To read files from a remote webserver in Perl, you may use the LWP
package. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 09:04:13 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Phil R Lawrence <prl2@lehigh.edu>
Subject: Re: script does things as different user?
Message-Id: <Pine.GSO.3.96.980130085732.1584G-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Phil R Lawrence wrote:

> I want a script to log into Oracle as a more powerful user than the person
> who starts the script.  How can I protect the password that goes with that
> more powerful userID from prying eyes?

The usual method is to keep that password in a file which is readable only
by that user id. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 09:48:47 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Hinrich Specht <hspecht@bytes.de>
Subject: Re: Sending data to a printer??
Message-Id: <Pine.GSO.3.96.980130094443.1584N-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Hinrich Specht wrote:

> Now I want the data to be printed on a printer. 

There's no special Perl way to send data to a printer, but you can use the
same method that your system uses when non-Perl programs need to send data
to a printer. For example, on a Unix-type machine, you may be able to pipe
to the lpr program. If you need help with the way to do this for your
system, people in a newsgroup about your system may be of some help. Hope
this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 30 Jan 1998 12:04:41 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Some possible bugs
Message-Id: <6at179$fvf@panix.com>

In <fl_aggie-3001981004060001@aggie.coaps.fsu.edu> fl_aggie@thepentagon.com (I R A Aggie) writes:
>In article <886161381.1421803532@dejanews.com>, shaker@netusa1.net wrote:

>+ I will gladly upgrade. However, it is going to take some time. We have
>+ perl and several other 'tools' in a central (so-called) software bank. I
>+ have to persuade the maintainers of this to perform the upgrade for me.

>Tell 'em perl v4 is dead. Tell 'em perl v4 is insecure.

 ...and there are no plans to make it Y2K compliant. :)

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: 30 Jan 1998 11:24:57 -0500
From: davet@angel.uunet.ca (Dave Till)
Subject: Re: TYP21D (was: substitute...)
Message-Id: <6asusp$bgq@angel.uunet.ca>

Tom Grydeland writes:

>A critical review of teach yourself PERL 5 in 21 days, 2/e
>
>General remarks
>
>This must be the most verbose perl I've ever seen written. It looks as if
>the author really wants to use C instead, and avoids using everything that
>makes perl worth using. It takes three times as much space as really
>necessary to explain anything, and everything is explained three times;
>first using the hardest way available, then ironing out some of the most
>verbose, and finally something which vaguely resembles perl.

Don't forget, though, that TYP21D was intended as a tutorial guide.
The basic idea was to present one concept at a time.  As a consequence,
many of the earlier examples are forced to be inefficient, since they
can only make use of the concepts already presented.

This sort of approach to learning doesn't suit everybody, and, in
particular, doesn't suit the more advanced reader.  But, judging by the
feedback I've gotten, it does suit many readers.

>What really bugs me about this, is that the presentation makes Perl look
>like a language with lots and lots of misfeatures and useless constructs. If
>this book was the only thing I'd ever read about Perl, I wouldn't see any
>point in learning the language. Yes, Perl has its warts, but this book
>presents it as all warts.

One person's wart is another person's feature.  Some people prefer the
object-oriented capability of Perl, and rely heavily on packages, classes
and modules.  Others don't (in particular, those who use Perl for CGI
scripting).  I myself seldom use references or classes, because I've
found that I can solve most of my programming problems more easily
using other features of Perl.  (Pattern matching in particular.)

>Every built-in function or operator is called a ``library function'',
>something that the author can allow himself to do, since he never intends to
>use the perl library anywhere in the book. (use isn't even mentioned in the
>index, and I've only spotted it twice in the text (Day 17, last section,
>Specifying System Variable Names as Words, which uses English; and Day 19,
>the Cocoa example)).

In my text, I distinguish between "library functions" and "modules".  I
think of a "library function" as a pre-defined procedure or routine,
similar to C library functions, whereas a module is a pre-defined
package.  This may not be the standard terminology in use in the
Perl community.

Were I to rewrite the book again (or over again), I would
definitely make sure that the module library was featured more prominently.
(Though, again, there's a "one concept at a time" problem:  you can't
really understand modules until you understand packages and classes,
which are among the most advanced features of Perl 5.)

BTW, there is a section on modules in Day 20 (page 737-740), which
describes how to use modules, lists a few useful modules, and mentions
CPAN.  (And there is an entry on "modules" in the index.)  As I've said,
I wish modules had been discussed in more detail, but they are described
more often than Mr. Grydeland implies.

>The author completely fails to grasp the difference between the null string
>"" and the undefined value.

To a certain extent, there is no real difference between
how undefined variables and variables containing the null string are treated.
For example, uninitialized variables are assumed to contain the null string;
in other languages, you can't use a variable in an expression context unless
you've first assigned something to it.  (I've found Perl much easier to
use than Expect/Tcl/Tk in this regard -- not that I like the
idea of referencing unassigned variables, but at least you can do it when
you have to.)

In my experience, there aren't all that many cases in which the distinction
between "" and the undefined value are important.  Other users' mileage
may vary.  (If anyone out there knows of obvious pitfalls that beginning
Perl programmers unaware of the distinction between "" and undefined
risk falling into, please let me know.)

>The cover boasts that the book is Completely Updated and Revised!, but to me
>it looks like the smallest rewrite that the author could get away with for a
>new edition, sometimes presenting obsolete (v.4) solutions and presenting
>the new way in a Note box as an afterthought. At least once, not even that.
>(The presentation of q//, p. 723.)

Again, unless you feel that Perl 5 is intended as an object-oriented language,
I don't see how you can really change the order in which the concepts
are presented.  (As I've said above, I do wish that there was more
information on the Perl modules, along with examples.)  If you don't know
how to use scalar variables, you can't really use references and classes,
can you?

>Many of the examples that could have
>demonstrated the author's understanding of Perl has instead become examples
>of exactly how little effort the author wanted to put into the making the
>book a reliable source of information.

Here, I feel I must take exception to your remark, and a tiny bit of
umbrage.  I have no problem with anyone criticizing my book, regardless
of how harshly they do so.  It's out in the world, and is fair game for
such criticism.  [I only respond to such criticism to correct factual
errors in their remarks.  For one thing, whining in such circumstances
makes one seem rather uncool. :-)]

But I find any comments on the amount of effort an author has put into
a book somewhat presumptuous.

>On the plus side, the fonts used both for running text and program listings
>are easy to read.
>
>Unfortunately, the fixed width font has two critical shortcomings:
>
>   * The single quote ' looks like a straight quote, and it is thus
>     impossible to determine from a glance whether a single quote or a
>     backtick was intended.

It's actually worse than that:  there have been several occasions where
I have specified a backtick in examples, only to see it converted into
a straight quote upon printing.  (I don't get galley proofs, so I can't
fix this myself.)

>   * Instead of a minus character, a hyphen is used, which is hard on the
>     eyes. In addition, it would appear that the typesetting system used
>     will interpret consecutive dashes to an em-dash, sometimes actively
>     exploited by the author, while other times leaving the text wrong. (See
>     p. 595.)

Again, the text as I wrote it used minus characters, not emdashes, and I keep
having to try to get SAMS to remove the damned things when I get author
reviews of new printings.  (Non-technical typesetters don't always
realize that the auto-decrement operator *has* to be two minus characters,
and *can't* be converted into an emdash.  Sigh.)

I'll take a look at the rest of Mr. Grydeland's comments when I get a
chance, and will put any errors found up on my web page
(http://www.net/~davet/errata52.html).  Apologies for having stalled
on this:  I got a copy of this message a few months ago, got bogged down
in my day job, and then forgot about it.  Mea culpa. :-)

--Dave Till
davet@uunet.ca


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

Date: Fri, 30 Jan 1998 09:17:23 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ray Schultz <ray@uh.edu>
Subject: Re: Where are all the scripts?
Message-Id: <Pine.GSO.3.96.980130091409.1584J-100000@user1.teleport.com>

On Thu, 29 Jan 1998, Ray Schultz wrote:

> I would think, given the =B3free=B2 atmosphire around perl, that there wo=
uld
> be a place where one could go and get already written perl scripts.  You
> know, =B3Why reinvent the wheel=B2, if it has already been written why wr=
ite
> it again.  So the question is where is that place?  FTP? WEB? Or what?

Others have mentioned CPAN, which is a good source. The last I heard,
though, CPAN is still looking for someone to volunteer to be the librarian
for the scripts category. Once someone volunteers (or once someone
volunteers to pay someone to do the work :-) more scripts may be kept on
CPAN.=20

Of course, there are plenty of other software archives out there. This can
help you to get started.=20

    http://www.yahoo.com/Computers_and_Internet/Software/Archives/

Hope this helps!

--=20
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 30 Jan 1998 15:54:53 GMT
From: FHeasley@chemistry.com (Frank)
Subject: Re: Why can't I unzip?
Message-Id: <34d1f7b9.3130195@news.halcyon.com>

On 30 Jan 1998 00:08:21 GMT, Tom Christiansen <tchrist@mox.perl.com>
wrote:

>Applying graphite can fix stuck zipper.
>
>--tom
Wouldn't help.  The current versions use buttons.

Frank



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

Date: Fri, 30 Jan 1998 10:41:06 -0600
From: pat.coutu@entrust.com
Subject: Working directory when exec. Perl w/ Netscape Server
Message-Id: <886178128.2030043141@dejanews.com>

When shell CGI perl scripts are executed on my server which is running
Netscape Enterprise 3.0, the current working directory is set to the
location of the perl interpreter executable (c:\perl\bin\).  This
requires that any scripts referencing  files within the same directory as
the executing script must use absolute paths.  Is there any way to change
the default current working directory to that of the directory which
contains the executiing script?

Thanks for any help,

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1770
**************************************

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