[19598] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1793 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 22 21:05:38 2001

Date: Sat, 22 Sep 2001 18:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001207110-v10-i1793@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 22 Sep 2001     Volume: 10 Number: 1793

Today's topics:
    Re: access old DIBOL file <tintin@snowy.calculus>
    Re: access old DIBOL file <dan@tuatha.sidhe.org>
    Re: access old DIBOL file <thompson-nospam@new.rr.com>
    Re: access old DIBOL file <jbritain@home.com>
    Re: Best way to hide the perl source code.. <tintin@snowy.calculus>
    Re: Best way to hide the perl source code.. <please@no.spam>
        command line file operations <cmerrifield@houston.rr.com>
    Re: command line file operations <please@no.spam>
    Re: command line file operations <bcaligari@fireforged.com>
        Concatenating Strings (RoJo)
    Re: Concatenating Strings <Laocoon@eudoramail.com>
    Re: Concatenating Strings (RoJo)
    Re: Concatenating Strings <tintin@snowy.calculus>
    Re: extra newline in s command (laura fairhead)
    Re: extra newline in s command <davidhilseenews@yahoo.com>
    Re: extra newline in s command <tony_curtis32@yahoo.com>
    Re: extra newline in s command <jurgenex@hotmail.com>
    Re: extra newline in s command (laura fairhead)
    Re: File::Find::name problem... <dtweed@acm.org>
        FLEXLM license parser module? <tony_curtis32@yahoo.com>
        Getting NULLS after a lockup from using up memory (Xeno Campanoli)
    Re: Hash problem... <guardian@chello.be>
    Re: How to pass hashes to function as parameter? <tinamue@zedat.fu-berlin.de>
    Re: Perhaps some help for a newbie - uninitialized valu <please@no.spam>
    Re: perl, lvalues, rvalues, and operators <please@no.spam>
    Re: Schwartzian Transform problem <matthew.garrish@sympatico.ca>
    Re: use of uninitialized value using join <please@no.spam>
        Why are tabs converted to spaces? <pwasson@mindspring.com>
    Re: Why are tabs converted to spaces? <Laocoon@eudoramail.com>
    Re: Why are tabs converted to spaces? <echang@netstorm.net>
    Re: Why are tabs converted to spaces? <jurgenex@hotmail.com>
    Re: Why are tabs converted to spaces? <jurgenex@hotmail.com>
    Re: Why are tabs converted to spaces? <pwasson@mindspring.com>
    Re: Why are tabs converted to spaces? <echang@netstorm.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 23 Sep 2001 08:16:59 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: access old DIBOL file
Message-Id: <C68r7.1$Jm1.178261@news.interact.net.au>


"Dan Sugalski" <dan@tuatha.sidhe.org> wrote in message
news:h94r7.25648$NT3.3554414@news1.rdc1.ct.home.com...
> jeremiah <brimstonesfc@hotmail.com> wrote:
> > I've got a bit of a problem. I need to acces an old DIBOL db via perl.
>
> Wasn't DiBOL some mutant version of COBOL that ran on DEC machines? (I
> have a vague recollection of doing DiBOL on PDP 11/70s, but that was
> a *long* time ago...)

Google to the rescue.

Digital Interactive Business Oriented Language.

DEC, 1970.

FORTRAN syntax with BCD arithmetic.

Versions for PDP-8 and RT-11.

ANSI X3.165-1988.





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

Date: Sat, 22 Sep 2001 22:53:34 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: access old DIBOL file
Message-Id: <OD8r7.26568$NT3.3628875@news1.rdc1.ct.home.com>

Tintin <tintin@snowy.calculus> wrote:

> "Dan Sugalski" <dan@tuatha.sidhe.org> wrote in message
> news:h94r7.25648$NT3.3554414@news1.rdc1.ct.home.com...
>> jeremiah <brimstonesfc@hotmail.com> wrote:
>> > I've got a bit of a problem. I need to acces an old DIBOL db via perl.
>>
>> Wasn't DiBOL some mutant version of COBOL that ran on DEC machines? (I
>> have a vague recollection of doing DiBOL on PDP 11/70s, but that was
>> a *long* time ago...)

> Google to the rescue.

> Digital Interactive Business Oriented Language.

> DEC, 1970.

> FORTRAN syntax with BCD arithmetic.

> Versions for PDP-8 and RT-11.

Google's not completely rescuing here. The name's right, but the rest is,
at best, out of date. I'm pretty sure it ran on VAXen, and I *know* it ran
on more than just RT-11 on the PDP-11s.

					Dan



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

Date: Sun, 23 Sep 2001 00:01:41 GMT
From: "P. Thompson" <thompson-nospam@new.rr.com>
Subject: Re: access old DIBOL file
Message-Id: <Pine.LNX.4.33.0109221901030.8408-100000@malacandra.localnet>


I have some old VMS consolidated distributions with this software
supposedly on it. I never looked at it, however.

On Sat, 22 Sep 2001, Dan Sugalski wrote:

> Tintin <tintin@snowy.calculus> wrote:
>
> > "Dan Sugalski" <dan@tuatha.sidhe.org> wrote in message
> > news:h94r7.25648$NT3.3554414@news1.rdc1.ct.home.com...
> >> jeremiah <brimstonesfc@hotmail.com> wrote:
> >> > I've got a bit of a problem. I need to acces an old DIBOL db via perl.
> >>
> >> Wasn't DiBOL some mutant version of COBOL that ran on DEC machines? (I
> >> have a vague recollection of doing DiBOL on PDP 11/70s, but that was
> >> a *long* time ago...)
>
> > Google to the rescue.
>
> > Digital Interactive Business Oriented Language.
>
> > DEC, 1970.
>
> > FORTRAN syntax with BCD arithmetic.
>
> > Versions for PDP-8 and RT-11.
>
> Google's not completely rescuing here. The name's right, but the rest is,
> at best, out of date. I'm pretty sure it ran on VAXen, and I *know* it ran
> on more than just RT-11 on the PDP-11s.
>
> 					Dan
>
>

-- 
Leave the nospam in, correct email address



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

Date: Sun, 23 Sep 2001 00:47:19 GMT
From: Jim Britain <jbritain@home.com>
Subject: Re: access old DIBOL file
Message-Id: <vvbqqt8aqhe3jm3pbaal3bf9kqmbbc6o18@4ax.com>

On Sat, 22 Sep 2001 17:47:57 GMT, Dan Sugalski <dan@tuatha.sidhe.org>
wrote:

>jeremiah <brimstonesfc@hotmail.com> wrote:
>> I've got a bit of a problem. I need to acces an old DIBOL db via perl.
>
>Wasn't DiBOL some mutant version of COBOL that ran on DEC machines? (I
>have a vague recollection of doing DiBOL on PDP 11/70s, but that was
>a *long* time ago...) If that's true the files might be stored in
>one of the Dec OS' native formats. (What OS was this stuff generated
>on?) If that's the case, you might be able to extract the data
>either with some of the native tools or VMS perl if you can
>get it over to a VMS box. 

Nope.  Old DEC product, quite stable and still usable (it the hardware
is still running)

Digital Interactive Business Oriented Language
PDP8, RT11, VMS etc.

Basically Fortran with a good BCD extension.




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

Date: Sun, 23 Sep 2001 08:20:54 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Best way to hide the perl source code..
Message-Id: <ha8r7.2$Pl1.176193@news.interact.net.au>


"Espen Myrland" <em@online.no> wrote in message
news:87r8szxsp2.fsf@strand.arcanum.net...
> Jayakumar Mundunuri <jkumar@atrenta.com> writes:
>
> > Hi Friends!!
> >
> > Can you suggest me what is the best way to hide perl source code?
> >
> > perl Compiler/ perlcc / perl Bite code / encrypt / perl Filter ....
> >
> > I heard the above names but not really attempted to use them.
> >
> > It would be great help if anybody guide me with some references.
> >
> > Thanks in advance.
> >
>
>         chmod  700 perl_source

That's as useful as doing:

chmod 000 perl_source

or

rm -f perl_source

which is moderately secure, but not particularly useful.




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

Date: Sat, 22 Sep 2001 22:28:33 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: Best way to hide the perl source code..
Message-Id: <87vgiaamln.fsf@homer.cghm>

Michael Slass <mikesl@wrq.com> writes:

> perldoc -q hide source
> 
> ,----
> | Found in /usr/lib/perl5/5.6.0/pod/perlfaq3.pod
> |   How can I hide the source for my Perl program?

[...]

> |   You can try using encryption via source filters (Filter::* from
> |   CPAN), but any decent programmer will be able to decrypt it. You
> |   can try using the byte code compiler and interpreter described
> |   below, but the curious might still be able to de-compile it. You
> |   can try using the native-code compiler described below, but
> |   crackers might be able to disassemble it.

If it's compiled to native code, you can just set it mode 111.

[...]

> |   If you're concerned about people profiting from your code

Apparently they're assuming this is the only reason someone might want
to hide source.


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

Date: Sat, 22 Sep 2001 21:11:59 GMT
From: "Chucko" <cmerrifield@houston.rr.com>
Subject: command line file operations
Message-Id: <z87r7.20$b55.36673@typhoon.austin.rr.com>

Does anyone know how to (from a command line) read in a file of text, keep
each word read, discard the duplicates then write the kept words to a file?






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

Date: Sat, 22 Sep 2001 22:58:08 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: command line file operations
Message-Id: <87g09eal8c.fsf@homer.cghm>

"Chucko" <cmerrifield@houston.rr.com> writes:

> Does anyone know how to (from a command line) read in a file of text, keep
> each word read, discard the duplicates then write the kept words to a file?

perl -lne ' foreach $word (split) { print $word unless $wordlist{$word}++ } '

Reads from stdin, prints to stdout.


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

Date: Sat, 22 Sep 2001 23:42:25 -0000
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: command line file operations
Message-Id: <9oj75o01csu@enews4.newsguy.com>


"Chucko" <cmerrifield@houston.rr.com> wrote in message
news:z87r7.20$b55.36673@typhoon.austin.rr.com...
> Does anyone know how to (from a command line) read in a file of text, keep
> each word read, discard the duplicates then write the kept words to a
file?
>

perl -nle '$x{$_}++ for split; END { print for keys %x }' filename

cat filename | tr -s [:space:] "\n" | sort | uniq

B.




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

Date: Sat, 22 Sep 2001 19:50:12 GMT
From: rojo@mindspring.com (RoJo)
Subject: Concatenating Strings
Message-Id: <3bacea62.164683642@news.mindspring.com>


I know this is a fundamental question.  But how do I concatenate
multiple strings to create one new string?

For example:

$first = 'I ';
$second = 'want ';
$third = 'these ';
$fourth = 'together.';

I want to create a string with the content:
'I want these together.'



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

Date: Sat, 22 Sep 2001 21:55:11 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Concatenating Strings
Message-Id: <Xns9124E05B2A14ELaocooneudoramailcom@62.153.159.134>

with the '.' operator..

$a = "This is ";
$b = "a test";
$c = $a . $b;

$c is now "This is a test"


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

Date: Sat, 22 Sep 2001 21:06:06 GMT
From: rojo@mindspring.com (RoJo)
Subject: Re: Concatenating Strings
Message-Id: <3bacfd1d.169478377@news.mindspring.com>


Thanks!  I figured it would be a simple solution.

On Sat, 22 Sep 2001 21:55:11 +0200, Laocoon <Laocoon@eudoramail.com>
wrote:

>with the '.' operator..
>
>$a = "This is ";
>$b = "a test";
>$c = $a . $b;
>
>$c is now "This is a test"



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

Date: Sun, 23 Sep 2001 08:24:56 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Concatenating Strings
Message-Id: <3e8r7.3$F41.68676@news.interact.net.au>


"RoJo" <rojo@mindspring.com> wrote in message
news:3bacea62.164683642@news.mindspring.com...
>
> I know this is a fundamental question.  But how do I concatenate
> multiple strings to create one new string?
>
> For example:
>
> $first = 'I ';
> $second = 'want ';
> $third = 'these ';
> $fourth = 'together.';
>
> I want to create a string with the content:
> 'I want these together.'

$string="$first$second$third$fourth";




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

Date: Sat, 22 Sep 2001 19:22:17 GMT
From: laura_fairhead@my-deja.com (laura fairhead)
Subject: Re: extra newline in s command
Message-Id: <3bace3a7.94715075@news.cis.dfn.de>

On Sat, 22 Sep 2001 17:54:29 GMT, friedman@math.utexas.edu (Chas Friedman) wrote:

>On Sat, 22 Sep 2001 17:23:40 GMT, laura_fairhead@my-deja.com (laura
>fairhead) wrote:
>
>>Hi,
>>
>>Can anyone explain to me why I'm getting extra
>>newlines inserted with the s/// command in this
>>script;
>>
>>open(FILE,qq[patternfile])
>>@k=(qq[0000],<FILE>)
>>while(<>){
>>  /(\d{4})/&& $1<=$#k && s/$1/$k[$1]/
>>  print
>>  }
>>
>>
>>Every line that has an s/// done on it has
>>an extra newline and I don't see why it's
>>doing that.
>>
>>It is suppossed to replace occurances of 4 digit
>>numerics with what is on that line in 'patternfile'
>>This is my 1st attempt at 'perl' so pleaze be
>>easy on me.... is this a reasonable way of doing
>>this or is there a better one? Also, can I read a file
>>into an array in just one command?
>>
>>thanx
>>
>>-- 
>>: ${L:-aura} # http://lf.8k.com:80
>>
>Well, your code won't even compile, because several semicolons are
>missing.
>Assuming your actual code doesn't have this problem, you are
>probably getting the newlines from the lines in patternfile.
>                                     chas

Okay. I found out a solution using 'chop' although it means
that I had to increase the first array element by 1 character
(there is no way to do a 'chop(<FILE>)' and put it in the
list is there? )

open(FILE,qq[K]);
chop(@k=(qq[0000x],<FILE>));
while(<>){
  /(\d{4})/&& $1<=$#k && s/$1/$k[$1]/;
  print ;
  }


byefornow,

-- 
: ${L:-aura} # http://lf.8k.com:80





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

Date: Sat, 22 Sep 2001 19:36:03 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: extra newline in s command
Message-Id: <DK5r7.6205$n_2.987317@news1.rdc1.md.home.com>


"laura fairhead" <laura_fairhead@my-deja.com> wrote in message
news:3bace3a7.94715075@news.cis.dfn.de...
> On Sat, 22 Sep 2001 17:54:29 GMT, friedman@math.utexas.edu (Chas Friedman)
wrote:
>
> >On Sat, 22 Sep 2001 17:23:40 GMT, laura_fairhead@my-deja.com (laura
> >fairhead) wrote:
> >
> >>Hi,
> >>
> >>Can anyone explain to me why I'm getting extra
> >>newlines inserted with the s/// command in this
> >>script;
> >>
> >>open(FILE,qq[patternfile])
> >>@k=(qq[0000],<FILE>)
> >>while(<>){
> >>  /(\d{4})/&& $1<=$#k && s/$1/$k[$1]/
> >>  print
> >>  }
> >>
> >>
> >>Every line that has an s/// done on it has
> >>an extra newline and I don't see why it's
> >>doing that.
> >>
> >>It is suppossed to replace occurances of 4 digit
> >>numerics with what is on that line in 'patternfile'
> >>This is my 1st attempt at 'perl' so pleaze be
> >>easy on me.... is this a reasonable way of doing
> >>this or is there a better one? Also, can I read a file
> >>into an array in just one command?
> >>
> >>thanx
> >>
> >>--
> >>: ${L:-aura} # http://lf.8k.com:80
> >>
> >Well, your code won't even compile, because several semicolons are
> >missing.
> >Assuming your actual code doesn't have this problem, you are
> >probably getting the newlines from the lines in patternfile.
> >                                     chas
>
> Okay. I found out a solution using 'chop' although it means
> that I had to increase the first array element by 1 character
> (there is no way to do a 'chop(<FILE>)' and put it in the
> list is there? )
>
> open(FILE,qq[K]);
> chop(@k=(qq[0000x],<FILE>));
> while(<>){
>   /(\d{4})/&& $1<=$#k && s/$1/$k[$1]/;
>   print ;
>   }
>
>
> byefornow,
>
> --
> : ${L:-aura} # http://lf.8k.com:80
>

Close.  perldoc -f chomp.

--
David Hilsee




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

Date: Sat, 22 Sep 2001 20:33:25 GMT
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: extra newline in s command
Message-Id: <87y9n7aru0.fsf@timmy.houston.rr.com>

>> On Sat, 22 Sep 2001 17:23:40 GMT,
>> laura_fairhead@my-deja.com (laura fairhead) said:

> Hi, Can anyone explain to me why I'm getting extra
> newlines inserted with the s/// command in this script;

> open(FILE,qq[patternfile])
> @k=(qq[0000],<FILE>)
> while(<>){
>   /(\d{4})/&& $1<=$#k && s/$1/$k[$1]/
>   print
> }

This code doesn't even compile.  Please post the *real*
code and try again.  How can you expect useful advice if
you post something that is unrelated to your problems?


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

Date: Sat, 22 Sep 2001 13:50:28 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: extra newline in s command
Message-Id: <3bacf996@news.microsoft.com>

"laura fairhead" <laura_fairhead@my-deja.com> wrote in message
news:3bace3a7.94715075@news.cis.dfn.de...
> Okay. I found out a solution using 'chop' although it means
> that I had to increase the first array element by 1 character
> (there is no way to do a 'chop(<FILE>)' and put it in the
> list is there? )

Any specific reason why you don't use "chomp" instead of "chop"?
Oh, and of course chomp works on lists, too.

jue




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

Date: Sat, 22 Sep 2001 23:02:21 GMT
From: laura_fairhead@my-deja.com (laura fairhead)
Subject: Re: extra newline in s command
Message-Id: <3bad158b.107489036@news.cis.dfn.de>

On Sat, 22 Sep 2001 13:50:28 -0700, "Jürgen Exner" <jurgenex@hotmail.com> wrote:

>"laura fairhead" <laura_fairhead@my-deja.com> wrote in message
>news:3bace3a7.94715075@news.cis.dfn.de...
>> Okay. I found out a solution using 'chop' although it means
>> that I had to increase the first array element by 1 character
>> (there is no way to do a 'chop(<FILE>)' and put it in the
>> list is there? )
>
>Any specific reason why you don't use "chomp" instead of "chop"?
>Oh, and of course chomp works on lists, too.
>

yes, I can't use 'chomp' because I'm working in Perl 4.

I know I should be using Perl 5 but unfortunately there
doesn't seem to be a Perl 5 for MSDOS (which I need the
program to work in... plain MSDOS not the Windoze variety)

It doesn't really matter though, as long as it workz
but the problem I've still got is the replace thing
with s///. 

The replace in the s command is interpretted as a regular
expression and I need to just do a plain string replace.
The /$k[$1]/ must not be interpretted as a regular expression,
and it may have special characters in it.

I've been reading as much as I can and looked at posts
in this group but I can't find anything. Doesn't
perl have a plain string replace function or does the
r.h.s have to be an perl RE ?

I read something here about using \Q to 'quote meta'
but it doesn't seem to be working here. Is that another
of the things new in Perl 5 ?

All I can see at the moment is messing about with
string splicing, using index() and then substr() to
do it but that lookz awful really.

cu,from

-- 
: ${L:-aura} # http://lf.8k.com:80

>jue
>
>



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

Date: Sat, 22 Sep 2001 18:08:54 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: File::Find::name problem...
Message-Id: <3BACD26F.4ABD021C@acm.org>

Rob wrote:
> Actually, all filenames are numbers, never alpha.  The only gotcha is
> I am writting this to be as independant of platform as I can.  I will
> need to preset a variable for the directory delimiter before
> performing the split.  (Another windows perl environment may use "\"
> instead of "/" which will work just fine in Unix/Linux.

All win32 API functions, which are what you're accessing from Perl,
accept either "\" or "/" as a path delimiter, so it's generally safe
to use "/" exclusively in your Perl code. File::Find uses only "/"
internally.  However, you may want to translate to the delimiter your
users expect to see when you display paths.

It's really only certain command-line tools from Microsoft that
sometimes demand only "\", because they use "/" as the option switch
instead of "-".

-- Dave Tweed


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

Date: Fri, 21 Sep 2001 18:28:10 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: FLEXLM license parser module?
Message-Id: <87ofo4t985.fsf@limey.hpcc.uh.edu>


does anyone know of any module(s) for parsing FLEXLM
license files?  Or lmstat output?  (I couldn't see owt on
CPAN.)

ta,
t
-- 
Yes way!  Mmmmkay?


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

Date: 22 Sep 2001 18:30:25 GMT
From: xeno@eskimo.com (Xeno Campanoli)
Subject: Getting NULLS after a lockup from using up memory
Message-Id: <9oilc1$ecl$1@eskinews.eskimo.com>


I'm finding that frequently, in my Perl program that I mentioned here
before, I get a catestrophic failure at the call to waitpid (this is
with either the zero, or the WNOHANG parameter in use) such that I
literally get a stream of nulls of varying length output to STDERR at
that point, at least when I'm using STDERR print statements to trace my
progress.  There seems to be no other reason for this than just running
out of resources, and it makes sense that I fail at waitpid since I
spend more time there when memory is getting used up (once in a while it
fails elsewhere, but usually there at the waitpid) but it is curious
that I get this stream of nulls.  I was wondering if you had any idea
why this is?  Have you ever seen that?




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

Date: Sat, 22 Sep 2001 18:25:41 GMT
From: "GuaRDiaN" <guardian@chello.be>
Subject: Re: Hash problem...
Message-Id: <FI4r7.1972$2a.83988@news.chello.be>

> First of all, the choice of $player_name and $player_name2 as your
> hash references leads me to conclude that you are using symbolic
> references.  If so, that is a bad thing.  In this case, it is *very*
> easy to avoid.  If $player_name contains the (unique) name of one
> player and $player_name2 another, then just use something like:
>
>   $player{$player_name}{kills}{count}++;
>   $player{$player_name2}{death}{count}--;

$player_name is just a temporary var that contains a user name then put it
into a hash...
and then goes to the following user...
This script is a Counter-Strike log analyser.


> Yeah, that's pretty much invalid syntax all around.  You're presumably
> looking for %{$$user{kills}} or %{$user->{kills}}, though if you
> switch to what I recommend then it would be %{$player{$user}{$kills}}.

I finally found the solution ;o) but many thanks :o)





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

Date: 22 Sep 2001 18:07:21 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: How to pass hashes to function as parameter?
Message-Id: <9oik0p$df2o7$2@fu-berlin.de>

Hamish Marson <hmarson@attglobal.net> wrote:

> OK. I"m having problems here and I just can't work out why... Probbaly
> blindingly obvious but...

> I can't seem to pass a has as a parameter to a function... I have a
> scalar & a hash I want to pass to a function... e.g.

this is an FAQ:
perldoc -q pass.*hash

hth, tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Sat, 22 Sep 2001 22:45:29 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: Perhaps some help for a newbie - uninitialized value...
Message-Id: <87pu8ialtf.fsf@homer.cghm>

Technician <travis5765@hotmail.clothes.com> writes:

> On 22 Sep 2001 00:30:00 -0500, Logan Shaw Decided to grace us with 
> his/her presance by stating:
> > In article <3BAC1336.365755EC@hotmail.com>,
> > root  <travis5765@hotmail.com> wrote:
> > >Ok, this script (perl script attached, assuming the servers allow it.)
> > 
> > The servers allow it, but actually it's considered bad netiquette to
> > use MIME (or anything but plain text) on Usenet newsgroups.  (The
> > obvious exceptions are the newsgroups devoted to binary postings.)
> 
> Sorry, i tried to copy and paste it but couldn't get netscape to paste 
> from a kedit copy so i attached it.

Select with the mouse in kedit, leave selected, and press middle mouse
button in netscape to paste.  Also, don't run netscape (or anything
interactive) as root, it's viciously insecure.  Especially an old
version of netscape such as the one your headers claim you use.

> The problem is, i plan to run this via cron (aka Linux scheduling)

cron is not also known as Linux scheduling.  Say "Linux scheduling"
and nobody will know you're talking about cron.  Some will think
you're talking about scheduling in the Linux kernel, which you are
not.

> and any text outputed by the script (errors, etc...) are automaticly
> mailed to the cron owner. if this is run every minute, that would
> produce 86,400 messages per day. This would be very annoying to say
> the least.

You could always pipe stderr to a log file, or /dev/null.  Then you
wouldn't get the mails.

> If i could just get it to run withought any errors, warnings, or any 
> other text output it would be great.

>/dev/null 2>&1

> I have tried removing the line "use strict" but this had no affect.

That's because use strict isn't what generates warnings, the -w switch
is.  If you remove that, the warning will go away.  If you're
discarding warnings anyway, you might as well disable them, but
generally they're very helpful and should be enabled (and it's better
to put them into a file somewhere than discard them).

> Oh, i just remembered. lines within {} brackets are read as one line.
> So $ips[$i] would have to be uninitialized to give this error. As i 
> stated, there is currently no entry in the requested log that matches the 
> query so $ips[$i] is uninitialized at the current moment.
> 
> Now, to correct this, i should be able to add a if statment testing if 
> $ips[$i] is null then set $ips[$i] = "000.000.000.000".
> The for statment would then read;
> --------------
> for (my $i = 0; $i <= $ips_shown; $i++) {
>    if (!$ips[$i]) {$ips[$i] = "000.000.000.000";}
>    print OUT "<li>$ips[$i]</li>";
> }

But setting the value to 000.000... changes the behavior of the
program, in that it will now print lots of zero IPs onto your HTML
document, instead of lots of empty list items.  A better way to do
what you're trying is:

print OUT "<li>$ips[$i]</li>" if defined($ips[$i]);

which will still change the behavior, but for the better.  With
defined() it also will work for variables with values such as 0 which
evaluate to false, although you're unlikely to come across those here.

However, the fact that $ips[$i] is undefined is actually a bug in the
script, and rather than working around it you should fix the bug.
Specifically, the for loop is assuming that ($#ips >= $ips_shown).
You should change the condition in the for loop, as follows:

for (my $i=0; $i <= $ips_shown && $i <= $#ips; $i++) { # ...

The reason referencing an undefined value generates a warning is
exactly that such things are often bugs.  If this were a C program,
that kind of sloppiness would either generate a segfault (if you're
lucky) or print garbage.  The author probably never encountered the
bug because his /var/log/messages always contained more than 8 IPs.

Incidentally, looking at the original file, that is a very low quality
program all around (I know you didn't write it, just saying).


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

Date: Sat, 22 Sep 2001 22:49:43 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: perl, lvalues, rvalues, and operators
Message-Id: <87k7yqalmc.fsf@homer.cghm>

Tina Mueller <tinamue@zedat.fu-berlin.de> writes:

> > Given a subroutine foo() that returns a string, I would like to
> > call the routine, mangle the output, and print it in one swell
> > foop:
>
> > print foo($arg, $notherarg) =~ s/regex/subst/;
> 
> you can do:
> print map {s/regex/subst/;$_} foo($arg, $notherarg);

Funny, this works:

$ perl -le ' sub f{return shift}; print map {tr/a/b/;$_} f("aaa") '
bbb

but not this:

$ perl -le ' print map {tr/a/b/;$_} "aaa" '
Modification of a read-only value attempted at -e line 1.

One would think that one rvalue should be as good as another, and it
seems (from perldoc -f map) that *neither* should work, as map
supposedly makes $_ an "alias" to the list value, not a copy.  But
apparently it's willing to work on the copy made for the function
call, even though other builtins demanding lvalues are not.  Hm.


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

Date: Sat, 22 Sep 2001 14:57:17 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Schwartzian Transform problem
Message-Id: <vb5r7.26377$386.4325882@news20.bellglobal.com>


"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:s6dpqtgrnln4t2m42s66smjofejpnskk06@4ax.com...

> Well, she claims to be an English teacher. I have no reason to doubt
> that. (Or was it professor?)
>

I pity her students then. Another case of the blind leading the blind...

Matt




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

Date: Sat, 22 Sep 2001 22:26:55 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: use of uninitialized value using join
Message-Id: <871ykyc18u.fsf@homer.cghm>

quang777@email.com (q777) writes:

> Bart Lateur <bart.lateur@skynet.be> wrote in message
> news:<rornqt8klreqhau0mihcj1mp256n6dndio@4ax.com>...
>
> > q777 wrote:
> > 
> > >my @array = ();
> > >my $string = join /\n/, @array;
> > >
> > >why does this give the "Use of uninitialized value" error?
> > 
> > Because you're joining using a regex instead of a plain string, which
> > does matching on $_, which in turn is undefined?
> 
> Duh. Thanks. Forgot about the $_ default behavior.

Um, it's not the $_ default behavior you forgot (well maybe that too),
but that join expects a string, not a regex.  Even if regexes didn't
default to matching against $_ your code wouldn't work (although in
that case it wouldn't even compile).


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

Date: Sat, 22 Sep 2001 13:03:18 -0700
From: Philip Wasson <pwasson@mindspring.com>
Subject: Why are tabs converted to spaces?
Message-Id: <3BACEE86.1128DE69@mindspring.com>

I am trying to separate fields in a guestbook by a tab but a space is written
instead.  Here is the code clip:

   open (GUEST,">$guestbookreal") || die "Can't Open $guestbookreal: $!\n";

         print GUEST "$FORM{'firstname'}\t";
         print GUEST "$FORM{'lastname'}\t";

Any ideas?  Thanks for taking the time to look at this.

Phil Wasson


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

Date: Sat, 22 Sep 2001 22:11:19 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Why are tabs converted to spaces?
Message-Id: <Xns9124E3171F6A2Laocooneudoramailcom@62.153.159.134>

One Tab = 8 spaces..
What else do you expect to be printed?


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

Date: Sat, 22 Sep 2001 20:44:35 GMT
From: "E.Chang" <echang@netstorm.net>
Subject: Re: Why are tabs converted to spaces?
Message-Id: <Xns9124AB2AFFD24echangnetstormnet@207.106.93.86>

Philip Wasson <pwasson@mindspring.com> wrote in
news:3BACEE86.1128DE69@mindspring.com: 

> I am trying to separate fields in a guestbook by a tab but a space
> is written instead.  Here is the code clip:
> 
>    open (GUEST,">$guestbookreal") || die "Can't Open
>    $guestbookreal: $!\n"; 
> 
>          print GUEST "$FORM{'firstname'}\t";
>          print GUEST "$FORM{'lastname'}\t";
> 
> Any ideas?  Thanks for taking the time to look at this.

Do you really mean a space is printed?  Or that only one space shows up 
in the rendered HTML page (which is what it seems you are creating) 
even though the tab is (and indeed it is) present in the source code?  
Remember that whitespace reduced to one space in the display unless you 
use preformatted text.  You need to print the same sort of HTML code to 
control the appearance of the page that you would if you were creating 
the page manually.

-- 
EBC


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

Date: Sat, 22 Sep 2001 14:06:39 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Why are tabs converted to spaces?
Message-Id: <3bacfd60$1@news.microsoft.com>

"Philip Wasson" <pwasson@mindspring.com> wrote in message
news:3BACEE86.1128DE69@mindspring.com...
> I am trying to separate fields in a guestbook by a tab but a space is
written
> instead.  Here is the code clip:
>
>    open (GUEST,">$guestbookreal") || die "Can't Open $guestbookreal:
$!\n";
>
>          print GUEST "$FORM{'firstname'}\t";
>          print GUEST "$FORM{'lastname'}\t";
>
> Any ideas?  Thanks for taking the time to look at this.

***Polishing the crystal ball***
Is there a chance that this might be a stealth CGI question?
I.e. that $guestbookreal is actually an HTML page to be viewed in a browser?

If this is the case then my Tarrot cards suggest to read up on the HTML spec
which states that all kinds of white space are considered to be equal.

jue




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

Date: Sat, 22 Sep 2001 14:08:21 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Why are tabs converted to spaces?
Message-Id: <3bacfdd2@news.microsoft.com>

"Laocoon" <Laocoon@eudoramail.com> wrote in message
news:Xns9124E3171F6A2Laocooneudoramailcom@62.153.159.134...
> One Tab = 8 spaces..
> What else do you expect to be printed?

Actually it's 0-8 spaces, depending on where the next tab stop is.

jue




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

Date: Sat, 22 Sep 2001 14:44:47 -0700
From: Philip Wasson <pwasson@mindspring.com>
Subject: Re: Why are tabs converted to spaces?
Message-Id: <3BAD064F.B43BD447@mindspring.com>

What I mean is that one tab character (0x09) is written to the file as one space
(0x20) character.  This is confirmed by viewing the file with a hex editor!

Phil Wasson


"E.Chang" wrote:
> 
> Philip Wasson <pwasson@mindspring.com> wrote in
> news:3BACEE86.1128DE69@mindspring.com:
> 
> > I am trying to separate fields in a guestbook by a tab but a space
> > is written instead.  Here is the code clip:
> >
> >    open (GUEST,">$guestbookreal") || die "Can't Open
> >    $guestbookreal: $!\n";
> >
> >          print GUEST "$FORM{'firstname'}\t";
> >          print GUEST "$FORM{'lastname'}\t";
> >
> > Any ideas?  Thanks for taking the time to look at this.
> 
> Do you really mean a space is printed?  Or that only one space shows up
> in the rendered HTML page (which is what it seems you are creating)
> even though the tab is (and indeed it is) present in the source code?
> Remember that whitespace reduced to one space in the display unless you
> use preformatted text.  You need to print the same sort of HTML code to
> control the appearance of the page that you would if you were creating
> the page manually.
> 
> --
> EBC


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

Date: Sat, 22 Sep 2001 23:53:20 GMT
From: "E.Chang" <echang@netstorm.net>
Subject: Re: Why are tabs converted to spaces?
Message-Id: <Xns9124CB2AC7EDAechangnetstormnet@207.106.92.86>

Philip Wasson <pwasson@mindspring.com> wrote in
news:3BAD064F.B43BD447@mindspring.com: 

[Top-posted reply moved to proper location]

> "E.Chang" wrote:
>> 
>> Philip Wasson <pwasson@mindspring.com> wrote in
>> news:3BACEE86.1128DE69@mindspring.com: 
>> 
>> > I am trying to separate fields in a guestbook by a tab but a
>> > space is written instead.  Here is the code clip:
>> >
>> >    open (GUEST,">$guestbookreal") || die "Can't Open
>> >    $guestbookreal: $!\n";
>> >
>> >          print GUEST "$FORM{'firstname'}\t";
>> >          print GUEST "$FORM{'lastname'}\t";
>> >
>> > Any ideas?  Thanks for taking the time to look at this.
>> 
>> Do you really mean a space is printed?  Or that only one space
>> shows up in the rendered HTML page 

[snip]

> What I mean is that one tab character (0x09) is written to the file
> as one space (0x20) character.  This is confirmed by viewing the
> file with a hex editor! 

Ah.  Apologies for the misunderstanding.  Then I really can't tell what 
might be wrong.  It must be peciliar to your specific environment.   I 
tested with Perl 5.6.0 and 5.6.1 on Windows and Linux, and the problem 
does not occur.  The tab character is correctly being written to the 
file.  If you give some more information such as what OS you are using, 
version, and such, someone might recognize what is happening. 

-- 
EBC


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1793
***************************************


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