[15986] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3398 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 17 03:05:27 2000

Date: Sat, 17 Jun 2000 00:05:13 -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: <961225512-v9-i3398@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 17 Jun 2000     Volume: 9 Number: 3398

Today's topics:
    Re: Activeperl 5.6 wrong ascii in Windows98 <kmsproule@worldnet.att.net>
        Auto Gallery Maker <amber@babesonthebeach.com>
    Re: Auto Gallery Maker (Randal L. Schwartz)
    Re: Auto Gallery Maker <bob@bob-n.com>
    Re: concerned about flock() - Win9X issues <phill@modulus.com.au>
    Re: embedding Java and Java script in Perl (Mark P.)
    Re: flock, read, truncate, write to a file fido99@my-deja.com
    Re: GIMP on G4 Mac <rootbeer@redcat.com>
    Re: gui Perl? (Malcolm Dew-Jones)
    Re: Help- Compile Perl 5.6.0 on N-Class (HPUX11.0) (Dennis Handly)
    Re: I can't figure this one out...  (Newbie question) <abe@ztreet.demon.nl>
    Re: I can't figure this one out...  (Newbie question) (Eric Bohlman)
    Re: I can't figure this one out...  (Newbie question) <uri@sysarch.com>
    Re: I can't figure this one out...  (Newbie question) (David Bell)
    Re: I can't figure this one out...  (Newbie question) (David Bell)
    Re: I can't figure this one out...  (Newbie question) <uri@sysarch.com>
    Re: I can't figure this one out...  (Newbie question) (Abigail)
    Re: I can't figure this one out...  (Newbie question) (David Bell)
    Re: I can't figure this one out...  (Newbie question) (David Bell)
    Re: I can't figure this one out...  (Newbie question) <uri@sysarch.com>
    Re: I can't figure this one out...  (Newbie question) (David Bell)
    Re: I can't figure this one out...  (Newbie question) (David Bell)
    Re: I can't figure this one out...  (Newbie question) <lr@hpl.hp.com>
    Re: I can't figure this one out...  (Newbie question) <lr@hpl.hp.com>
    Re: I can't figure this one out...  (Newbie question) <uri@sysarch.com>
    Re: I can't figure this one out...  (Newbie question) (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 17 Jun 2000 05:26:45 GMT
From: "Kevin M. Sproule" <kmsproule@worldnet.att.net>
Subject: Re: Activeperl 5.6 wrong ascii in Windows98
Message-Id: <p_D25.5488$Uw3.343142@bgtnsc04-news.ops.worldnet.att.net>


<michaeljgardner@my-deja.com> wrote in message
news:8idfsr$psg$1@nnrp1.deja.com...
> Using the chr() function with a value of 10 returns a carriage return
> character instead of the proper ascii character.  Any ideas on how to
> get windows, or Perl, to return the proper value.
>
> Thanks,
> Michael

Michael,

binmode(STDOUT);
$char = chr(10);
print $char;

Without binmode the script emits 0D0A (a nice DOS end-of-line sequence).
With binmode the script emits 0A, just what you were looking for.

Digitally yours,

Kevin Sproule




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

Date: Fri, 16 Jun 2000 22:18:01 -0500
From: "Amber" <amber@babesonthebeach.com>
Subject: Auto Gallery Maker
Message-Id: <4dB25.192279$MB.3554164@news6.giganews.com>

I am looking for a free, and I stress free perl script that will randomly
create a thumbnail gallery from a directory of images. Each thumbnail Must
link to it's full size image.  I have found one script ($300.00) but I'm not
in the position to be able to pay for such a program.  If anyone can help,
please email me.  I'm willing to add links from ALL my pages to anyone that
can help.

Thanks
webmaster@babesonthebeach.com




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

Date: 16 Jun 2000 19:35:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Auto Gallery Maker
Message-Id: <m1d7lhm3v6.fsf@halfdome.holdit.com>

>>>>> "Amber" == Amber  <amber@babesonthebeach.com> writes:

Amber> I am looking for a free, and I stress free perl script that
Amber> will randomly create a thumbnail gallery from a directory of
Amber> images. Each thumbnail Must link to it's full size image.  I
Amber> have found one script ($300.00) but I'm not in the position to
Amber> be able to pay for such a program.  If anyone can help, please
Amber> email me.  I'm willing to add links from ALL my pages to anyone
Amber> that can help.

I've done a couple of those... see the "image gallery" columns in

        http://www.stonehenge.com/merlyn/WebTechniques/

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 16 Jun 2000 23:46:33 -0500
From: Bob Niederman <bob@bob-n.com>
Subject: Re: Auto Gallery Maker
Message-Id: <394B02A9.A37599EA@bob-n.com>

Check out cthumbs, http://puchol.com/cpg/software/cthumb/

I look forward to the links, tho if your web-site has the same domian
name as your email, I suspect there won't be a lot of crossover.

-- 
- Bob Niederman http://bob-n.com
Fight UCITA! http://www.4cite.org, http://bob-n.com/ucita



 Amber wrote:
> 
> I am looking for a free, and I stress free perl script that will randomly
> create a thumbnail gallery from a directory of images. Each thumbnail Must
> link to it's full size image.  I have found one script ($300.00) but I'm not
> in the position to be able to pay for such a program.  If anyone can help,
> please email me.  I'm willing to add links from ALL my pages to anyone that
> can help.
> 
> Thanks
> webmaster@babesonthebeach.com


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

Date: Sat, 17 Jun 2000 13:57:16 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: concerned about flock() - Win9X issues
Message-Id: <394AF71C.17CB@modulus.com.au>

Larry Rosler wrote:
> 
> In article <3949ABD1.3423@modulus.com.au> on Fri, 16 Jun 2000 14:23:45
> +1000, Peter Hill <phill@modulus.com.au> says...
> > Clinton A. Pierce wrote:
> 
> ...
> 
> > > I've used flock() on a variety of Unix and Windows systems.  Where
> > > it works (Unix with local filesystems, NT with local filesystems) it
> > > works OK.  Where it's not supported (Win9x) it's not needed.  Where it
> >
> > Win9x is a single-user multi-tasking OS - the lack of flock on Win9x is
> > unfortunate, as it is needed where multiple tasks might conflict.
> 
> But on Win9x one task cannot open a file that is already opened by
> another task, so there can be no conflict, so no need for file locking.
> In essence, the operating system imposes mandatory locking.

Larry, Bart, Clinton, japhs in general:
I'm *way* confused, and out of my depth to tackle this at a discussion
level, so as a substitute wrote the snippet below in the hope that you
could lighten my confusion. 

As you can see from the appended results:
1. It appears (to me at least) that the OS (Win95) is not imposing any
sort of locking
2. It appears (to me at least) that such absence of locking is resulting
in a predictable (not necessarily desirable) outcome for an OS without
that locking.
3. It appears (to me at least) that it would be possible to write a sub
which prevent this predictable behaviour and result in outcomes
consistent with a better OS (usual caveats of all processes cooperating
in the locking process etc.)

Given my limited experience relative to the other posters, I believe I'm
missing some fundamental point here and look forward to clarification.
TIA

#! /bin/perl -w
use strict;

open(HANDLE_1,"<flocktest.txt") || die "At pos 1, could not open
flocktst.txt for read $!";
while (<HANDLE_1>){
	print;
}
open(HANDLE_2,">flocktest.txt") || die "At pos 2, could not open
flocktst.txt for write $!";
open(HANDLE_3,">>flocktest.txt") || die "At pos 3, could not open
flocktst.txt for append $!";
open(HANDLE_4,">flocktest.txt") || die "At pos 4, could not open
flocktst.txt for write $!";
print HANDLE_2 'sausages';
print HANDLE_4 'bicycles';
close(HANDLE_1);
close(HANDLE_2);
print HANDLE_3 'oranges';
close(HANDLE_3);
close(HANDLE_4);
__END__

#This is perl, version 5.005_03 built for MSWin32-x86-object
#(with 1 registered patch, see perl -V for more detail)
#
#Copyright 1987-1999, Larry Wall
#
#Binary build 522 provided by ActiveState Tool Corp.
http://www.ActiveState.com
#Built 09:52:28 Nov  2 1999
#OS is Windows 95

#flocktest.txt (initially)
a
b
c
#flocktest.txt (after 1 or more runs)
bicyclesoranges


-- 
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/


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

Date: Sat, 17 Jun 2000 02:48:57 GMT
From: perl@imchat.com (Mark P.)
Subject: Re: embedding Java and Java script in Perl
Message-Id: <394ae698.79670710@news.ionet.net>

On Fri, 16 Jun 2000 14:03:43 -0700, Zolla Michalak
<michalak@hwr.arizona.edu> wrote:

>I have an HTML page with embedded Java and Javascript, and I would like
>to embed the whole thing in a Perl script. Actually, I did this, by
>putting the whole thing in a print statement, and it works, except that
>it can't read the java. So, I'm wondering if I need to use Java.pm or
>something else to make this work. Any ideas?????

	I beleive I answered this in a more appropriate newsgoup. Perl
gives a damn about your html or java. If your html and java are
correct it will work. Think about this, where are you executing your
cgi and where is your java app? 


>
>Thanks -zolla michalak
>

MP


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

Date: Sat, 17 Jun 2000 06:53:28 GMT
From: fido99@my-deja.com
Subject: Re: flock, read, truncate, write to a file
Message-Id: <8if797$umt$1@nnrp1.deja.com>

Hi,

The second question in the faq, "How do I change one line in a file..."
can have another answer.  The answer as it currently exists assumes
there is no file locking.  But what if one needed to lock the file? The
solution is not obvious, but here it is, based on Michael Carman's post.

To avoid conflicts between processes, the file must be locked.  The
problem with the solution as presented in the FAQ is that the file has
to be closed before it can be renamed.  In between close() and rename()
another process can put a lock on the file.   However, rename()of the
first process won't respect the second process's lock.  The second
process will discover that it cannot rename(), because the file has
been now lost by the first process's rename().

Here is the work around.  Basically, the solution involves the
following steps:

    1) Open the file read/write mode
    2) Obtain a lock on the file
    3) Read all the lines of the file into memory
    4) Go back to the beginning of the file
    5) Write out the all the lines from the copy in memory back into
the file, except the line you want to change.
    6) Truncate the file.
    7) Close the file.
    8) Unlock the file.

Here is a sample Perl program illustrating the technique:

#!/usr/bin/perl -w

$LOCK_EX = 2;
$LOCK_UN = 8;

$filename = "sample.txt";
$deleteline = "this line in sample.txt should be removed";

open (FILEHANDLE, "+< $filename") or die "Can't open $filename";
flock FILEHANDLE, $LOCK_EX;

@inbuff = <FILEHANDLE>;
seek FILEHANDLE, 0, 0;

for $line (@inbuff) {
    print FILEHANDLE $line unless ($line eq $deleteline);
}

truncate(FILEHANDLE, tell(FILEHANDLE));

close (FILEHANDLE);
flock FILEHANDLE, $LOCK_UN;

I'm not sure if the unlock is necessary after the close.

--Peter
psun@mail.com



-----Original Post------------------------------
Michael Carman wrote:
John Reynolds wrote:
>
> Opening for read/write allows me to read then append but what if
> I need to change something in the middle of the file?
>
> I think perlfaq5 (or one of the Perl books) states that there is no
way
> to seek to the middle of a file and change the contents (except for
> certain file systems). The suggestion is, read the file, truncate or
> unlink and write a new file. Which gets me back to where I started.

Believe the FAQ. Unless you're dealing with a file of fixed-length
records (i.e. replacing N bytes of data with N bytes of data) you can't
do this the way the human mind wants to. You can't just insert/delete
something in the middle; it would destroy the contiguous nature of the
file. So if you want to change line 12 of a 100 line file you must read
the whole thing in, truncate it after line 11, write your new line 12,
and then restore lines 12+ from the copy you read.

To avoid conflicts between processes, only open and lock the file
once:   Open file read/write mode.
  Obtain your lock.
  Read the contents.
  Make changes to you copy in memory.
  Truncate the old file and write out your new one.
  Unlock the file and close.

-mjc




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 16 Jun 2000 22:17:04 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: GIMP on G4 Mac
Message-Id: <Pine.GSO.4.10.10006162216450.21108-100000@user2.teleport.com>

On Sat, 17 Jun 2000, Peter L. Berghold wrote:

> Uhhmmmm... is it just me? Did I misconfigure my perl? I try doing a 
> perldoc -f GIMP and it doesn't give me back anything....

Not everything is a function! :-)

    http://search.cpan.org/search?dist=Gimp

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



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

Date: 16 Jun 2000 21:34:48 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: gui Perl?
Message-Id: <394affe8@news.victoria.tc.ca>

bradley_johnston@my-deja.com wrote:
: What is WPERL.exe? Is it a gui version of Perl.EXE? It seems to run my
: Perl script in the Windows NT environment with out the ugly DOS window
: flashing by.

: Thanks,

: Bradley

I think its just Perl.exe with the DOS .EXE headers fudged so the console
doesn't open when it runs, so you don't see the DOS box window when
running scripts that don't need a dos box window.

It's not in any way a GUI thing, it's just a dos program that's configured
to look prettier in a GUI environment. 


: Sent via Deja.com http://www.deja.com/
: Before you buy.

--


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

Date: 17 Jun 2000 05:00:26 GMT
From: dhandly@cup.hp.com (Dennis Handly)
Subject: Re: Help- Compile Perl 5.6.0 on N-Class (HPUX11.0)
Message-Id: <8if0la$s2a$4@web1.cup.hp.com>

jinz@gene.com wrote:
: LD_RUN_PATH="/usr/local/lib" ld -o ../../lib/auto/DB_File/DB_File.sl  -
: b +vnocompatwarnings -L/usr/local/lib version.o DB_File.o    -
: L/usr/local/lib -ldb
: ld: Invalid loader fixup in text space needed in output file for
: symbol "$000000A3" in input file "/usr/local/lib/libdb.a(db_appinit.o)"

This indicates that db_appinit.o was not compiled with +z.
Or you should not be linking -ldb to your shared lib.


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

Date: Sat, 17 Jun 2000 03:06:51 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <k6jlkscumbn23gsvir8bq2kjapbgo538v7@4ax.com>

On Fri, 16 Jun 2000 12:35:14 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
 ...
> In article <20000616144412.15905.00007890@ng-md1.aol.com> on 16 Jun 2000 
> 18:44:12 GMT, David Bell <db7654321@aol.comspamsux> says...
 ...
> >         $num = ++$num;
> 
> That is a ghastly statement, because it changes $num twice, and you 
> can't be sure what order things happen.  Just incrementing is enough.

It looks to me like the RHS must be evaluated before it can be assigned
to the LHS. As the pre-increment operator increments the expression
_before_ returning it, I'd say you _can_ be sure of what order 'things
happen'.

Of course, _full big yes_ on the other three.
-- 
Good luck,
Abe


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

Date: 17 Jun 2000 01:16:29 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <8iejhd$8eg$7@nntp9.atl.mindspring.net>

Larry Rosler (lr@hpl.hp.com) wrote:
: You omitted the obvious:
: 
:       $num++;
: 
: or
: 
:       ++$num;
: 
: I prefer the last from my old C days, because it doesn't have to save a 
: copy to use as a potential rvalue.  But in Perl, there is no way that 
: minute distinction can matter.

The latter can be read as "increment $num" whereas I have a harder time 
putting the former into English.



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

Date: Sat, 17 Jun 2000 03:16:16 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <x7ln05575s.fsf@home.sysarch.com>

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

  >> and that is a major loser line. you really should read perlop and learn
  >> what ++ does. you don't need to assign it back to itself. that would
  >> more properly be:
  >> 
  >> $num = $num + 1 ;
  >> or
  >> $num += 1 ;

  LR> You omitted the obvious:

  LR>       $num++;

i didn't really skip it. i was trying (poorly) to illustrate a point
about assignment and not ++. i also did mention he should look up ++.

what is amusing is how he seems to take one vague idea and run very far
in the wrong direction with it (qw and this odd use of ++).

  LR> I prefer the last from my old C days, because it doesn't have to save a 
  LR> copy to use as a potential rvalue.  But in Perl, there is no way that 
  LR> minute distinction can matter.

for some reason, i like the postfix style for its looks (unless i really
care about pre vs. post).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 17 Jun 2000 03:19:12 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <20000616231912.02872.00001127@ng-cg1.aol.com>

>well, you have ignore many suggestions and critiques. so why should we
>send you more?

Well, like I said in my last message, I'm still working through the comments
and suggestions.  I WILL correct all problems you fine people see. 
Unfortunetly, the newsreader (just AOL) sucks, and backtracking through
messages takes awhile.

>like larry sai, using a string for a boolean marker is weak
>

Bear with me here:  In english?  :)

>DB>         $num = ++$num;
>
>and that is a major loser line. you really should read perlop and learn
>what ++ does. you don't need to assign it back to itself. that would
>more properly be:
>
>	$num = $num + 1 ;
>or
>	$num += 1 ;
>

Ok, this was a point of confusion on my part.  In 'Learning Perl', on page 42
under the heading "Autoincrement ..." to the best of my understanding, says
++$num is the same as $num += 1.  From your comments, I see this is not the
case(?).

>or any string that is not 'no'. just do it like larry said and use last.
>
>	while( 1 ) {
>
>		if ( blah ) {
>
>			more blah
>		}
>		else {
>
>			print WRITEUSER "$userinfo ";
>			print "\n\tYou're on the list now!\n\n";
>			last ;
>		}
>	}
>

Ok!  One question:  what does the 1 in while(1) mean?  Thanks!

-------------------------
David Bell - Otherwise known as DB7654321

Remember to remove nospam, notrash or anything odd looking from my email
address. :)


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

Date: 17 Jun 2000 03:29:08 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <20000616232908.02872.00001130@ng-cg1.aol.com>

Correction:

>Ok, this was a point of confusion on my part.  In 'Learning Perl', on page 42
>under the heading "Autoincrement ..." to the best of my understanding, says
>++$num is the same as $num += 1.  From your comments, I see this is not the
>case(?).
>

I see that Learning Perl IS correct.  I [for some odd reason] added $num =
before ++$num.  I've corrected that mistake and many others, but, there are
probably more.  :)  When I think I've got it figured out, shall I post the code
to learn more?  (that last comment was not sarcastic, as I learn best from
mistakes.)

-------------------------
David Bell - Otherwise known as DB7654321

Remember to remove nospam, notrash or anything odd looking from my email
address. :)


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

Date: Sat, 17 Jun 2000 03:44:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <x7itv955vh.fsf@home.sysarch.com>

>>>>> "DB" == David Bell <db7654321@aol.comspamsux> writes:

  >> like larry sai, using a string for a boolean marker is weak
  >> 

  DB> Bear with me here:  In english?  :)

boolean mean a value which is only true or false. it is what is used
when you use a flag like you do here. but as we have shown you, a flag
is not needed. as less code is usually better than more code (if they do
the same thing) so first you can make the var into a boolean (and not
assign 'no' to it, assign 1 or 0 ) and just test if it is true or false
and not to compare it to something else.


  DB> $num = ++$num;
  >> 
  >> and that is a major loser line. you really should read perlop and learn
  >> what ++ does. you don't need to assign it back to itself. that would
  >> more properly be:
  >> 
  >> $num = $num + 1 ;
  >> or
  >> $num += 1 ;
  >> 

  DB> Ok, this was a point of confusion on my part.  In 'Learning Perl',
  DB> on page 42 under the heading "Autoincrement ..." to the best of my
  DB> understanding, says ++$num is the same as $num += 1.  From your
  DB> comments, I see this is not the case(?).

so if $num++ is the same as $num += 1, why do BOTH? what you did worked
but like before, it was more code than necessary to do the job.

  DB> Ok!  One question:  what does the 1 in while(1) mean?  Thanks!

it means 1. seriously that is all it is. read what while does and what
it does to the expression in its (). then figure out what it will do if
the expression is 1. you are not using enough logical thought here.

	while( $foo eq 'bar' ) {

what does that do? what does eq return?

	while( 1 ) {

what does that expression equal in a boolean context? why does while put
its expression in a boolean context? because it is a BOOLEAN loop
operator!!

you need to learn some fundamental computer programming logic and
terminology. people here use both and can't always translate to
english in each case. you have a lot to learn grasshopper.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 17 Jun 2000 00:26:09 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <slrn8km0h8.mlf.abigail@alexandra.delanet.com>

Eric Bohlman (ebohlman@netcom.com) wrote on MMCDLXXXII September MCMXCIII
in <URL:news:8iejhd$8eg$7@nntp9.atl.mindspring.net>:
;; Larry Rosler (lr@hpl.hp.com) wrote:
;; : You omitted the obvious:
;; : 
;; :       $num++;
;; : 
;; : or
;; : 
;; :       ++$num;
;; : 
;; : I prefer the last from my old C days, because it doesn't have to save a 
;; : copy to use as a potential rvalue.  But in Perl, there is no way that 
;; : minute distinction can matter.
;; 
;; The latter can be read as "increment $num" whereas I have a harder time 
;; putting the former into English.


$num incrementing.


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: 17 Jun 2000 04:43:02 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <20000617004302.02872.00001158@ng-cg1.aol.com>

>what is amusing is how he seems to take one vague idea and run very far
>in the wrong direction with it (qw and this odd use of ++).

Well, I was mistaken about qw (I didn't know better), but seeing that ++
increments by 1, just as $num + 1, does it matter?  If there is a real, good
reason not to use ++, I'll use $num += 1 or $num + 1 instead.  In your
experience, what are the disadvantages of ++?  Thankyou.

-------------------------
David Bell - Otherwise known as DB7654321

Remember to remove nospam, notrash or anything odd looking from my email
address. :)


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

Date: 17 Jun 2000 05:08:30 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <20000617010830.02872.00001169@ng-cg1.aol.com>

>it means 1. seriously that is all it is. read what while does and what
>it does to the expression in its (). then figure out what it will do if
>the expression is 1. you are not using enough logical thought here.
>
>	while( $foo eq 'bar' ) {
>
>what does that do? what does eq return?

Ah ha!  Well, it would compare $foo to "bar".  If equal, it would return true,
which equals 1 (I think.  Actually, I'm not sure.  If thinking in exit codes, 0
equals success, which would lead me to believe that 0 is true.  This is very
simple, but I can't remember which is which.).


>	while( 1 ) {
>
>what does that expression equal in a boolean context? why does while put
>its expression in a boolean context? because it is a BOOLEAN loop
>operator!!
>
>you need to learn some fundamental computer programming logic and
>terminology. people here use both and can't always translate to
>english in each case. you have a lot to learn grasshopper.
>
Yup, I know.  I'll get it!  ...One of these days.  Thanks!


-------------------------
David Bell - Otherwise known as DB7654321

Remember to remove nospam, notrash or anything odd looking from my email
address. :)


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

Date: Sat, 17 Jun 2000 05:25:36 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <x7g0qc6fqo.fsf@home.sysarch.com>

>>>>> "DB" == David Bell <db7654321@aol.comspamsux> writes:

  DB> Well, I was mistaken about qw (I didn't know better), but seeing
  DB> that ++ increments by 1, just as $num + 1, does it matter?  If
  DB> there is a real, good reason not to use ++, I'll use $num += 1 or
  DB> $num + 1 instead.  In your experience, what are the disadvantages
  DB> of ++?  Thankyou.

you are not getting the point. all 3 will work. it is a case of matching
what you mean the best. 

	$num = $num + 1 ;

that is like older languages like basic and PL/I. it was the only way to
increment a number.

	$num += 1 ;

that comes from c and was faster (in most cases) and clearer as you
didn't have to duplicate the left side. if that happened to be a complex
structure or pointer expression, it was less bug prone. it is also the
way to bump by a value other than 1 as in $num += 3 

	$num++ ;

this is a SIDE EFFECT operation. it increments $num and returns the value
AFTER that.

	++$num ;

that increments num and returns the value BEFORE the increment.

if all you want is the increment side effect, then either will do.

but the increment versions are useful inside more complex expressions
where they can be used effectively.

you have a long path to trod, grasshopper.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 17 Jun 2000 05:33:30 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <20000617013330.02872.00001179@ng-cg1.aol.com>

Well, at the cost of overposting (that possible?) on one day, I think I *may*
have the script more to everyone's liking...  And best of all, it works! hehe..
 Here is it:

#!/usr/bin/perl -w
use strict;
my $num = 0;
my $userfile = "/home/david/perl/users";
open(USER, $userfile) or die "Can't open $userfile $!\n";
my @user = split ' ', <USER>;
close(USER) or die "can't close $userfile: $!\n";
chomp(my $userinfo = `id -un`) or die "Can't execute id -un $!\n";
open(WRITEUSER, ">>$userfile") || die "Can't open $userfile $!\n";
while(1) {
    if ($user[$num] eq $userinfo) {
        print "\n\tYou're already using the internet.\n\n";
        last;
    } elsif ($num < 9) {
        ++$num;
    } else {
        print WRITEUSER "$userinfo ";
        print "\n\tYou're on the list now!\n\n";
        last;
    }
}
close(WRITEUSER) or die "Can't close $userfile $!\n";


This'll write to $userfile in this format: name1 name2 name3 ... .  I haven't
noticed any problems yet, but this script (in it's current form) is only a
test.  I will use most all of it in my connect script (exept for the "already
on the internet" and "now on the list" messages.).  My remaining questions are:
 What's the easiest way to add this to the connect script?  (I know it's all
very short, and I can easily add it by hand.  But, I'd rather learn an easier
way for longer programs I may need in the future.)  And, for the disconnect
script, how do I go about finding, and removing $userinfo from the array.  I'll
also need to know when the array is empty, which at that time, it will
disconnect (perhaps a way to count the number of words in the array?).  Come to
think of it, when $userfile is emtpy, I get the 'Use of uninitialized value at
 ./user line 11.' error until it adds a name to $userfile. If I added a word in
the file (like test) that the word counter could ignore it would work though,
Is this possible?  ...I really have no idea.  Thanks again!

-------------------------
David Bell - Otherwise known as DB7654321

Remember to remove nospam, notrash or anything odd looking from my email
address. :)


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

Date: 17 Jun 2000 05:51:11 GMT
From: db7654321@aol.comspamsux (David Bell)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <20000617015111.02848.00001095@ng-cg1.aol.com>

>$num++ ;
>
>this is a SIDE EFFECT operation. it increments $num and returns the value
>AFTER that.
>
>	++$num ;
>
>that increments num and returns the value BEFORE the increment.
>
>if all you want is the increment side effect, then either will do.
>

Ahhhhhhh...  I see.  Well, in this case, it's less code.  hehe

-------------------------
David Bell - Otherwise known as DB7654321

Remember to remove nospam, notrash or anything odd looking from my email
address. :)


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

Date: Fri, 16 Jun 2000 23:22:10 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <MPG.13b4b8ee5c2f3cb798ab9a@nntp.hpl.hp.com>

In article <20000617015111.02848.00001095@ng-cg1.aol.com>, 
db7654321@aol.comspamsux says...

Missing attribution to Uri Guttman, who deserves the credit^Wblame.

> >$num++ ;
> >
> >this is a SIDE EFFECT operation. it increments $num and returns the value
> >AFTER that.
> >
> >	++$num ;
> >
> >that increments num and returns the value BEFORE the increment.
> >
> >if all you want is the increment side effect, then either will do.
> 
> Ahhhhhhh...  I see.  Well, in this case, it's less code.  hehe

Yes.  Too bad Uri described the values returned backwards.  But as each 
of these expressions is here used in void context, it makes no never-
mind which one is used, or what the erroneous description is.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 16 Jun 2000 23:28:59 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <MPG.13b4ba863eb1d69b98ab9b@nntp.hpl.hp.com>

In article <x7itv955vh.fsf@home.sysarch.com>, uri@sysarch.com says...

 ...

> 	while( 1 ) {
> 
> what does that expression equal in a boolean context? why does while put
> its expression in a boolean context? because it is a BOOLEAN loop
> operator!!

Or

   while ( ) {

Maybe more opaque for a novice programmer, but analogous to the empty 
conditional expression in

    for ( ; ; ) {

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 17 Jun 2000 06:51:44 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <x7d7lg6br5.fsf@home.sysarch.com>

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

  LR> In article <20000617015111.02848.00001095@ng-cg1.aol.com>, 
  LR> db7654321@aol.comspamsux says...

  >> >$num++ ;
  >> >
  >> >this is a SIDE EFFECT operation. it increments $num and returns the value
  >> >AFTER that.
  >> >
  >> >	++$num ;
  >> >
  >> >that increments num and returns the value BEFORE the increment.

  LR> Yes.  Too bad Uri described the values returned backwards.  But as each 
  LR> of these expressions is here used in void context, it makes no never-
  LR> mind which one is used, or what the erroneous description is.

so i did. got a little frustrated with the OP and doing other stuff
distracted me. 

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 17 Jun 2000 01:56:38 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: I can't figure this one out...  (Newbie question)
Message-Id: <slrn8km4om.9tj.tadmc@magna.metronet.com>

On 17 Jun 2000 05:08:30 GMT, David Bell <db7654321@aol.comspamsux> wrote:

>If equal, it would return true,
>which equals 1 (I think.  Actually, I'm not sure.  If thinking in exit codes, 0
>equals success, which would lead me to believe that 0 is true.  This is very
>simple, but I can't remember which is which.).


The problem may be that Perl's convention is the opposite
of Unix's convention.

In Unix, zero means success, non-zero means failure.

In Perl, true means success, false means failure.


There are four false values in Perl:

   numerically zero (e.g. 0, 0.0, -0, 0.0e10, 5-5, ...)

   '' (the empty string)

   '0' (a one-char string where the one char is the zero digit)

   undef

All other values ( 1 is one of these :-) are true.



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


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3398
**************************************


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