[8623] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2240 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 3 08:18:21 1998

Date: Fri, 3 Apr 98 05:01:09 -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, 3 Apr 1998     Volume: 8 Number: 2240

Today's topics:
        [SOURCE] rot90: New and better MIME format (Tom Christiansen)
    Re: [SOURCE] rot90: New and better MIME format <neeri@iis.ee.ethz.ch>
    Re: ampersand in replacement (Bart Lateur)
    Re: Anon Scalar Expression (was: Evaluate expression in (Bart Lateur)
    Re: Cgi Perl Programming problem <grinch@whoville.com>
    Re: Conversion of Excel file to Text file <Russell_Schulz@locutus.ofB.ORG>
    Re: current week (Bart Lateur)
    Re: eval with text files (Andy Wardley)
    Re: File Comparison on NT? <ebohlman@netcom.com>
    Re: foreach loop & current element index (Bart Lateur)
        Help mailing in Perl <patb@mround.bt.co.uk>
    Re: How should I send a signal 'INT' to a remote server <jamesr@aethos.co.uk.nospam>
        Is anyone using Perl for 3d graphics? <grinch@whoville.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? <bcoleman@mindspring.com>
    Re: Looking for ANY Suggestions on parsing this line!! (Andre L.)
        Ltrim at ASCII Zero. <jc@tdf.net>
    Re: need help with regexp alternation problem <ebohlman@netcom.com>
    Re: password input (TReitstett)
    Re: Perl dies with segmentation fault and leaves a core <himmel2@ibm.net>
    Re: Ping <qdtcall@esb.ericsson.se>
        Problems with database-related module (Albert Strasheim)
    Re: Problems with database-related module <ebohlman@netcom.com>
    Re: processing big file <sekchye@singnet.com.sg>
    Re: readdir/grep/map (Bart Lateur)
        reading dbf file and outputting gif file <broc.stirton@amd.com>
    Re: reading dbf file and outputting gif file <ebohlman@netcom.com>
    Re: Strange behavior with NET:Ftp under Cron <grinch@whoville.com>
    Re: Subscribing to a list without duplicates <ebohlman@netcom.com>
    Re: Unitialized values (was Re: use strict and GD) (Tom Mornini)
    Re: upload a file to ftp site <daveh@sift.co.uk>
    Re: Weird Effects w/ "require" <Tony.Curtis+usenet@vcpc.univie.ac.at>
        What does a reference refer to? <raconway@atos-group.com>
    Re: What does a reference refer to? <grinch@whoville.com>
    Re: what is wrong with being a novice ?? (Craig Pickles)
        Why $ENV{'PWD'} is not equal to `pwd` ? <James_Yang@via.com.tw>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 3 Apr 1998 10:56:53 GMT
From: tchrist@perl.com (Tom Christiansen)
Subject: [SOURCE] rot90: New and better MIME format
Message-Id: <6g2f9l$lup$1@csnews.cs.colorado.edu>

This is a multi-part message in MIME format.
 
------=_NextPart_000_0004_01BD5E9F.68E39C00
Content-Type: text/x-rot90; charset="iso-8859-1"

I s k m o f w t T c s p p p t v t i r t t    -
  i e e w o a h h o h o o o h e h n u h o    -
h n e s n r n e i o o p r p o r i c n e p    t
a c p s   m t   s l u u t u s t n l          o
v e s a i a   a     l l i l e i k u t b a    m
e     g n t t c i t d a o a   c   d h o s 
  e s e v s o t s h   r n c w a I e e t   
d v e s e     i   i b   s e h l       t w 
e e n   n t g o a n e i   , o l s a l o e 
c r d i t h e n   g   n o     . h   i m l 
i y i n e a t   r   e   f l r   o w n   l 
d o n   d t   t e t x c   i e   u a e t ? 
e n g t     i o a h t e t k a D l y s o   
d e   h   I n o l a r r h e d o d         
    m e       . l t e t e         t f t   
t e e i     o   y   m a     t y   o r h   
h l   r     n       e i     e o     o e   
a s                 l n     x u     m     
t e                 y       t             

------_NextPart_000_0004_01BD5E9F.68E39C00

Content-Type: application/x-perl; charset="iso-8859-1"

#!/usr/bin/perl 
# rot90 - tchrist@perl.com

$/ = '';

# uncomment for easier to read, but not reversible
#@ARGV = map { "fmt -20 $_ |" } @ARGV;

while ( <> ) {
    chomp;
    @lines = split /\n/;
    $MAXCOLS = -1;
    for (@lines) { $MAXCOLS = length if $MAXCOLS < length; }
    @vlines = ( " " x @lines ) x $MAXCOLS;
    for ( $row = 0; $row < @lines; $row++ ) {
	for ( $col = 0; $col < $MAXCOLS; $col++ ) {
	    $char = ( length($lines[$row]) > $col  )
		    ? substr($lines[$row], $col, 1) 
		    : ' ';
	    substr($vlines[$col], $row, 1) = $char;
	}
    }
    for (@vlines) {
	# uncomment for easier to read, but not reversible
	s/(.)/$1 /g;
	print $_, "\n";
    }
    print "\n";
}


------=_NextPart_000_0004_01BD5E9F.68E39C00--

-- 
	Tom Christiansen	tchrist@jhereg.perl.com


There's no such thing as a simple cache bug. --Rob Pike


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

Date: 03 Apr 1998 14:46:20 +0200
From: Matthias Neeracher <neeri@iis.ee.ethz.ch>
Subject: Re: [SOURCE] rot90: New and better MIME format
Message-Id: <86zpi3qdib.fsf@gwaihir.ethz.ch>

tchrist@perl.com (Tom Christiansen) writes:

> This is a multi-part message in MIME format.
>  
> ------=_NextPart_000_0004_01BD5E9F.68E39C00
> Content-Type: text/x-rot90; charset="iso-8859-1"

I don't know too much about MIME, but shouldn't this be an Encoding: instead of
a Content-Type?

Matthias

-- 
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "I'm set free to find a new illusion" -- Velvet Underground


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

Date: Fri, 03 Apr 1998 07:39:16 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: ampersand in replacement
Message-Id: <352c90fb.4598321@news.tornado.be>

David Grove wrote:

>Which is correct?
>
>s/</&lt;/g
>
>or
>
>s/</\&lt;/g

There is NO NEED to put a backslash in front of the ampersand. But that
doesn't mean that it isn't allowed. It is.

Look in the docs for regular expressions and meta characters
(perlre.pod). You'll see that Larry took special care so that putting a
backslash in front of any non-word character to quote it, is safe.
Always.

HTH,
Bart.


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

Date: Fri, 03 Apr 1998 07:33:20 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Anon Scalar Expression (was: Evaluate expression inside print "")
Message-Id: <35268b57.3158242@news.tornado.be>

Kevin Reid wrote:

>\($x,$y,$z) is equivalent to (\$x,\$y,\$z).

But apparently, only in a list context.

In a scalar context, it returns a SCALAR ref, and the comma's are
interpreted as the comma operator. I think this code would be quite
equivalent:

	do { my $result = ($x,$y,$z); \$result }

	Bart.


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

Date: Fri, 3 Apr 1998 03:25:51 -0500
From: "Grinch" <grinch@whoville.com>
Subject: Re: Cgi Perl Programming problem
Message-Id: <6g25m8$79l@fridge.shore.net>

expoinfo@globalexpos.co.nz wrote in message
<6fsjti$5ml$1@nnrp1.dejanews.com>...

>Could anyone with a knowledge in perl please help me with a problem in cgi?


I'm sure that someone could...if they knew what the problem is.

One thing... is it really a CGI problem, or a PERL problem? I've noticed
that people here are pretty touchy about the difference. If it's a CGI
problem, try posting in "comp.infosystems.www.authoring.cgi".

HTH!

-grinch

--
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: Fri, 3 Apr 1998 12:57:24 +0100
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: Conversion of Excel file to Text file
Message-Id: <19980403.125724.7G7.rnr.w164w@locutus.ofB.ORG>

M Shakeel Qureshi <shakeel@ti.com> writes:

> If it is possible to convert excel file to plain text file using perl.

from the comp.apps.spreadsheets FAQ:

7.2.4 Herbert, a free platform independent MS Excel to HTML convertress
  http://wwwwbs.cs.tu-berlin.de/~schwartz/perl/
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Fri, 03 Apr 1998 07:33:30 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: current week
Message-Id: <352b9018.4372084@news.tornado.be>

Bob Trieger wrote:

>a start would be:
>
>	@date = localtime();
>	$week = $date[7]/7;

Close. But it really depends on what day of the week the year starts
with. In other words: the first week is but rarely a complete week.

And shouldn't you apply int() on this result?

	Bart.


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

Date: Fri, 3 Apr 1998 08:00:03 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: Re: eval with text files
Message-Id: <EqtvK3.8H9@cre.canon.co.uk>

Soccerweb  <soccerweb@iotp.demon.co.uk> wrote:
>[...] I want
>to be able to convert the variables in the text file and then attach the
>headers etc. to the e-mail and post. But, I can't manage to change
>$country to Spain when $country eq "Spain". So the posted e-mail's still
>state "as researcher for $country", I've tried eval but it doesn't work,
>any suggestions?

use Text::MetaText;


A


--
Andy Wardley <abw@kfs.org> http://www.kfs.org/~abw    
Signature lost in transit.  We apologise for any inconvenience caused.


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

Date: Fri, 3 Apr 1998 11:35:27 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: File Comparison on NT?
Message-Id: <ebohlmanEqu5J3.5Kx@netcom.com>

Gowri Prasad Gandluri <gprasad@ti.com> wrote:
: Is there a way to efficiently compare two sorted files
: and get a list of lines that are unique to one of those two
: files ? I am talking about doing this on NT.

Read through the two files, using each line as a hash key and 
incrementing the hash value.  Then loop through the hash's keys, 
extracting those lines with a count of 1.



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

Date: Fri, 03 Apr 1998 07:33:27 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: foreach loop & current element index
Message-Id: <35298e02.3841344@news.tornado.be>

Alexandra Stehman wrote:

>The question was:  "When in a foreach loop, is there a special variable
>or perl function that can be used to determine the index of the current
>array element?"

There's no "neat" way. A hack that works is like this:

	@allfish=("one fish","two fish","red fish","blue fish");

	my $i=0;
	foreach $fish(@allfish){
	        print "The current fish is $fish\n";
	        print "and the index is: $i\n";
	} continue {
	        $i++;
	}

Note that I've put the increment of this index in a "continu" block, so
that using "next" still works reliably. Try putting this in your loop
code. It still works as it should.

	        next if $i==2;

HTH,
Bart.


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

Date: 3 Apr 1998 09:14:03 GMT
From: "Pat Bloomfield" <patb@mround.bt.co.uk>
Subject: Help mailing in Perl
Message-Id: <01bd5ee0$f0b17990$10cf9284@icm>

I've developed an appliacation used for distributing  customer messages to
other parts of the organisation.  Sometimes people "reply" to these message
and they all get returned to the user that the Perl script runs under,
however, we would like to send this email back to distributing department -
which is in another part of the country.

I'm currently using mail as:
result = ( open( MAIL, "/bin/echo $msg | /usr/ucb/mail -s $subject
$dst_addr |" ) ) ? 1 : 0;

However, mail doesn't have a facility to allow the from source address to
be set, at least I couldn't find it.  So we're trying a similar thing using
sendmail, it works from a prompt: 

unix%/usr/5bin/echo $msg | /usr/lib/sendmail -f $src_addr $dst_addr

but doesn't work from within Perl:

result = ( open( MAIL, "/usr/5bin/echo $msg | /usr/lib/sendmail -f
$src_addr $dst_addr |" ) ) ? 1 : 0;

Any help or ideas would be greatly appreciated.

Pat
----


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

Date: 3 Apr 98 11:42:56 GMT
From: "James Richardson" <jamesr@aethos.co.uk.nospam>
Subject: Re: How should I send a signal 'INT' to a remote server?
Message-Id: <01bd5ef6$ed862840$26c0a4c1@kitkat.aethos.co.uk>

James Yang <James_Yang@via.com.tw> wrote in article
<3521AFCA.8AE3AE33@via.com.tw>...
> Hi,
> 
>     If I execute a Perl script on server severA and then it do the this
>             exec("rsh $host 'cd $pwd;$prog @ARGV'");
> How should I to send a interrupt signal to this process?
> May I specify the server name in function 'kill'?
> 
> Thanks,
> James

Nope you can't do that....you basically have two methods:

1) Set up some IPC interface between the two processes on the different
machines.
	-> Perl can do this easily, and its portable!

2) use more rsh commands to 
	a) run ps -elf (or -aux, or whatever)| grep command_name to get the pid of
the process on the other machine, mungeing the line(s) you get back from
the rsh command. (Note that rsh is also the restricted shell, and the
command wont work on HPUX (rexec instead), or many other non *nix boxes
just in case you wanted to be portable.)
 
	b) kill the specified pid.
	->lots of RPC overhead.
	->portability problems

James



 


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

Date: Fri, 3 Apr 1998 07:14:34 -0500
From: "Grinch" <grinch@whoville.com>
Subject: Is anyone using Perl for 3d graphics?
Message-Id: <6g2j30$cg9@fridge.shore.net>

Howdy,

Is anyone aware of any Perl modules (or subs, or snippets, or...) geared
towards working with 3d graphics files?

I'm especially interested in working with LightWave object files (.lwo).
But, there are just over a million file conversion utilities available
(1,000,037 to be precise), so just about any reasonably complete format will
do.

I'd like to be able to import the file, manipulate its contents by adding,
deleting, or modifying its contents, and then write the file back out in the
same format.

Can anyone refer me to such a beast, or do I have to write it? If I wind up
writing it, is there enough interest to warrant documenting it and
submitting it to CPAN?

TIA!

-grinch

--
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com




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

Date: Fri, 03 Apr 98 04:33:38 +0400
From: "Ben Coleman" <bcoleman@mindspring.com>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <zpyysxeshrieono.pminews@user-37kbbh2.dialup.mindspring.com>

On 30 Mar 1998 10:59:53 -0500, Lloyd Zusman wrote:

>However, how many experienced
>programmers do you know of who read all available docs?

I'd say any _effective_ experienced programmers have at least gone
through a period where they read everything they could get their
hands on.  After you've been through that awhile, you get to a place
where it's less necessary, as the experience reading all that doc
allows you to grab a manual and quickly find the piece of info you're
looking for.


>How many
>would laugh in your face if you tried to make this a "compulsory"
>practice?

Far, far, too many.  The stats I've read about supposed technical
professionals who _never_ read technical journals or books are
frightening.

>Many of us programmers read the docs as a last resort,
>after we have tried hacking our way through a problem with no positive
>results.

Which can mean that you waste a lot of time 'experimentally
discovering' things that could have been much more quickly discovered
by checking the docs.  And you may be leaving holes in your code in
cases where there are side effects that aren't easily discoverable by
hacking.

There's a place for experimental hacking where you feel the docs are
less than clear, or that you don't yet understand the concepts, or
where there's questions about the particular installation you're
working with, but a policy of 'hack first, read later, if at all'
seems counter-productive to me.

Ben
-- 
Ben Coleman NJ8J                     | The attempt to legislatively
Internet: bcoleman@mindspring.com    | micromanage equality results, at
http://bcoleman.home.mindspring.com/ | best, in equal misery for all.





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

Date: Fri, 03 Apr 1998 02:58:15 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Looking for ANY Suggestions on parsing this line!!
Message-Id: <alecler-0304980258150001@dialup-63.hip.cam.org>

I (Andre L.) wrote:

> Assuming the line is in $_ ,
> assuming that the next-to-last field is always one character, 
> and assuming fields 1 and 7 always begin with a $, this appears to work,
at least with the two lines above. 

Disregard the 3rd assumption; I changed the algorithm before posting and
forgot to modify that sentence.

A.


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

Date: Fri, 3 Apr 1998 06:38:14 -0600
From: "Jean-Claude" <jc@tdf.net>
Subject: Ltrim at ASCII Zero.
Message-Id: <6g2lds$t9r@news.microsoft.com>

Help.

I have a variable that contains text with an embedded Ascii 0 within it.
Like:

  _Accept_The_Task&_for_all_time

I want to cut the contents from the point of the & (actually an ascii 0)
leaving only what is to the left.    I tried a $x=~ tr\blah blah\ but don't
know how to tell it to only cut at the ASCII zero.

The basic line I am looking for by comparision is:

A$="This is text"+chr$(0)+"for us."
A$=left$(a$,instr(chr$(0),a$)-1)

Thanks.

Jean-Claude
--
The opinions expressed in this message are my own personal views
and do not reflect the official views of any corporation, or organization.




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

Date: Fri, 3 Apr 1998 11:47:14 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: need help with regexp alternation problem
Message-Id: <ebohlmanEqu62q.5wI@netcom.com>

Rebecca Ideus <becca@emrtc.nmt.edu> wrote:
: I  have written a script which is supposed to build a regular expression
: to match a series of dates.  For instance if I want to match 3/5/98 -
: 3/27/98,  it builds the following:

: /Mar\s{1,2}([5-9]|[1][0-9]|[2][0-7]).{12}98/

Why are you trying to use regexps to match date ranges instead of using 
one of the Date:: modules from CPAN?  Can your scheme handle 12/15/99 - 
1/14/00?



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

Date: 3 Apr 1998 08:33:42 GMT
From: treitstett@aol.com (TReitstett)
Subject: Re: password input
Message-Id: <1998040308334201.DAA08372@ladder01.news.aol.com>

>
>I have a script that prompts for a username and password. It would
>obviously be a good idea if the password were not echoed to the screen. 

I use this:

# Get password
system("stty -echo");
print "passwd: ";
$passwd = <STDIN>;
system("stty echo");
print "\n";


--
Thomas Reitstetter
AOL Bertelsmann Online UK


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

Date: Fri, 3 Apr 1998 07:49:09 -0500
From: "JHailer" <himmel2@ibm.net>
Subject: Re: Perl dies with segmentation fault and leaves a core
Message-Id: <3524dc98.0@news1.ibm.net>

I have had a similar problem with perl5 on Solaris.  The really weird part
is that in my programs that experience seg faults, if I throw some blank
print statements (i.e.  - print "";) in front of the offending line of code,
the problem goes away.  Sometimes even putting blank spaces in after the
semi-colon fixes the problem.  Very frustrating.  It seems to happen most
frequently on a subroutine call.  I guess I will try to reinstall like
Richard did.

Richard Pierce wrote in message <35234663.4A77E00@mema.mail.fedex.com>...
>I have experienced some seg faults with the pre-built Perl package for
>Solaris.  I corrected by obtaining the latest version of Perl and
>installing the old-fashion way, complete configure, make, and install.
>
>Richard
>
>Joseph N. Hall wrote:
>
>> Perl should not crash.  With few exceptions this is a perl bug.
>> You should post code and/or submit the bug with the perlbug program.
>>
>>         -joseph
>>          http://www.effectiveperl.com
>>
>> Bob wrote:
>> >
>> > Is there anything that a user script can do to cause a Segmentation
>> > fault and core dump, or is it a perl bug?
>
>
>




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

Date: 03 Apr 1998 13:49:56 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Ping
Message-Id: <isg1jv3z17.fsf@godzilla.kiere.ericsson.se>

Flavio Veloso <flaviovs@centroin.com.br-ZZZ-> writes:

> But it uses the TCP echo port which isn't the *real* ping. And since
> many (most?) sysadmin disable this service in their host for security
> reason (I strongly recommend anyone to do this), Net::Ping is almost
> unusable.

You haven't looked at it for a long time, have you? The way Net::Ping
looks today (and, as far as I remember, looked like a year ago) you
get to chose if you want to send TCP, UDP or ICMP packets.
-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: 3 Apr 1998 09:53:45 GMT
From: fullung@xena.sun.ac.za (Albert Strasheim)
Subject: Problems with database-related module
Message-Id: <slrn6i9qe3.nh.fullung@xena.sun.ac.za>
Keywords: database, module, perl, help

Hello,

I've written a module (added below) to make accessing databases easy again
(after the demise of dbmopen() and his close friend dbmclose()).

The thing is, I can't figure out why it doesn't work.

It's pretty obvious how to use it (I hope).

If you can fix it, I'd appreciate it if you could send me back a copy (to
fullung@ilink.nis.za). I'd be happy to devote an entire CREDITS file to
you. :)

--- start of Database.pm ---

# created by Albert Strasheim

package Database;

require 5.004;

use strict;
use Tie::Hash;
use GDBM_File;

sub new {
 my $proto = shift;
 my $class = ref($proto) || $proto;
 my $self = {};
 my @params = @_;
 my %info = (
        path => $params[0],  # path to the gdbm file
        perms => oct($params[1]), # permissions in xxxx numeric format
        lock => $params[2],  # should i lock the file?
 );
 my %database = undef;
 my $locked = 0;
 bless($self, $class);
 return $self;
}

sub open_database {
 my %info = shift;
 my $locked = shift;
 my %database = shift;
 if($info{'lock'}) {
  # lock code should go here
  $locked = 1;
 }
 tie(%database, 'GDB_File', $info{'path'}, &GDBM_WRCREAT, $info{'perms'});
}

sub return_database {
 my %database = shift;
 return \%database;
} 

sub close_database {
 my $locked = shift;
 my %database = shift;

 if($locked) {
  # unlock code should go here
  $locked = 0;
 }
 untie %database;
} 
sub is_locked {
 my $locked = shift;
 return $locked;
}

1;

--- end of Database.pm ---

Thanks in advance,

Albert.


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

Date: Fri, 3 Apr 1998 12:15:26 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Problems with database-related module
Message-Id: <ebohlmanEqu7Dq.6xs@netcom.com>

Albert Strasheim <fullung@xena.sun.ac.za> wrote:
: Hello,

: I've written a module (added below) to make accessing databases easy again
: (after the demise of dbmopen() and his close friend dbmclose()).

: The thing is, I can't figure out why it doesn't work.

[snip]
: sub new {
:  my $proto = shift;
:  my $class = ref($proto) || $proto;
:  my $self = {};
:  my @params = @_;
:  my %info = (
:         path => $params[0],  # path to the gdbm file
:         perms => oct($params[1]), # permissions in xxxx numeric format
:         lock => $params[2],  # should i lock the file?
:  );
:  my %database = undef;
:  my $locked = 0;

You're throwing away the results of the last three assignments. Maybe you
want to set $self{info}, $self{database} and $self{locked} so that you 
can keep track of them.

:  bless($self, $class);
:  return $self;
: }

: sub open_database {
:  my %info = shift;

You weren't testing with -w set, were you?  This should have given you a 
warning, since you're trying to assign a scalar to a hash.  In any case, 
given the changes above, you want to replace this and the next two 
assignments with:

my $self=shift

and replace the variable names with "$self{name}"

:  my $locked = shift;
:  my %database = shift;
:  if($info{'lock'}) {
:   # lock code should go here
:   $locked = 1;
:  }
:  tie(%database, 'GDB_File', $info{'path'}, &GDBM_WRCREAT, $info{'perms'});
: }

: sub return_database {
:  my %database = shift;

By now, you should know what to do here.

:  return \%database;
: } 

: sub close_database {
:  my $locked = shift;

and here

:  my %database = shift;

:  if($locked) {
:   # unlock code should go here
:   $locked = 0;
:  }
:  untie %database;
: } 
: sub is_locked {
:  my $locked = shift;

and here

:  return $locked;
: }

: 1;

: --- end of Database.pm ---

: Thanks in advance,

: Albert.


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

Date: Fri, 03 Apr 1998 20:33:38 +0800
From: sekchye <sekchye@singnet.com.sg>
Subject: Re: processing big file
Message-Id: <3524D722.D25CD6B1@singnet.com.sg>

On Thu, 2 Apr 1998, David A. Black wrote:

> I doubt it's the open() that's the problem - it's probably whatever
> you're doing to actually read in the file.  Are you going
line-by-line,
> or are you reading it all into one variable at once?
>
> You should be doing something like this:
>
> while (defined ($line = <IN>)) { ... }
>
> but not this:
>
> @all_lines = <IN>;
>
> You might also want/need to use sysread() to read in a specific number

> of bytes (though that's best when each line is the same length, which
> they probably aren't).  Or, you could keep track of the $. variable
and
> read smaller numbers of lines in at one time.
>
> David Black
> dblack@saturn.superlink.net

Hi!  Thank you Martien, Jason Gloudon and also David Black for your
reply.  It is very nice to know that there are people out there who are
willing to help and share their knowledge.  I think David Black has
solved my problem.  My problem lies in reading everything in from the
logfile into an array:

@input =<LOGFILE>;

I overlooked this line of code in the program.

I apologise for not posting my program code previously because the
program is quite long and messy.(^_^)  It processes on the sendmail
logfile and alert me on the possiblity of an ongoing mail bomb on my
server by monitoring the total number and size of emails sent or
received by a user.  .

Once again, thanks for all the help!

I find David Black's email very useful and I hope that David would not
mind that I have posted his reply to the newsgroup.  Thanks.



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

Date: Fri, 03 Apr 1998 07:33:24 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: readdir/grep/map
Message-Id: <35288d8c.3722706@news.tornado.be>

Peter Sakalaukus wrote:

>@files2 = grep !/^\.\.?$|region/,map "$dir/$_", readdir THISDIR;
>
>So my question is, how do I make example #2 skip . and ..

Swap the map and the grep parts.

	Bart.


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

Date: Fri, 03 Apr 1998 03:02:37 -0600
From: Broc Stirton <broc.stirton@amd.com>
Subject: reading dbf file and outputting gif file
Message-Id: <3524A5AD.33565447@amd.com>

I would like to read a .dbf (Microsoft Foxpro) .dbf file.  Are there any
modules, etc that can read the header and make these into something
usable (completely changing the database format is NOT an option
unfortunately).
	On a related note, I would like to output simple graphs (made from
parsing the .dbf data) in a gif file format (for posting to a web
page).  Any module that can handle this?  I would also appreciate any
accompanying caveats/recommendations (I am a novice).
	Thanks,
		broc 
--


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

Date: Fri, 3 Apr 1998 12:03:35 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: reading dbf file and outputting gif file
Message-Id: <ebohlmanEqu6tz.6Iq@netcom.com>

Broc Stirton <broc.stirton@amd.com> wrote:
: I would like to read a .dbf (Microsoft Foxpro) .dbf file.  Are there any
: modules, etc that can read the header and make these into something
: usable (completely changing the database format is NOT an option
: unfortunately).

Check out the various modules on CPAN that have "Xbase" in their names.  
Foxpro .dbf files are standard xbase files.  I'm not sure if any of the 
modules can handle Foxpro index files, but if you don't need the index, 
you should be set.

: On a related note, I would like to output simple graphs (made from
: parsing the .dbf data) in a gif file format (for posting to a web
: page).  Any module that can handle this?  I would also appreciate any
: accompanying caveats/recommendations (I am a novice).

Look at GD, also on CPAN.



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

Date: Fri, 3 Apr 1998 05:20:05 -0500
From: "Grinch" <grinch@whoville.com>
Subject: Re: Strange behavior with NET:Ftp under Cron
Message-Id: <6g2cce$982@fridge.shore.net>

Aaron Bennett wrote in message <3517EA42.6E6E4C03@stonehill.edu>...

>when I run a script that uses NET:Ftp from the command line, it works
>flawlessly.  However, when running from Cron, it occassionaly produces


>>  Can't call method "login" without a package or object reference at
>/export/service/www-home/https-www2/bin/registrar.pl line 43.

Hmmm...

If the problem is intermittent, it's probably not a Perl issue at all, but a
network problem. The script may occasionally have problems connecting to the
ftp server, causing the constructor to return undef instead of an object
reference. If $ftp is undef, attempting to call a member function will
produce the above message.

To check for this, add something like the following after the constructor,
but before calling any member functions:

die "Could not connect to ftp server!" unless ($ftp);

HTH!

-grinch

--
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: Fri, 3 Apr 1998 12:00:22 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Subscribing to a list without duplicates
Message-Id: <ebohlmanEqu6oM.6F0@netcom.com>

removeRod Borland <rodb@dial.pipex.com> wrote:
: $checksub = "false"

: if ($FORM{'action'} eq 'Subscribed') {

:   open (FILE,"$basedir/$subscribe");

*Always* check that your attempt to open a file was successful!

:   @email=<FILE>;
:   close(FILE);

:   open (FILE,">>$basedir/$subscribe");
:   foreach $email (@email) {

Better chomp $email here.

:     if ($email = $FORM{'email'}) {

You want to use eq, not =, here.

:       $checksub = "true";
:       $ok = "Y";

You want to break out of your loop here; no point in checking the rest of 
the entries if you already know you matched one.

:     }

The code below needs to go outside the loop.

:    if ($checksub = "false") {
:       open (FILE,">>$basedir/$subscribe");

You already did this.

:       print FILE "$FORM{'email'}\n";
:       close(FILE);
:       $ok = "Y";
:    }  
: }


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

Date: Fri, 3 Apr 1998 08:08:51 GMT
From: tmornini@netcom.com (Tom Mornini)
Subject: Re: Unitialized values (was Re: use strict and GD)
Message-Id: <tmorniniEqtvys.G65@netcom.com>

Ronald J Kimball (rjk@coos.dartmouth.edu) wrote:

: Tom Mornini wrote:
: > 
: > Also, I'm formally complaining :-) about Perl's method of checking for
: > unitialized variables. If I have code that says:
: > 
: > 01: my $foo='';
: > 
: > 63: if ($foo)
: > 64:  {
: > 65:   print 'foo is';
: > 66:  }
: > 
: > Perl will complain that $foo is unitialized at line 63, if $foo didn't
: > have any non-null values assigned between lines 1 and 63.

: Sorry, but I just don't buy that.

And RIGHT YOU ARE for not buying that! After 20 years of programming, I should
know 1) When you can't think straight, it's time for bed, and 2) Right when
you think you have it nailed, time for a reality check.

Thanks for taking the time to straighten me out on this subject.

What was happening in my code was this:

01: my $foo='';

20: $foo=$ENV{'REQUEST_METHOD'};

63: if ($foo)
64:  {
65:   print 'foo is';
66:  }

After line 1, everything is cool and initialized just fine.

After line 20, if $ENV{'REQUEST_METHOD'} is undef, then $foo also becomes
undef. $ENV{'REQUEST_METHOD'} would rarely be anything but undef, unless
you're running as a CGI. I was using perl -w from the shell, and it was
complaining.

I'm still not completely happy with this behavior, though! I have somewhat
of a hard time dealing with a message that says a variable is uninitialized
after it was subject to an assignment.

I can understand it, but I don't grok it. I can certainly live with it, and
work with it, and I suppose there are examples where this would make me a
better coder and my programs less error prone.

And, if I don't like it, I can always run without -w... :-)

-- Tom Mornini
-- InfoMania


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

Date: 03 Apr 1998 12:42:15 +0100
From: Dave Hodgkinson <daveh@sift.co.uk>
Subject: Re: upload a file to ftp site
Message-Id: <81u38b1694.fsf@charlotte.sift.co.uk>


As someone else said, use Net::FTP.

I've done exactly this, before I found that Lee McLoughlin's mirror
suite (written in Perl) could blow as well as suck.

-- 
David Hodgkinson, Technical Director, Sift PLC    http://www.sift.co.uk
European Information Product of the Year http://www.accountingweb.co.uk
Editor, "The Highway Star"                  http://www.deep-purple.com
Deep Purple Family Tree            http://deep-purple.family-tree.org/


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

Date: 03 Apr 1998 10:10:05 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Weird Effects w/ "require"
Message-Id: <7x3efv9vhe.fsf@beavis.vcpc.univie.ac.at>

Re: Weird Effects w/ "require", Jerome <bradenb@ibm.net>
said:

Jerome> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

Hmmm, what could this be, I wonder?

Jerome> fails to read form data passed in. If I only
Jerome> "require" the library once, all is well. The
Jerome> workaround is self explanatory, but I'd like to know
Jerome> why. Please forward your wisdom to the address
Jerome> below. Thanks.

You don't provide any code or code fragments to demonstrate
the effect you're talking about so it's impossible to say
with any authority what is going on here.

Of course, you could make life a whole load easier for
yourself and

    use CGI;


-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/

"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"


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

Date: Fri, 3 Apr 1998 13:01:48 +0200 
From: "R. Allen Conway" <raconway@atos-group.com>
Subject: What does a reference refer to?
Message-Id: <14953E9BAF17D111926800805FA66B7102F01A69@hermes.atos-group.com>

How can you tell what a reference is referring to - a hash, an array, a
whatever?

Many thanks for the replies to the "how do I know what modules I've got"
question!



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

Date: Fri, 3 Apr 1998 06:52:52 -0500
From: "Grinch" <grinch@whoville.com>
Subject: Re: What does a reference refer to?
Message-Id: <6g2hqb$b0t@fridge.shore.net>

R. Allen Conway wrote in message

<14953E9BAF17D111926800805FA66B7102F01A69@hermes.atos-group.com>...
>How can you tell what a reference is referring to - a hash, an array, a
>whatever?


Use the "ref" function. It takes a single argument, and returns a null
string if the argument is not a reference.

If the argument is a reference to a built-in data type, it returns REF,
SCALAR, ARRAY, HASH, CODE, or GLOB as appropriate. If the referenced object
has been blessed into a package, then the name of the package is returned.

HTH!

-grinch

--
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: Fri, 03 Apr 1998 08:11:21 GMT
From: pickles_c@hotmail.com (Craig Pickles)
Subject: Re: what is wrong with being a novice ??
Message-Id: <352498bb.61492036@news.demon.co.uk>


>If the FAQ tells you that Perl's equivalent of *anything* is the
>'switch' command, then the FAQ has been sabotaged.  There is no such
>command (or function, or anything else).

ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/doc/FAQs/FAQ/PerlFAQ.html#How_do_I_create_a_switch_or_case

How do I create a switch or case statement? 
This is explained in more depth in the the perlsyn manpage. Briefly,
there's no official case statement, because of the variety of tests
possible in Perl (numeric comparison, string comparison, glob
comparison, regexp matching, overloaded comparisons, ...). Larry
couldn't decide how best to do this, so he left it out, even though
it's been on the wish list since perl1. 
Here's a simple example of a switch based on pattern matching. We'll
do a multi-way conditional based on the type of reference stored in
$whatchamacallit: 


    SWITCH:
      for (ref $whatchamacallit) {

	/^$/		&& die "not a reference";

	/SCALAR/	&& do {
				print_scalar($$ref);
				last SWITCH;
			};

	/ARRAY/		&& do {
				print_array(@$ref);
				last SWITCH;
			};

	/HASH/		&& do {
				print_hash(%$ref);
				last SWITCH;
			};

	/CODE/		&& do {
				warn "can't print function ref";
				last SWITCH;
			};

	# DEFAULT

	warn "User defined type skipped";

    }

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

Well, thats what the FAQ that I read said, didnt really make much
difference as I didnt use it in the end...seemed too complicated....
:)

BTW, I am quite proud of my perl efforts, I wrote all the scripts used
on http://www.carltonint.co.uk including the search and banner
scripts...... in just two weeks from the first time I touched perl
properly........ which I think is good going.....

This newsgroup has been ionvaluable, I havent actually had to post a
message yet, either looking at current messages or doing a archive
search on deja vu for this newsgroup has helped me more than any FAQ
ever has......

As for IRC, thats another matter :(

It just goes to show that its not what your know its knowing where to
find out.

Craig Pickles


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

Date: Fri, 03 Apr 1998 16:19:58 +0800
From: James Yang <James_Yang@via.com.tw>
Subject: Why $ENV{'PWD'} is not equal to `pwd` ?
Message-Id: <35249BAD.5DEAB84A@via.com.tw>

Hi,

The followings are part of my Perl script,

$pwd1 = $ENV{'PWD'};
$pwd2 = `pwd`;
$pwd3 = `env | grep PWD`;
print "PWD1 $pwd1\n";
print "PWD2 $pwd2\n";
print "PWD3 $pwd3\n";

And if I run this program by use of a makefile like this:
### makefile ###
test:
    cd dir1; MyProg;

Then the stand output will show as below:

cd dir1; MyProg;
PWD1    /usr/bauli
PWD2    /usr/bauli/dir1
>

Is there anybody can tell me what is the reason that PWD1 is not equal
to PWD2?
Thanks a lot!

Bauli



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

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

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