[10755] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4354 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 3 18:07:30 1998

Date: Thu, 3 Dec 98 15: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           Thu, 3 Dec 1998     Volume: 8 Number: 4354

Today's topics:
        a (naive?) complaint about the Pod:: modules <tbc@col.hp.com>
    Re: Connection to Microsoft SQL Server <tripp.lilley@perspex.com>
    Re: DB handles, best approach? (Martien Verbruggen)
    Re: Directory permission. (Tad McClellan)
    Re: Directory permission. (Mike D.)
        Does crypt() act differently in different versions? <nospam.xnera@cyberenet.net>
        File Upload / cgi-lib.pl <patrick@horgen.org>
    Re: File with Sendmail <upsetter@ziplink.net>
    Re: File with Sendmail <gellyfish@btinternet.com>
        Need help editing a script phter@meganet.net
    Re: Need help editing a script <dgris@moiraine.dimensional.com>
    Re: Need help editing a script <due@murray.fordham.edu>
    Re: New idiom? (Sean McAfee)
    Re: NT won't return anything (Martien Verbruggen)
    Re: Open or Create a file wyndo@cxo.com
    Re: PC to Unix Problem <gellyfish@btinternet.com>
    Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)? ( hans mayer )
    Re: Perl to awk? (Martien Verbruggen)
        Please help with search/find PERL script (ref)
    Re: Please help with search/find PERL script (Sean McAfee)
        Problem with Dynaloader and Shared Libraries jstephens@bridge.com
        Random integer numbers (1,2,3,4,5....,.....) HOW??? <mouwend@casema.net>
        Random integer numbers (1,2,3,4,5....,.....) HOW??? <mouwend@casema.net>
        Random integer numbers (1,2,3,4,5....,.....) HOW??? <mouwend@casema.net>
        Random integer numbers (1,2,3,4,5....,.....) HOW??? <mouwend@casema.net>
    Re: Random integer numbers (1,2,3,4,5....,.....) HOW??? (John Stanley)
    Re: Regex question <asharp@hobbes.clarity.ca>
    Re: signals on Windows nt <camerond@mail.uca.edu>
    Re: Solaris passwd/shadow & getpwuid() (Martien Verbruggen)
    Re: Strange setpgrp()/root interaction? (Brand Hilton)
    Re: Strange setpgrp()/root interaction? (Martien Verbruggen)
    Re: Variable modification in module without "return"? <Allan@due.net>
    Re: Variable modification in module without "return"? (Andrew M. Langmead)
        wantarray() question. (Mike D.)
    Re: Why is "... @foo ..." occasionally a syntax error? (Martien Verbruggen)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 3 Dec 1998 15:18:53 -0700
From: "Tim Chambers" <tbc@col.hp.com>
Subject: a (naive?) complaint about the Pod:: modules
Message-Id: <7472oi$l6n$1@nonews.col.hp.com>

I just finished tracking down a couple of bugs in my POD, and I wanted to
know if there's a simple way to correlate paragraphs (reported by pod2html)
back to the line number they came from.

I read every DejaNews hit and found no discussion of this
(http://x2.dejanews.com/dnquery.xp?QRY=POD+debug&DBS=2&ST=PS&defaultOp=AND&L
NG=ALL&format=terse&showsort=score&maxhits=25&groups=comp.lang.perl.misc).

I wrote the enclosed snippet to report on the lines in each POD paragraph.
Once I did that, it was trivial to figure out what was going wrong. But the
error messages from pod2html weren't very helpful by themselves. (And
pod2text doesn't even say which paragraph the error was found.) I looked in
/opt/perl5.004/lib/Pod/ -- it seems to me the modules could be enhanced to
accept a --veryverbose option that would do something like what I did here.
But before I do that, I wanted to know what others thought. Maybe I'm
missing something obvious.

Tim Chambers                   || tbc@col.hp.com (e-mail)
Software Design Engineer       || 719.590.5570 (Office phone)
Hewlett-Packard Company        || 719.590.2251 (Fax)
Colorado Springs Division      || Tools for Digital & Embedded Design
http://www.geocities.com/Athens/3680/ (Personal Web)
The opinions and URL recommendations stated here are my own
and do not necessarily represent those of Hewlett-Packard.

---

open(POD, $ARGV[0]) || FatalMsg("cannot open '$ARGV[0]'");

$/ = "";
my @poddata  = <POD>;
close(POD);

my $idx = 0;
my $inPOD = 0;
for (@poddata) {
 $idx++;
 @chAr = split(//);
 $line = "";
 foreach $ch (@chAr) {
  $line .= $ch;
  last if ($ch eq "\n");
 }
 if (/^=head1\s/) {
  $inPOD = 1;
  printf("%4d: %s\n", $idx, $line);
 } elsif (/^=cut/) {
  $inPOD = 0;
  printf("%4d: CUT\n", $idx);
 } elsif (/^=pod/) {
  $inPOD = 1;
  printf("%4d: POD\n", $idx);
 } elsif ($inPOD) {
  printf("%4d: %s\n", $idx, $line);
 }
}






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

Date: Thu, 03 Dec 1998 17:43:29 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: Connection to Microsoft SQL Server
Message-Id: <36671411.307943D1@perspex.com>

Hendrik Woerdehoff wrote:

> I have read some statements that suggested that MS SQLServer 7 doesn't
> work with Sybase libraries any longer. But I have no knowledge whether
> this is really the case and wich actions are not working (all or just
> new features).

Does anyone have pointers to docs on the TDS (Tabular Data Stream)
format? (Yes, I realize this isn't explicitly a Perl question, but it would
help
me write a non ctlib-dependant driver for Sybase and/or MS-SQL). I've
searched off and on over the past several months, sometimes spending
an hour or two trying to follow links into numerous dead ends.

IF this thing about SQL Server 7 no longer working with ctlib is true,
does anyone know if MS has plans to make available the specs on
whatever the new on-the-wire protocol is?

Naw, that would be /useful/. <sigh>.




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

Date: Thu, 03 Dec 1998 22:49:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: DB handles, best approach?
Message-Id: <LzE92.6$MF3.175@nsw.nnrp.telstra.net>

In article <746fsi$6dh$1@nnrp1.dejanews.com>,
	frogsmock@my-dejanews.com writes:

> I am setting up a site that uses Apache, mod_perl, and PostgreSQL (I
> am using the DBI module to talk to PostgreSQL).	My question is,
> what is the most efficient approach to use in creating/tearing down
> the database handles?  Should I create them in each perl script that
> make SQL calls, or should I create a database handle during httpd
> startup that all the scripts can use?  It will be a data-oriented
> site, so most pages will make SQL calls.  PROs and CONs would be
> appreciated, along with any other tips for improving the performance
> of a site that makes frequent SQL calls using mod_perl and DBI.

I haven't ever done this in perl, but generally:

What I normally do is create a pool of handles that can be used by a
number of processes. If it's all in the same multithreaded process,
it's simply some shared pool in memory somewhere. If there are going
to be many processes (for example CGI) there is some work to be done
to figure out what the best approach is. You can write some 'proxy'
server process, that opens and manages a pool of connections to your
database. The clients get their information from that process. Of
course, that middle tier has to do work as well, and clients have to
connect to it as well. If the middle tier is on the same machine as
all the processes, and the database isn;t this could give you an
advantage. If the database is also on the same machine, the advantage
may be non-existent, or you may be doing more work with the middle
tier.

Of course it also depends on your network configuration, OS, database
type etc. Unfortunately I don't know much about any of the actual
implementations you use, which is why I am being so general.
And of course it depends on how many connections you get, and the
amount of work that is done in a single transaction. If it's a lot of
work, the work to open and close a db connection may not be
significant.

The actual techniques are not really perl specific, and I suspect that
in a group where they talk about database client programming you may
be able to pick up some nifty things.

The simplest approach is to initially let all CGI clients open their
own connection. If you find that your database server is doing most of
its work opening and closing connections, then you should start
looking for something else. Programming a pool of connections is not a
trivial exercise, although interesting, so make sure it will be worth
it.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd.       | am.
NSW, Australia                      | 


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

Date: Thu, 3 Dec 1998 15:55:45 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Directory permission.
Message-Id: <1d1747.6s2.ln@metronet.com>

Christian H. Knudsen (webmaster@bluegalaxy.hypermart.net) wrote:
: I have a directory with a 700 permission. I would like a script
: to be able to change the permission to 777 (for example),
: write some files in the dir and the chmod back to 700. The
: reason for this is that I would like the files in the dir to be
: hidden from any users, as it will contain secret info like
: passwords and user names.


   Uhhh. If a Bad Guy comes around while you are doing the
   "write some files" part, he gets anything he wants.

   Your secrets will not be so secret.


   If they are *important* secrets, then you better take a little
   more care in safeguarding them.


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


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

Date: Thu, 03 Dec 1998 21:32:22 GMT
From: sprintfer@yahoo.com (Mike D.)
Subject: Re: Directory permission.
Message-Id: <366702c8.890069191@nntp.cts.com>

On Thu, 03 Dec 1998 19:56:12 GMT, "Christian H. Knudsen"
<webmaster@bluegalaxy.hypermart.net> wrote:

The owner of the directory has to change the permissions (as you
probably know).  Many servers run under the name "nobody" so you if
you definately want to do this, do this

chown nobody dirname

But of course, you are now running into more security and access
issues.



>I have a directory with a 700 permission. I would like a script
>to be able to change the permission to 777 (for example),
>write some files in the dir and the chmod back to 700. The
>reason for this is that I would like the files in the dir to be
>hidden from any users, as it will contain secret info like
>passwords and user names.
>
>My problem is that the script (naturally) isn't able to chmod
>the dir to 777 because of the 700 permission!
>
>Any ideas?
>
>-- Christian H. Knudsen
>

Mike D.
sprintfer@yahoo.com


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

Date: Thu, 03 Dec 1998 15:56:32 -0500
From: Xnera <nospam.xnera@cyberenet.net>
Subject: Does crypt() act differently in different versions?
Message-Id: <3666FB00.12E0047D@cyberenet.net>

My service-provider did some kind of 'upgrade' to the server last night.

Suddenly half of my perl scripts didn't work anymore.  It looked like
somehow the perl version got reverted to 4.0.  I told the guy and he
said he fixed it.  (it's now 5.004_04)

The problem now is crypt seems to be acting differently.  What used to
work just fine for checking passwords on log in doesn't work
anymore.

Here is my test:
if ( crypt($entered_pw, substr($onfile_pw, 3 , 2) ) eq $onfile_pw) )

and it fails where it used to pass.  I printed out the data and this is
what I get:

crypt($entered_pw, substr($onfile_pw, 3 , 2) ) = cW.tXTHid8mVQ
$onfile_pw = $1$cW$H1fdjxquV3LxzleWrCvQT

am I doing something wrong?  Why did it used to work and now it doesnt?
I don't know the exact version of perl I was using before the 'fixed' my

server.

Thanks for anyhelp,
Karen
xnera@cyberenet.net



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

Date: Thu, 03 Dec 1998 22:56:23 +0100
From: Patrick Egloff <patrick@horgen.org>
Subject: File Upload / cgi-lib.pl
Message-Id: <36670907.CF24F8AD@horgen.org>

Hy

Because I'd like to create a file-upload-script using cgi-lib.pl a would
need access to the perl directory. Unfortunately I don't have so on my
rented server.

Does anyone know how to place this file somewhere else on the server and
refer to that location in the script? I tried it with ../../ but that
didn't work.

Or do you have a good hint how to make a script for file uploading via
forms without having access to the system direcories?

Thanks for your answers and best regards,
Patrick


Line in the script refering to the needed file:
require "../../cgi-lib.pl";

Error-Log:
Can't locate ../../cgi-lib.pl in @INC (@INC contains:
/usr/lib/perl5/i686-linux/5.00404 /usr/lib/perl5
/usr/lib/perl5/site_perl/i686-linux /usr/lib/perl5/site_perl .) at
/www/cgi-bin/upload/fup.pl line 7.
[Thu Dec  3 16:24:12 1998] access to /www/cgi-bin/upload/fup.pl failed
for 195.141.225.107, reason: Premature end of script headers


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

Date: Thu, 03 Dec 1998 22:50:14 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: File with Sendmail
Message-Id: <GAE92.469$8d6.67300@news.shore.net>


Daniel Boksjv <daniel@boksjo.com> wrote:
: I'm writing a script that is supposed to send me a certain file on my
: e-mail. I'm using sendmail to do this, since I have used sendmail before in
: another script. The thing is that now I want to redirect a file to sendmail,
: not only a certain text. What syntax do I use in a Perl program for this?
: Maybe:

: exec 'sendmail', 'my@email.com <directory/file';

I would usually use "mail" for something like this rather than sendmail,
but I don't know if there's a difference in this simple case.

You may be running into a problem because you're passing "exec" two
different parameters (which would normally bypass the shell) but you're
using a shell redirection character "<" in your command. Try putting
the whole command into one string, e.g.
	exec 'mail my@email.com < directory/file';

and see if that makes any difference (of course you know that this method
is insecure with unknown, user-inputted data, but it may work for your
purposes).

--Art
-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: 3 Dec 1998 22:21:16 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: File with Sendmail
Message-Id: <7472ss$ce$1@gellyfish.btinternet.com>

On Thu, 3 Dec 1998 16:22:58 +0100 Daniel Boksjv <daniel@boksjo.com> wrote:
> Hi,
> 
> I'm writing a script that is supposed to send me a certain file on my
> e-mail. I'm using sendmail to do this, since I have used sendmail before in
> another script. The thing is that now I want to redirect a file to sendmail,
> not only a certain text. What syntax do I use in a Perl program for this?
> Maybe:
> 
> exec 'sendmail', 'my@email.com <directory/file';
> 
> I have scanned the man pages of sendmail, but haven't found anything on
> proper syntax for this.
> 

You might try using one of the modules described in perlfaq9 or perhaps
you might want to run 'sendmail' in a piped open thus:

open(MAIL, '| /usr/lib/sendmail -t') || die "cant run sendmail - $!\n";

print MAIL "To:  blah@woof.com\n";
print MAIL "From: me@catfood.com\n";
print MAIL "Subject: TeeHeeHee\n\n";

open(MYFILE,"directory/file") || die "Blah blah -$!\n";

while(<MYFILE>)
  {
    print MAIL $_;
  }

close(MAIL) || die "Ooer -$!\n";
close(MYFILE);

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Thu, 03 Dec 1998 21:18:01 GMT
From: phter@meganet.net
Subject: Need help editing a script
Message-Id: <746v66$k1a$1@nnrp1.dejanews.com>

I found this great perl script, but it is not meant for cgi input. I tried to
convert it by setting all the inputs into an array, but it didn't work.
Please, if you know how to make this script accept cgi input, mail it back to
me corrected.------------snip-------------#!/usr/bin/perl
############################################################### ScanPort v1.0
# Written By: Samuel Sparling (sparling@slip.net)# # Copyright ) 1998 Samuel
Sparling# All Rights Reserved.# # Thanks to gargan for the idea of a perl
port scanner## Tested on: # Windows 95 w/ ActiveWare's perl for Win32 (perl
5.003_07) # SunOS 5.6 w/ perl 5.004_04# Red Hat Linux 5.1 w/ perl 5.004_04#
##############################################################use Socket;
print "ScanPort v1.0\n\n";print "Host: ";$remote=<STDIN>; chop($remote) if
$remote =~ /\n$/;print "Start Port: ";$start=<STDIN>; chop($start) if $start
=~ /\n$/;print "Stop Port: ";$stop=<STDIN>; chop($stop) if $stop =~
/\n$/;print "Log Session?(y/n)";$yn=<STDIN>; if($yn =~ /y/i){  $log = 1;     
 $logfile="$remote".".scan";	 print "Log File [$logfile]: "; 
$file=<STDIN>;	chop($file) if $file =~ /\n$/;	if($file ne "") 	{    
	  $logfile=$file; }	  open(LOG,">>$logfile") || die("Unable to
write to $logfile!");} $time = localtime(time); print "\nScanning ports
$start to $stop on $remote at $time\n\n";      if($log == 1)   {	     
 print LOG "\nScanning ports $start to $stop on $remote at $time\n\n";	 }   
   $current=$start;	   while($current < $stop) { &scan_port($current);   
     $current++;     }$time = localtime(time);print "\nFinished scan of
$remote at $time\n";	     if($log == 1)   {		     print LOG
"\nFinished scan of $remote at $time\n";	      close(LOG);     }sub
scan_port{$port = shift(@_);	   if ($port =~ /\D/) { $port =
getservbyname($port, 'tcp'); }	   die("No port specified.") unless $port;   
     $iaddr = inet_aton($remote) || die("Failed to find host: $remote");    
$paddr = sockaddr_in($port, $iaddr);	$proto = getprotobyname('tcp');      
  socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die("Failed to open socket:
$!");	      if(connect(SOCK, $paddr))# || die("Unable to connect: $!");    
{		print "Listening on port: $port\n";		if($log == 1)
  {			  print LOG "Listening on port: $port\n";	  } }
    close(SOCK);}exit; ------------snip-------------

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 03 Dec 1998 15:03:52 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Need help editing a script
Message-Id: <m3vhjsannb.fsf@moiraine.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

phter@meganet.net writes:

<snip>

Please tell me this is an intentional troll and that no
human being could possibly be this stupid.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
Supporter of grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 3 Dec 1998 22:16:59 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Need help editing a script
Message-Id: <7472kr$brb$0@206.165.167.248>

phter@meganet.net wrote in message <746v66$k1a$1@nnrp1.dejanews.com>...
>I found this great perl script, but it is not meant for cgi input. I tried
to
>convert it by setting all the inputs into an array, but it didn't work.

>
>Please, if you know how to make this script accept cgi input, mail it back
to
>me corrected.------------snip-------------#!/usr/bin/perl


The three principal virtues of a programmer are Laziness, Impatience,
and Hubris.                             -- Larry Wall

I hate to say it, but do you think there is at least one missing?  Because
this person seems to have the rest covered.

AmD






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

Date: Thu, 03 Dec 1998 21:40:12 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: New idiom?
Message-Id: <0zD92.2495$CY1.9977164@news.itd.umich.edu>

In article <3665DAF5.8499BC41@shaw.wave.ca>,
Rick Delaney  <rick.delaney@shaw.wave.ca> wrote:
>Sean McAfee wrote:
>> Undefined value assigned to typeglob at ...
>> when each() returned undef after iterating through the entire hash.

>Are you sure there's nothing else wrong with the other code?  I was able
>to use your idiom with -w and received no warnings.

This is what I did:

%hash = ( foo => { bar => 5 }, baz => { bletch => 10 } );
while ((my $a, local *b) = each %hash) {
	while (my ($c, $d) = each %b) {
		print "$a: $c => $d\n";
	}
}

This code runs fine without -w, but I get the above-mentioned warning when
I add it.  I neglected to mention my environment in my original article,
but I'm using 5.005_02 on Solaris 2.6.

>> Oh well.  It looked like such a nifty little idiom...

>And it still does.  Kudos and thanks.

Glad you like it.  I'm finding that one must exercise some caution when
using it, though.  For a project I'm working on, I wanted to create tied
hashes that would act like normal hashes, but would retrieve from a (large)
hash of default values when a nonexistent key was given:

%default = ( a => "b", c => "d", e => "f", ... );
%param = ( g => "h" );
print $param{"g"}, $param{"a"};  # prints "hb"

This was easy enough to do:

package Parameters;
use Tie::Hash;
@ISA = 'Tie::StdHash';
sub FETCH {
	my ($self, $key) = @_;
	exists $self->{$key} ? $self->{$key} : $::default{$key};
}

But I ran into deep-recursion trouble when I tried something like this:

while ((my $host, local *default) = each %hosts) {
	print $default{"key not present in %{ $hosts{$host} }"};
}

Fortunately, this problem is easily solved, and in the process of solving
it I learned something I never realized before about typeglob aliasing:

*foo = *bar;
$bar = 123;
{ local *bar; print $foo; }

This prints 123, indicating that after *bar is localized, *foo continues to
refer to *bar's original typeglob.  So, all I had to do to solve my problem
was this:

package Parameters;
*default = *::default;
sub FETCH {
	my ($self, $key) = @_;
	exists $self->{$key} ? $self->{$key} : $default{$key};
}

Pretty spiffy.

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Thu, 03 Dec 1998 22:27:40 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: NT won't return anything
Message-Id: <wfE92.43$mE3.104@nsw.nnrp.telstra.net>

In article <3666B956.47BD4B56@email.com>,
	corder <corder@email.com> writes:
> This is really upsetting me.  I wrote a little snippet to test it out.
> 
> $version = `ver`;
> print "Content-type: text/html\n\n";
> print "Version: $version\n<br>";
> print "Error code: $?<br>";

Of course, what you print there is not HTML, while your content-type
suggests that it should be.

Furthermore: is the 'ver' command available when this thing runs as a
CGI script? is it in the path? does it exist at all? Why are you not
checking that it did indeed do something useful?

And this really has not much to do with perl.

# perldoc perlfaq9
(first question)
     My CGI script runs from the command line but not the
     browser.   (500 Server Error)

Even though you're not getting a 500 error, you still should read this.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd.       | reflects this.
NSW, Australia                      | 


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

Date: Thu, 03 Dec 1998 21:13:40 GMT
From: wyndo@cxo.com
Subject: Re: Open or Create a file
Message-Id: <746uu1$jso$1@nnrp1.dejanews.com>

In article <mEx82.798$kx1.868@news.ipass.net>,
  "E. Preble" <preble@ipass.net> wrote:
> I have a counter, and it needs to update a particular file when it
> finds it, or else it needs to create the file, chmod it, and then
> update the counter in it.  What is the "create file" command in
> Perl.
>
> Are there security issues with creating files from a script? (no
> exec commands allowed on my server).
>
> E. Preble

Create a file? I use open:

   open FILE, ">$filename";
   print FILE "$counter_num";
   close FILE

That will open/create/overwrite a file.

   open FILE, ">>$filename"; will append.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 3 Dec 1998 21:52:11 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: PC to Unix Problem
Message-Id: <74716b$c8$1@gellyfish.btinternet.com>

On Thu, 03 Dec 1998 11:38:58 -0500 Yao, Hsin (EXCHANGE:MTL:1T83) <hsinyao@americasm01.nt.com> wrote:
> oleynikl@geocities.com wrote:
>> 
>> I've been learning Perl 5.0 for 2 days now. I'm trying to use Perl to solve a
>> problem. Whenever I create an ascii file in a PC environment and upload it to
>> a UNIX account, what I get is newline characters appearing everywhere. (ie: I
>> get ^M in vi and <cr> in nedit).
>> 
> 
> In vi , you can try :
> :1,$s/<ctrl-v><ctrl-m>//g
> the command will appear as:
> :1,$s/^M//g
> and it should get rid of all the ^M .

Not all vi - a - likes will work like this  ViM will show 'no match' on a
DOS file.  You are probably better using a Perl or <ahem> sed script or
perhaps dos2unix or duconv - or perhaps even learn to use FTP properly ;-)

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 3 Dec 1998 21:14:26 GMT
From: mayer1b@unisys.co.at ( hans mayer )
Subject: Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)?
Message-Id: <912719619.549291@scarlatti>

In article <F9i92.17$Fw3.133@nsw.nnrp.telstra.net>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>> create a symbolic link as root:
>> ln -s /opt/LWperl/bin/perl /usr/bin/perl 
>This approach of course requires a symlink for every tool that perl
>installs. There are quite a few, and the number is growing :)

of course, and i have a lot of that in the meantime. :-) 

 
-- 
best regards from vienna           |   mayer (at) unisys.co.at_SPAM
hans                               |   mayer (at) relay.bfl.at_SPAM



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

Date: Thu, 03 Dec 1998 22:23:56 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl to awk?
Message-Id: <0cE92.42$mE3.104@nsw.nnrp.telstra.net>

In article <3669a59a.170258298@news.ford.com>,
	cpierce1@mail.ford.com (Clinton Pierce) writes:

> Awk's not that bad!   I still haven't found a more elegant way to do
> this in perl:
> 
> 	ps -ef | awk '{print $1}'

In fact, awk is better at some things than perl.

look at the entry for $/ in perlvar to find an example of this. Yours
also is a good one. While perl can do that, awk simply does it better.

perl is a tool. It does not replace all other tools, it augments the
set you can use.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd.       | negative.
NSW, Australia                      | 


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

Date: 3 Dec 1998 16:04:57 -0600
From: ref@realtime.net (ref)
Subject: Please help with search/find PERL script
Message-Id: <7471u9$r1p@jake.bga.com>

In my work network, we're running AIX version 4. I'm on a Mac, interfacing
with the shell using NCSA Telnet.

I have a PERL string that works nicely for searching and replacing all
occurrences of a text string in files with filenames containing a
given text string.

For example, I want to change all occurrences of "dog" to "cat" in all
files with filenames containing the string "rock."  I have files named
rock1, rock2, rock3, rockA, rockB, and so on. I use the command:

perl -pi.bak -e 's/dog/cat/g' rock*

Works perfectly, and creates .bak backup files of the original files
before making the changes.

Problem: this command string works *only* on files in the present working
directory.  If the PWD contains subdirectories, which may contain even
more directories, and "rock" files are scattered throughout these directories,
they aren't affected. You have to go to each directory individually
and run the command. This is not insignificant when you're looking at
a web site containing *dozens* of directories.

What PERL command string would change all occurrences of "dog" to "cat" in
files with filenames containing the string "rock," not only in the present
working directory, but in all levels of its subdirectories as well?

Thanks,
Ron M.


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

Date: Thu, 03 Dec 1998 22:31:43 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Please help with search/find PERL script
Message-Id: <jjE92.2500$CY1.10003403@news.itd.umich.edu>

In article <7471u9$r1p@jake.bga.com>, ref <ref@realtime.net> wrote:
>In my work network, we're running AIX version 4. I'm on a Mac, interfacing
>with the shell using NCSA Telnet.
[snip]

>perl -pi.bak -e 's/dog/cat/g' rock*

>Works perfectly, and creates .bak backup files of the original files
>before making the changes.

>Problem: this command string works *only* on files in the present working
>directory.
[snip]

>What PERL command string would change all occurrences of "dog" to "cat" in
>files with filenames containing the string "rock," not only in the present
>working directory, but in all levels of its subdirectories as well?

perl -i.bak -pe 's/dog/cat/g' `find . -name rock\*`

Or, you could let Perl do everything itself:

perl -MFile::Find -i.bak -pe \
    'BEGIN { find sub { push @ARGV, $File::Find::name if /^rock/ }, "." } \
     s/dog/cat/g'

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Thu, 03 Dec 1998 21:27:22 GMT
From: jstephens@bridge.com
Subject: Problem with Dynaloader and Shared Libraries
Message-Id: <746vnm$kj0$1@nnrp1.dejanews.com>

I remember seeing this somewhere, but can't find it...I have installed
a shared library into the perl tree, but when I try and use it, I get:

Can't load '/opt/perl5/lib/site_perl/5.005/PA-RISC1.1/auto/Vanperl/Vanperl.sl'
for module Vanperl: No such file or directory at
/opt/perl5/lib/5.00502/PA-RISC1.1/DynaLoader.pm line 168.

 at ./bob line 3
BEGIN failed--compilation aborted at ./bob line 3.

The problem:  The file exists and is readable.  As you can see, I am using
perl 5.005_02, and I believe that Vanperl.sl was compiled under 5.003.  Is
there an incompatibility with shared libraries and the different versions
of perl?  I remember seeing something about the perl guts changing between
5.003 and 5.004 which requires a re-compiling.  Can anyone verify this for
me and point me to the correct documentation?

TIA

Jeff

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 3 Dec 1998 22:57:40 +0100
From: "Marcel Ouwendijk" <mouwend@casema.net>
Subject: Random integer numbers (1,2,3,4,5....,.....) HOW???
Message-Id: <7471iq$sa7$1@sun4000.casema.net>

I know that there is a function 'rand(value)' but it returns floating point
numbers. But i need a whole integer nummer somwhere between 1 and 15.

Who can help me with this one.

Thanks in advance...
Marcel






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

Date: Thu, 3 Dec 1998 22:58:54 +0100
From: "Marcel Ouwendijk" <mouwend@casema.net>
Subject: Random integer numbers (1,2,3,4,5....,.....) HOW???
Message-Id: <7471l0$f0$1@sun4000.casema.net>

I know that there is a function 'rand(value)' but it returns floating point
numbers. But i need a whole integer nummer somwhere between 1 and 15.

Who can help me with this one.

Thanks in advance...
Marcel








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

Date: Thu, 3 Dec 1998 22:52:01 +0100
From: "Marcel Ouwendijk" <mouwend@casema.net>
Subject: Random integer numbers (1,2,3,4,5....,.....) HOW???
Message-Id: <747183$lop$1@sun4000.casema.net>

I know that there is a function 'rand(value)' but it returns floating point
numbers. But i need a whole integer nummer somwhere between 1 and 15.

Who can help me with this one.

Thanks in advance...
Marcel




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

Date: Thu, 3 Dec 1998 22:58:54 +0100
From: "Marcel Ouwendijk" <mouwend@casema.net>
Subject: Random integer numbers (1,2,3,4,5....,.....) HOW???
Message-Id: <74727f$bem$1@sun4000.casema.net>

I know that there is a function 'rand(value)' but it returns floating point
numbers. But i need a whole integer nummer somwhere between 1 and 15.

Who can help me with this one.

Thanks in advance...
Marcel








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

Date: 3 Dec 1998 22:55:10 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Random integer numbers (1,2,3,4,5....,.....) HOW???
Message-Id: <7474se$i60$1@news.NERO.NET>

In article <74727f$bem$1@sun4000.casema.net>,
Marcel Ouwendijk <mouwend@casema.net> wrote:
>I know that there is a function 'rand(value)' but it returns floating point
>numbers. But i need a whole integer nummer somwhere between 1 and 15.
>
>Who can help me with this one.

Anyone who has read the documentation for int.

Free clue: the answer to your other three copies of this question are
the same.




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

Date: Thu, 03 Dec 1998 15:30:44 -0700
From: Andy Sharp <asharp@hobbes.clarity.ca>
Subject: Re: Regex question
Message-Id: <36671114.1F20A56D@hobbes.clarity.ca>



Duncan Martin wrote:
> I'm reading in a plain text file where each line needs to be split into
> fields.  Each field is either alphanumeric and has " around it or
> numeric without the quotes.
> 
> e.g, possible lines are
> 1,2,"camel",4,"book"
> "a","b",4,"c"
> 
> previously I was doing it in three stages,
> $rawline =~ s/(\",|,\")/\n/gso;
> $rawline =~ s/([0-9]),([0-9])/$1\n$2/go;
> $rawline =~ s/\"//go;
> 
> then splitting on the \n, unfortunately the new data contains fields
> like :
> "123 45,67" which gets turned into two fields, and
> 1,   2,3,4
> where the white space is confusing the whole thing.


Two steps, first line by line:

open(FILE, $filename)
while(chomp($n = <FILE>)){  #splits a file on a new line, and removes
the \n on the end
    $n = s/\"//g;  	    #Get rid of those quotes  (unless you have ","'s
in your data)
    @fields = split (/,/,$n);  #split the data on commas
}
close(FILE); # be nice :)

White space shouldn't be a problem, if you just split on commas - the
only problem is if your data contains commas which are not de-limiters. 
If so - then just search for ," ", or "," and replace it with a unique
delimeter for the interm

scanning left to right for quotes is /"([^"]*)"/  <- captures anything
in quotes, but not the quotes


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

Date: Thu, 03 Dec 1998 16:43:44 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: Fernando Nunez Benito <fnunez@mail.cern.ch>
Subject: Re: signals on Windows nt
Message-Id: <36671420.DBDD1FF1@mail.uca.edu>

[cc'd to fnb]

Fernando Nunez Benito wrote:
> 
> Hi all,
> I finished implemented a monitoring program for different unix platforms
> and when I tried to port it to Winndows NT, I realised "frok()" function
> was not implemented (surprising) and signals didn't work.

Well, "frok()" is not implemented on WinNT, however, "fork()" is.

> I fixed the first problem, but I couldn't make signals work properly on
> Windows NT. Even with a simple example like this one:
> 
>         $SIG('INT')='my_handler';
>         [further code snipped]
> Any idea?

Yep, signals don't work (at least not reliably) on WinNT. Don't (try to)
use them.

Cameron
camerond@mail.uca.edu


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

Date: Thu, 03 Dec 1998 22:20:18 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Solaris passwd/shadow & getpwuid()
Message-Id: <C8E92.41$mE3.104@nsw.nnrp.telstra.net>

In article <7468aq$rh$1@mendelevium.btinternet.com>,
	D.Haywood@btinternet.com (Dave Haywood) writes:
> Hi,
> 
> Environment: Solaris 2.6, Perl 5.004_04, sun4-solaris
> 
> I tried the "crypt" example from the perlfunc man page but don't see how it 
> can work in a shadow password system!  The code given is:

# perldoc perlfaq8
     How do I modify the shadow password file on a Unix system?

     If perl was installed correctly, and your shadow library was
     written properly, the getpw*() functions described in the
     perlfunc manpage should in theory provide (read-only) access
     to entries in the shadow password file.  To change the file,
     make a new shadow password file (the format varies from
     system to system - see the passwd(5) manpage for specifics)
     and use pwd_mkdb(8) to install it (see the pwd_mkdb(5)
     manpage for more details).

Of course, if the shadow library is broken, it won't work. You may
want to check on a solaris specific group what the story is with Sun's
implementation of this. You could also write a little c program to
check what it does.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.       | again. Then quit; there's no use being
NSW, Australia                      | a damn fool about it.


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

Date: 3 Dec 1998 21:01:25 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Strange setpgrp()/root interaction?
Message-Id: <746u75$at1@mercury.adc.com>

In article <746cs2$929$1@crchh14.us.nortel.com>,
Karlon West <karlon@bnr.ca> wrote:
>I'm not sure what question to ask, only that the perl program
>is dieing, and I can't tell why.
>
>If I run the following code as a normal user on a Solaris or HPUX box,
>all three lines are printed, which is what you'd expect.
>
>If I run it as root on a Solaris box (I don't have root password on the
>HP) only the first two lines are printed, and I get a strange exit code.
>Any ideas?  Is it perl related?  Is it OS related?
>
>This is just the smallest reproducible code.  The real program has
>several hundred lines, function calls, loops, updates of other
>filehandles, etc between the setpgrp and the read from STDIN, and they
>are all executed normally, but something strange is happening when
>trying to read from STDIN AFTER I do a setpgrp() as "root".
>
>Here's the code: "This is perl, version 5.004_01"
>It's a solaris 2.5, sun4m sparc SUNW,SPARCstation-20
>---------------------------------------
>#!/usr/bin/perl -w
>use diagnostics;
>use strict;
>
>print "this is printed\n";
>$a=<STDIN>;
>setpgrp(0,$$);
>print "this is printed...\n";
>$a=<STDIN>;
>print "i guess it worked\n";
>--------------------------------------

Finally got through trying this here, and didn't have any trouble with
it, either as a normal user or as root.  We've got Perl 5.004_01 and
Solaris 2.6.  Specifically,

$ perl -v
This is perl, version 5.004_01

$ uname -a
SunOS wst146 5.6 Generic_105181-06 sun4m sparc sun4m

However, I think what you're seeing, and the fact that I'm not seeing
it, might be traceable back to two things.  First, when I run the
program from the command prompt, I see from ps that it's already the
process group leader, so the setpgrp doesn't really do anything.
Second, the following from the setpgrp(2) man page:  "...and releases
its controlling terminal."  If the program is no longer associated
with a terminal, I wouldn't expect a read from STDIN to work very
well.

HTH

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


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

Date: Thu, 03 Dec 1998 22:35:07 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Strange setpgrp()/root interaction?
Message-Id: <vmE92.50$mE3.104@nsw.nnrp.telstra.net>

In article <746cs2$929$1@crchh14.us.nortel.com>,
	karlon@bnr.ca (Karlon West) writes:

> setpgrp(0,$$);

A few notes:

(all of this on a Solaris 2.6/SPARC)

# perldoc -f setpgrp
=item setpgrp PID,PGRP

Sets the current process group for the specified PID, C<0> for the current
process.  Will produce a fatal error if used on a machine that doesn't
implement setpgrp(2).  If the arguments are omitted, it defaults to
C<0,0>.  Note that the POSIX version of C<setpgrp()> does not accept any
arguments, so only setpgrp C<0,0> is portable.

Solaris's setpgrp is POSIX compliant, so your arguments will have no
effect, and will effectively be (0,0).

# man setpgrp
[snip]
     pid_t setpgrp(void);
[snip]
DESCRIPTION
     If the calling process is  not  already  a  session  leader,
     setpgrp()  makes  it one by setting its process group ID and
     session ID to the value of its process ID, and releases  its
     controlling  terminal.  See intro(2) for more information on
     process group IDs and session leaders.

This mentions that setpgrp releases its controlling terminal. I
suspect that that is where your problem originates.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: Thu, 3 Dec 1998 16:09:07 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Variable modification in module without "return"?
Message-Id: <746um9$ng$1@camel29.mindspring.com>

Jennifer Davis wrote in message <3666D24C.A1F919A9@osprey.arc.nasa.gov>...
>I want to have a module modify a non-global variable.
>I don't want the variable to be returned via "return"
>because I am using return for my success/failure codes
>(and eventually I might want to modify more than one
>non-global variable). (I'm trying to use pass-by-
>reference as I do in C. Perhaps I can't do this in
>Perl?)
>Here is the jist of what I'm doing:
>local $x = "";
>$result = b::a(\$x);
>print "$x";  # this results in the null string
>b.pm has:
>a()
>{
>  $pkg = shift;
>  $x = shift;
>  $x = "bubba";
>  print "$x"; # this results in "bubba"
>  return 1;
>  # normally, the value would be returned here as
>  # return \$x;  ...but I don't wanna!
>}
>(These are extremely simplified names; I assure you
>that I don't use one-letter names in my real code.
>I am using use strict; and -w.)
>Thanks much for any help. I've been digging through
>"Programming Perl," "Advanced Perl Programming," and
>various web sites but still can't figure this out.


Not that my answer is any different than the others but this is new to me
too so it took me a while to generate my example.  I included exporting the
subroutine a (or is it the function a) so you could use it within the
script.  If folks see errors in my example I would appreciate the feedback.
HTH

AmD

b.pm
----------------
package b;
use strict;
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = qw (Exporter);
@EXPORT = qw(&a);

sub a {
  my $change = shift;
  $$change = "bubba";
  print "In b: $$change\n"; # this results in "bubba"
  return 1;
}
1;
-------------------
script:

#!/usr/local/bin/perl -w
use strict;
use lib 'd:\\perl testing package';
use b;
my $x = 'hubba';
my $y;
print "$x\n";

my $result = b::a(\$x);
print "The x is changed to $x\n";

$result = a(\$y);
print "The y is also changed to $y\n";
--------





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

Date: Thu, 3 Dec 1998 21:19:12 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Variable modification in module without "return"?
Message-Id: <F3Er81.81x@world.std.com>

Jennifer Davis <jdavis@osprey.arc.nasa.gov> writes:

>I want to have a module modify a non-global variable.
>I don't want the variable to be returned via "return"
>because I am using return for my success/failure codes
>(and eventually I might want to modify more than one
>non-global variable). (I'm trying to use pass-by-
>reference as I do in C. Perhaps I can't do this in
>Perl?)

In many cases, you can use "undef" or an empty list to signal
failure. Even if you want to modify more than one item passed to you,
you can return them as a list. This style of programming is a hint
towards Perl's "bourne shell"ish influences. You have a list things
that go in, and a list of things that go out, and the subroutines
start to act like Unix filters.

Perl does all of its parameter passing as pass-by-reference. You're
explicitly making a copy when you assign them to named parameters. So
technically if you just modify "$_[0]", you'll modify the first
parmeter in the caller.

You are better off doing what you are doing, though. Explicitly
creating a reference to the variable give the person using your
subroutine a better clue that the variable may be different when they
get it back. You're only problem though, is that perl does not
explicitly dereference variables for you. If you pass a reference to
the function, you have to get back to the data through the reference
when inside the function.

You are also mixing up function call with method call syntax. Saying
"b::a(\$x)" is a simple function call to the subroutine "a" in the
package "b". "b->a(\$x)" is a method call to the class method "a" of
the class "b". The first is passed a single element in the argument
array @_ consisting of a refernce to $x. The second is passed the
class name as a first argument, and the ref to $x as a second. You're
calling a simple subroutine and then throwing away your first
argument.

I think what you want is something like this:

my $x = "";  # my is preferable to local()
my $result = b::a(\$x);
print "$x\n";  # this results in "bubba"

# Put this in a separate file if you would like. It doesn't matter.
package b;

# notice it is "sub a", not "a()" the keyword "sub" is needed
# and the parens create a prototype for the subroutine which 
# may screw you up.
sub a {
  my $x = shift; # get the reference passed to the sub

  $$x = "bubba"; # change the thingy $x points to to "bubba".
  print "$$x\n"; # print the thingy $x points to to be sure.

  return 1; # Signify a successful call.
}
-- 
Andrew Langmead


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

Date: Thu, 03 Dec 1998 21:50:04 GMT
From: sprintfer@yahoo.com (Mike D.)
Subject: wantarray() question.
Message-Id: <366705c7.890836234@nntp.cts.com>

I have a function called employees, I would like it to return the
number of employees if called in scalar context or the all the
employees if called in list context.  This function is part of a
employer class.  The structure of the data is:

	$employer->{employees}[];

Where the employee data is actually an anon array.

The employees function looks like:

sub employees {
  my $self = shift;
  if (defined($self->{employees}) && ref($self->{employees})) {
    return(@{$self->{employees}});
  }
}

Later I call this function in three ways:

$num_employees = $employer->employees;
if ($employeer->employees);
foreach $employee ($employeer->employees)...

So here is the question, would it be more efficient to rewrite the
fuction like:

sub employees {
	my $self = shift;
	if (defined($self->{employees}) && ref($self->{employees})) {
		if (wantarray()) {		
			return(@{$self->{employees}});
		} else {
			my $num_elements = @{$self->{employees}};
			return($num_elements);
		}
	}
}



Mike D.
sprintfer@yahoo.com


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

Date: Thu, 03 Dec 1998 22:00:01 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Why is "... @foo ..." occasionally a syntax error?
Message-Id: <BRD92.40$mE3.104@nsw.nnrp.telstra.net>

In article <3666B243.6CDC6AD5@eddie.mit.edu>,
	John Chambers <jc@eddie.mit.edu> writes:
> Ala Qumsieh wrote:
>> 
>> John Chambers <jc@eddie.mit.edu> writes:
> 
>> hmmm... if you had been using the correct pragmas, then you would've
>> been forced to declare all your variables.
>> 
>> Remeber these:
>> 1) ALWAYS use the -w switch.
>> 2) ALWAYS "use strict;"
> 
> Well, I use them a lot during debugging, but tend to turn them off for
> "production" use.  The main reason is that -w causes the web server's
> error log to grow rapidly, with every CGI script producing a flood of
> "used only once: possible type" and "Use of uninitialized value" messages.
> If I knew a way to turn off such spurious message, I'd do so, but if
> it's possible, I haven't yet stumbled across it. I consider perl's use 

If you use both, you won't get the first one of the two (because you
will be forced to predeclare your variables), and if you always
initialise your variables, you won't get the second.

If you really don't want to do that, even though it will be a
tremendous help when debugging, and you will find that your code
becomes much more robust, maintainable and elegant, you can always
write your own handler for $SIG{__WARN__}

# perldoc perlvar
     %SIG  $SIG{expr}
[snip]
             Certain internal hooks can be also set using the
             %SIG hash.  The routine indicated by $SIG{__WARN__}
             is called when a warning message is about to be
             printed.  The warning message is passed as the first
             argument.  The presence of a __WARN__ hook causes
             the ordinary printing of warnings to STDERR to be
             suppressed.  You can use this to save warnings in a
             variable, or turn warnings into fatal errors
[snip]

You can also use it to ignore certain warnings, but I would strongly
advise against that. The warnings are there for a purpose.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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