[8237] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1855 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 11 00:15:11 1998

Date: Tue, 10 Feb 98 21:00:20 -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           Tue, 10 Feb 1998     Volume: 8 Number: 1855

Today's topics:
        Counter problem - resets (Technical Wizard)
    Re: Counter problem - resets <tchrist@mox.perl.com>
        FIND2PERL (Ed.Q.Bridges)
    Re: foreach and my() [GUTS; LONG] <rjk@coos.dartmouth.edu>
        How do I get the time? <k383@hkstar.com>
    Re: How do I get the time? <tchrist@mox.perl.com>
    Re: How to tell if your CGI-related question belongs in <camerond@mail.uca.edu>
    Re: Huge arrays: 'Out of Memory' <zenin@best.com>
        Perl For Win32 <sixtoeb@pop3.cris.com>
        Perl to Java/C <jeff@MelbourneIT.com.au>
    Re: perl5.003 and now CGI won't work <rjk@coos.dartmouth.edu>
    Re: polyform error (Martien Verbruggen)
    Re: Problems installing DBI on Win 95 (Nathan V. Patwardhan)
    Re: RFC about ``Matt's Script Archive'' (Jack Straw)
    Re: RFC about ``Matt's Script Archive'' <tchrist@mox.perl.com>
    Re: save away filehandles... <tchrist@mox.perl.com>
    Re: save away filehandles... (Gabor)
    Re: Seriously Off Topic, but a Common Complaint/Problem (Michael Wang)
    Re: Syntax-coloring editor for NT (Andy Lester)
    Re: SYSTEM command - How do you return data to the brow (Martien Verbruggen)
    Re: TOOLS USA '98: 2nd Call for Papers & Registration (Martien Verbruggen)
    Re: Using flock? (Michael Wang)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 10 Feb 1998 20:51:24 -0800
From: "Doug Munn (Technical Wizard)" <doug@idi-ut.com>
Subject: Counter problem - resets
Message-Id: <34E12E4C.26D4@idi-ut.com>

I'm having a horrible problem with a counter file resetting every few
days.  Originally, I just read the galcntr file, updated then rewrote
the file.  Then I declared the variable, thinking that some memory might
be getting stomped, then I tried locking the file.

The code is below:


$galcnt=0;
open (GALCNTRIN, "cgi-bin/galcntr");
flock (GALCNTRIN, 2);
$galcnt = <GALCNTRIN>;
close GALCNTRIN;
flock (GALCNTRIN, 8);
$galcnt++;
open (GALCNTROUT, ">cgi-bin/galcntr");
flock (GALCNTOUT, 2);
print GALCNTROUT $galcnt;
close GALCNTROUT;
flock (GALCNTROUT, 8);


HELP!!!  Driving me nuts.

Doug Munn



 
         * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         *           Intermountain Digital Imaging, LC         *
         *                 3111 South 4400 West                *
         *              Salt Lake City,  UT   84120            *
         *                 PH/FAX (801) 963-0132               *
         *  email sales@idi-ut.com  -   http://www.idi-ut.com  *
         *               download - ftp.idi-ut.com             *
         *            upload - ftp.idi-ut.com/incoming         *
         * * * * * * * * * * * * * * * * * * * * * * * * * * * *


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

Date: 11 Feb 1998 04:48:23 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Counter problem - resets
Message-Id: <6brain$3rd$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

Relying upon that ineffably perverse monstrosity of newsreader-wannabe,
Mozilla 3.01 (Win16; I), doug@idi-ut.com in comp.lang.perl.misc writes:

:I'm having a horrible problem with a counter file resetting every few
:days.  Originally, I just read the galcntr file, updated then rewrote
:the file.  Then I declared the variable, thinking that some memory might
:be getting stomped, then I tried locking the file.

Why did you neglect the FAQ?

   % man perlfaq5
   How can I lock a file?
   ....
   What can't I just open(FH, "">file.lock")?
   ...

   I still don't get locking.  I just want to increment the number in
   the file.  How can I do this?

   Didn't anyone ever tell you web-page hit counters were useless?

:$galcnt=0;
:open (GALCNTRIN, "cgi-bin/galcntr");

Did you check the return value from that system call?

:flock (GALCNTRIN, 2);

Did you check the return value from that system call?

:$galcnt = <GALCNTRIN>;
:close GALCNTRIN;

Did you check the return value from that system call?

:flock (GALCNTRIN, 8);

Did you check the return value from that system call?

Why are you unlocking an invalid (closed) file handle?

:$galcnt++;

*THE HORROR*

:open (GALCNTROUT, ">cgi-bin/galcntr");

Did you check the return value from that system call?

:flock (GALCNTOUT, 2);

Did you check the return value from that system call?

:print GALCNTROUT $galcnt;

Did you check the return value from that system call?

I don't imagine you thought to flush.

I suppose mentioning O_SYNC at this point would just confuse.

:close GALCNTROUT;

Did you check the return value from that system call?

:flock (GALCNTROUT, 8);

Did you check the return value from that system call?

Why are you unlocking an invalid (closed) file handle?

Here's my question: why are you incrementing your variable when you don't
have the file locked?  Didn't anyone ever teach you about semaphores and
locking, critical sections, and transactional integrity?  You'd better
retake that operating systems design course you seem to have forgotten,
as well as the one on hand-coded database design.

CGI isn't easy.  I'm afraid that contrary to popular belief,
programming is serious stuff.  Whoever told you it was has done you a
cruel disservice.  Programming just isn't at *all* trivial.   You can't
learn it in 7 days, or 21, or whatever.  It's a real profession, with
theoretical issues that you can't just skip over.  And data integrity
in a multiprocessing system is no simple task.

I increasingly begin to understand why some universities require
that its compsci majors study the Euclid's Prime Number Theorem,
the Fundamental Theorem of Calculus, Cantor's Diagonalization Proof,
Goedel's Incompleteness Theorem, and the ramifications of Halting Problem
in everyday life.  These may not be involved in daily programming, but
it helps develop a rigorous mind.  And it gives those who would progress
from typist to word-processor devotee to HTML documenter to CGI scripter
to distributed multithreaded operating systems design specialist cause
for pause.  You just can't do that without proper training.

I'm sorry is this is really too harsh a diatribe for your simple problem.
But just because it seems simple doesn't mean it is.  You've got some
fundamental principles to go back and learn.

Meanwhile, please go read the FAQ.  All nine sections, cover to cover.
Pretty please.

And remember: there is a newsgroup for CGI programming -- and it's
not this one.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

Definition of a hermaphrodite: a bisexual built for two.
    --Jeff Daiell


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

Date: Mon, 09 Feb 1998 15:23:00 GMT
From: eqbridges@cbs.com (Ed.Q.Bridges)
Subject: FIND2PERL
Message-Id: <34df1eb0.253065018@news.spry.com>



is there any documentation about using the -tar switch for find2perl?

i'm having trouble dereferencing symbolic links in a directory
accessed by a script generated by find2perl.  if anyone is aware of
a solution to this as well, i'd be very grateful.  the script is
below.

thanks for any assistance.
--ed--



##############################################################################

#!/opt/local/gnu/bin/perl
require "find.pl";

### findfiles.pl   begun 01.24.98   eqbridges@cbs.com
### * copies specific types of files into a tarfile
### * excludes contents of specific directories
### * deletes the copied files
###
### Usage:
### The path to the parent directory of the directory 
### tree to be searched is passed as an argument.
### The tarfile is written to STDOUT, and can be 
### redirected wherever.
###
### Extensions included:
###   * gif, jpg, jpeg, ht.*, class, swf
### Directories excluded:
###   * wch, temp
###
### sub wanted is called by the find subroutine,
### in find.pl.  $dir contains the current directory 
### name, and $_ the current filename within that directory.
### $name contains "$dir/$_".  You are cd'ed to $dir 
### when the function is called.  
###
### Caveats:
###   * does not exclude the directory entries of
###   excluded directories, only their contents.

CONFIG:
{
    $SearchDir = shift;
    chdir( $SearchDir );
}

MAIN:
{
    &find('.');
    &tflushall;

    if(scalar @Delete)
    {
      foreach(@Delete)
      {
##DEBUG##   print STDERR "Error Deleting $_: $!\n" unless (unlink);
          print STDERR "Deleting $_\n";
    }
    }

    exit;
}


sub wanted {
    (
     ### PRUNED DIRECTORIES
     /^wch$/  && ($prune = 1) 
     || 
     /^temp$/ && ($prune = 1) 
     || 
     ### INCLUDED FILES
     /^.*\.gif$/i   || 
     /^.*\.jpg$/i   || 
     /^.*\.jpeg$/i  || 
     /^.*\.htm.*$/i || 
     /^.*\.class$/i || 
     /^.*\.swf$/i   
     ) 
      && ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = stat($_)))
&& &tar(STDOUT
);

    push @Delete, $name unless (-d $& or !(-f $&));
}

sub tar {
    local($fh) = @_;
    local($linkname,$header,$l,$slop);
    local($linkflag) = "\0";

    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
      $atime,$mtime,$ctime,$blksize,$blocks) = stat(_);
    $nm = $name;

    if ($nlink > 1) {
      if ($linkname = $linkseen{$fh,$dev,$ino}) {
          $linkflag = 1;
      }
      else {
          $linkseen{$fh,$dev,$ino} = $nm;
      }
    }
    if (-f _) {
    open(IN, "./$_\0") || do {
          warn "Couldn't open $name: $!\n";
          return;
      };
      $size = 0 if $linkflag ne "\0";
    }
    else {
      $linkname = readlink($_);
      $linkflag = 2 if defined $linkname;
      $nm .= '/' if -d _;
      $size = 0;
    }

    $header = pack("a100a8a8a8a12a12a8a1a100",
      $nm,
      sprintf("%6o ", $mode & 0777),
      sprintf("%6o ", $uid & 0777777),
      sprintf("%6o ", $gid & 0777777),
      sprintf("%11o ", $size),
      sprintf("%11o ", $mtime),
      "        ",
      $linkflag,
      $linkname);
    $l = length($header) % 512;
    substr($header, 148, 6) = sprintf("%6o", unpack("%16C*",
$header));
    substr($header, 154, 1) = "\0";  # blech
    $tarout{$fh} .= $header;
    $tarout{$fh} .= "\0" x (512 - $l) if $l;
    if ($size) {
      &tflush($fh) while ($l = length($tarout{$fh})) >= 10240;
      while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) {
          $slop = length($tarout{$fh}) % 512;
          $tarout{$fh} .= "\0" x (512 - $slop) if $slop;
          &tflush($fh);
          $l = length($tarout{$fh});
      }
    }
    close IN;
}

sub tflush {
    local($fh) = @_;

    while (length($tarout{$fh}) >= 10240) {
      syswrite($fh,$tarout{$fh},10240);
      ++$blocks{$fh};
    substr($tarout{$fh}, 0, 10240) = '';
    }
}

sub tflushall {
    local($len);

    foreach $fh (keys %tarout) {
      $len = 10240 - length($tarout{$fh});
      $len += 10240 if $len < 1024;
      $tarout{$fh} .= "\0" x $len;
      &tflush($fh);
    }
}



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

Date: Tue, 10 Feb 1998 22:51:30 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Denis Goddard <dgoddard@us.oracle.com>
Subject: Re: foreach and my() [GUTS; LONG]
Message-Id: <34E12044.ECD67F06@coos.dartmouth.edu>

Denis Goddard wrote:
> 
> Chipmunk wrote:
> >
> # Looks like when the tokenizer gets a "for", it plows thru with no care
> # about "foreach" vs. "for", which is why "for $a ( 1 .. 3 )" works
> # *exactly* like "foreach $a ( 1 .. 3 )"  Hah! I always wondered about that.

Why wonder when you can read the documentation?

from the perlsyn manpage:
     The 'foreach' keyword is actually a synonym for the 'for' keyword, so you
     can use 'foreach' for readability or 'for' for brevity.

> [...]
> > Unlike the first two, which leave $a scoped to the package level,
> > foreach has $a lexically scoped to the foreach loop.
> 
> Actually, I think that it's not "for" vs "foreach", but rather the
> different types of expressions you used to control the loop iteration.

I already knew that the keywords "for" and "foreach" were equivalent.
My point was that this loop:

my($a);
for ($a=1;$a<=3;++$a) {
}

does not have the same effect as this loop:

my($a);
foreach $a (1..3) {
}

The distinction isn't the 'for' and 'foreach' keywords, but the 'for'
and 'foreach' loop styles: for(;;) vs. foreach $ (@)
That's the readibility approach mentioned in the docs.  :-)

> [...]
> TO CHIPMUNK'S ACTUAL QUESTION!  :)
> ==============================
> Yeah, I *think* I see a number of reasons why it behaves the way it does.
> 
> First and foremost, it avoids the crap we had to do in 100-level CS classes:
>      "int i,j,k,l,m,n,o,x,y,z,p,d,q;  /* iteration variables */"
> Second and secondmost, no matter what kind of variable or loop is being
> used, it goes into a new context (via 'remember') which gets neatly STACKED.
> Third, and it seems most importantly, speed. You want a new scope to spring
> up and protect yer fast-acting loop variable at just the right moment, right?

No, I don't want that.  :-)
That's how I found this "feature" - I had code like this:

my($id, $id_iter);
foreach $id_iter (@ids) {
  $id = $id_iter;
  &process_id();
}

sub do_something {
  print "$id\n";
}

[Note: in my real code, there are about 20 different functions that use $id
and other related variables.]

I was only using $id_iter as the foreach variable, and immediately copying the
value to $id.  I figured, why use the extra variable?  So I replaced it with:

my($id);
foreach $id (@ids) {
  &process_id();
}

And my code was immediately broken.

> [...]
> P.S. "Okay, I am cool enough to hang out in this newsgroup now?"   :)
>      (you can say, "no".....)

"Yes."

Chipmunk


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

Date: Wed, 11 Feb 1998 10:30:17 +0800
From: Richard Jackson <k383@hkstar.com>
Subject: How do I get the time?
Message-Id: <34E10D39.13CD2921@hkstar.com>

I want to write a cgi to get the time. However, I've only know how to
write a script to get local server time. How can I get the other server
time?



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

Date: 11 Feb 1998 04:24:55 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How do I get the time?
Message-Id: <6br96n$t37$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Richard Jackson <k383@hkstar.com> writes:
:I want to write a cgi to get the time. However, I've only know how to
:write a script to get local server time. How can I get the other server
:time?

What is an "other server"?  You mean you want the server to ask the
client for the time?  What client?  What about proxies?  What about
asking in a CGI group instead of here?  What about Naomi?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    I already have too much problem with people thinking the efficiency of
    a perl construct is related to its length.  On the other hand, I'm
    perfectly capable of changing my mind next week...  :-) --lwall


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

Date: Tue, 10 Feb 1998 21:44:48 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: Joe McMahon <joe.mcmahon@gsfc.nasa.gov>
Subject: Re: How to tell if your CGI-related question belongs in comp.lang.perl.misc
Message-Id: <34E11EB0.C504A010@mail.uca.edu>

[cc'd to JMcM]

Joe McMahon wrote:
> 
> [snip to par. 2]
> If you've written up your requirements, but aren't sure how to
> proceed, you'll need to learn (or refresh your memory) on how CGI 
> works first, no matter what language you're going to use. Try
> comp.infosystems.cgi.authoring for help on how to get started writing
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
you must mean comp.infosystems.www.authoring.cgi

> CGI programs. You're not ready for comp.lang.perl.misc yet.

Cameron Dorey
camerond@mail.uca.edu


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

Date: 11 Feb 1998 03:17:58 GMT
From: Zenin <zenin@best.com>
Subject: Re: Huge arrays: 'Out of Memory'
Message-Id: <887167346.344458@thrush.omix.com>

Howard S. Ostrowsky <shermo@sb.grci.com> wrote:
: I have been using Perl to process sometimes-very-large data files.

	Ditto.

: It is a great advantage when the entire file can be slurped into
: memory all at onec.

	Err, ok...why?  This more then oftin leads to problems such as
	you're having.  While I do have some vary memory hungry programs,
	they are rare and I bend over backwards to avoid them.

:  But sometimes the files are too long.  Then
: I get a crash (or a hang -- same thing) with the 'Out of Memory'
: message.  The problem is, I have no idea which files will cause this
: error until I try them.

	Exactly why this style should be avoided whenever possible.

: Is there some way I could intercept the error message before the crash

	Yes, kinda.  You can recompile using Perl's internal malloc() with
	a couple flags set.  It will then allow you to use the $^M variable
	as a temp storage space in such a memory condition.

	Be warned however, that it's VARY unlikely this will be of any help
	to you.  Not only does it simply not work on some platforms
	(Solaris and FreeBSD are what I've had problems with so far), it
	also doesn't have any reliable string to match yet.  That is, the
	string 'Out of memory!' is only one of a few that you could get and
	none of which are really documented.

: and try to recover from the problem (possibly by subdividing the 
: input file)?

	No.  If you're lucky you can print out a stack trace or other
	debugging info before you seg fault, but only if you're lucky.

	It should be considered a debug and mission critical clean shutdown
	tool ONLY.

: Although I have been using Perl pretty successfully for
: about a year now, I have no idea what might be the best way to
: attack this problem.

	Don't use so much memory.  If you must, try setting your limits
	higher.  Use the ulimit or limit command (shell depending) and maybe
	even adjust /etc/login.conf to allow you're program to suck as much
	memory as it wants. -I've had problems with programs that wanted
	more then 32 megs of memory because of my /etc/login.conf settings,
	when the system had 100+ megs of memory free, before swap!  So check
	your hard and soft memory limits.

-- 
-Zenin
 zenin@best.com


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

Date: Wed, 11 Feb 1998 11:30:24 -0800
From: Sixto Becerra <sixtoeb@pop3.cris.com>
Subject: Perl For Win32
Message-Id: <34E1FC50.D464A684@pop3.cris.com>

I just started to learn about perl for Win32.
I installed a version 5 copy in a directory c:/perl
I also place the file CGI.PM in the bin directory, all files with
extension *.pl
are associated with perl.exe but I can not get any of the examples that
came with the book to work.  the example supposet to take the user first
name and last, display thank you notice and save the information in a
*.txt file.  When I run it the browser wants me to "save to disk"
instead or displaying the greetings and vaving it to the specified
file.  What am I doing wrong. please help.
sixto




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

Date: Wed, 11 Feb 1998 15:49:25 +1000
From: Jeff Liu <jeff@MelbourneIT.com.au>
Subject: Perl to Java/C
Message-Id: <34E13BE5.F09E1581@MelbourneIT.com.au>

Hi there,

Is there any tools to convert Perl scripts to Java or C?

Thanks in advance.

Jeff Liu



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

Date: Tue, 10 Feb 1998 23:15:01 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: perl5.003 and now CGI won't work
Message-Id: <34E125C8.48891D1C@coos.dartmouth.edu>

Rod Bush wrote:
> 
> I just installed the latest version of wwwstat on my Linux based Apache
> web server. An upgrade to perl5.003 came with it. Now none of my cgi
> scripts are working.

How are they not working?  Try

perl -cw script.cgi

from the command line and see what useful error messages you get.

Chipmunk


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

Date: 11 Feb 1998 02:37:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: polyform error
Message-Id: <6br2t4$re1$2@comdyn.comdyn.com.au>

In article <34E0F5D0.7D2A@mail.y-net.com.au>,
	admin <admin@mail.y-net.com.au> writes:
> I have a nt4 operating system and option pack 4.I loaded polyform into

hmm.

> my inetpub/scripts file.The problem I am having is that every time I
> tried to submite an application an error 500,documents contians no data
> or  HTTP Error 405
> 
> 405 Method Not Allowed
> 
> The method specified in the Request Line is not allowed for the resource
> identified by the request.
> Please ensure that you have the proper MIME type set up for the resource
> you are requesting.

bad text formatting, please fix before posting again.

> Please contact the server's administrator if this problem persists.
> 
> Please advice.

Why don't you do what it suggests? This really has nothing to do with
perl. It's a problem with the setup of your server. Contact your web
site admin, or if that person doesn't know, post to a CGI group, or a
group specific to your Web server. You should most likely also read
the CGI FAQ's

http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.       | make a better idiot.
NSW, Australia                      | 


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

Date: 11 Feb 1998 02:50:29 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Problems installing DBI on Win 95
Message-Id: <6br3ll$l03@fridge.shore.net>

Gurusamy Sarathy (gsar@engin.umich.edu) wrote:

: I hear you can make it work if you use 4DOS/NT and dmake.
: Don't forget to change 'nmake' to 'dmake' in Config.pm,
: if you decide to try that.

The original poster might also have better results if the try to build
Perl with cygwin32 (or a supported win32 compiler).  PERL.EXE builds
out of the box, but you'll have no less than a million problems trying
to get the extensions (like POSIX) to work under win95.  It's slightly
less irritating under NT 4.  Underscore the word "slightly".

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: Wed, 11 Feb 1998 02:12:44 GMT
From: jackstraw@notachance.net (Jack Straw)
Subject: Re: RFC about ``Matt's Script Archive''
Message-Id: <34e108e2.6356992@news.erols.com>

Tom Christiansen in <6bqqiu$l7c$5@csnews.cs.colorado.edu>:
; [courtesy cc of this posting sent to cited author via email]
;
;In comp.lang.perl.misc, palincss@nicom.com writes:
;:Executive summary:  a train wreck waiting to happen.
;:Further commentary:  it doesn't take all that long to rewrite the
;:offending routines and add flocking as required.  Why, oh why
;:has Matt not done that yet?
;
;Bad programmer, or evil.  Take your pick.
;
;--tom

Prolly for the same reason YOU haven't done it yet.  And given it away
so prolificly...   Not much time for free work -- you get what you pay
for.


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

Date: 11 Feb 1998 02:24:33 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: RFC about ``Matt's Script Archive''
Message-Id: <6br251$b9m$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, using an obfuscated address now reveal for all
to grep from the newsspool, jackstraw@erols.com (Jack Straw) writes:

:>Bad programmer, or evil.  Take your pick.
:Prolly for the same reason YOU haven't done it yet.  And given it away
:so prolificly...   Not much time for free work -- you get what you pay
:for.

Hello?  It's *his* code!  And it's crud.  It's not up to me
to fix his mistakes.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    It's documented in The Book, somewhere...
            --Larry Wall in <10502@jpl-devvax.JPL.NASA.GOV>


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

Date: 11 Feb 1998 04:23:34 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: save away filehandles...
Message-Id: <6br946$t37$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, ttdsuen@ln.edu.hk (Daniel Suen) writes:
:I am writing a perl script which tries to save away a number of file
:descriptors in an array for later use. However, it seems that it does
:not seem to work. I am using Perl 5.003. My code looks like the following,

If you had 5.004, you would find that this is covered in the
standard perlfaq5 manpage:

    How can I make a filehandle local to a subroutine?  How do I pass
    filehandles between subroutines?  How do I make an array of
    filehandles?

:while (...) {
:
:$fd = new FileHandle ">>$some_file_name";

No, you mean $fh.  $fd = fileno($fh), which won't help you.

:$ofilehandle[$i] = $fd;
:$i++;
:}
:print $ofilehandle[5] "hello, world\n";

:The last line "print" cannot get through Perl as operators are expected
:after [5]. Any help would be appreciated through email to "ttdsuen@ln.edu.hk".

You're being hosed by indirect object syntax.  This too is covered
in the aforecited FAQ.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
:The only reason [not to use] perl is that some sysadmins don't allow software that they didn't pay for.
By all means, let them send me money if it makes them feel better.  :-)
	--Larry Wall in <1993Dec13.213032.26623@netlabs.com>


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

Date: 11 Feb 1998 04:58:40 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: save away filehandles...
Message-Id: <slrn6e2bqd.2sm.gabor@vnode.vmunix.com>


In comp.lang.perl.misc, Daniel Suen <ttdsuen@ln.edu.hk> wrote :
# 
# Dear All,
# 
# I am writing a perl script which tries to save away a number of file
# descriptors in an array for later use. However, it seems that it does
# not seem to work. I am using Perl 5.003. My code looks like the following,
# 
# while (...) {
# 
# $fd = new FileHandle ">>$some_file_name";
# $ofilehandle[$i] = $fd;
# $i++;
# 
# }
# print $ofilehandle[5] "hello, world\n";

I think this is in the FAQ somewhere.

print {$ofilehandle[5]} "hello, world\n";

# The last line "print" cannot get through Perl as operators are expected
# after [5]. Any help would be appreciated through email to "ttdsuen@ln.edu.hk".
# Thanks!
# 
# daniel

gabor.
--
    But you have to allow a little for the desire to evangelize when
    you think you have good news.  
        -- Larry Wall in <1992Aug26.184221.29627@netlabs.com>


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

Date: 11 Feb 1998 01:54:47 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: Seriously Off Topic, but a Common Complaint/Problem in this NG
Message-Id: <6br0d7$8jc$1@news.ml.com>

Tom Christiansen  <tchrist@mox.perl.com> wrote:
>rn and sons, originally by Larry.  I use trn 4.0, which has perl-aware
>scoring abilities.

trn is very hard to build since it does not include inews. 

inew can be obtained from nntpclient software, but it
can not be compiled with major operation on the code. 
I am using solaris. 


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

Date: 11 Feb 1998 01:57:46 GMT
From: petdance@maxx.mc.net (Andy Lester)
Subject: Re: Syntax-coloring editor for NT
Message-Id: <6br0iq$5k7$1@usenet40.supernews.com>

: Microsoft IS screwing the rest of us.  The "free market" does not 
: exist in the presence of a monopoly.  Microsoft does not have 
: competitors, at least not any that last.  They use underhanded 
: legalisms, lies, marketing, and their unique position in the economy 
: to destroy any competitors that might dare to oppose them.


Good thing they don't have a programmer's editor available, or I might
have bought it if it was what I liked best.

: Most consumers are stupid.  They buy whatever has the best TV ad or the 
: glitzyist interface.  That leaves those of us who know better stuck with 
: the choice between superior but incompatible solutions or mainstream 
: mediocrity.

So why did we buy Multi-Edit?  It has neither TV ads (which I wouldn't
have seen anyway), and it has an ugly (albeit syntax-coloring) interface.

I'll speak for me on this one: I tried them both.  I liked Multi-Edit.  I
have never liked emacs.  So I prefer one over the other.  Bummer on yer
crusade.

: There is a difference between the need to eat and the desire to get rich.

So why didn't you just SAY that you disagree with capitalism?  It would
have saved a lot of time, not to mention the Internet Collective's
bandwidth.

xoxo,
Andy



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



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

Date: 11 Feb 1998 02:29:09 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: SYSTEM command - How do you return data to the browser?
Message-Id: <6br2dl$re1$1@comdyn.comdyn.com.au>

In article <34E08096.5F8D@ptsc.slg.eds.com>,
	Glenn West <westxga@ptsc.slg.eds.com> writes:

> open(FH, "some_pgm.exe|");

Especially when your code is an example, you should be checking the
return value of an open() call.

open(FH, "/path/to/program |") or die "Cannot start program: $!";

You might want to have a glance at the perlipc documentation.
Don't forget to also check the close() return value.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.       | make a better idiot.
NSW, Australia                      | 


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

Date: 11 Feb 1998 02:39:38 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: TOOLS USA '98: 2nd Call for Papers & Registration
Message-Id: <6br31a$re1$3@comdyn.comdyn.com.au>

In article <6bqsnk$igf$1@news.rain.org>,
	"Karen Ouellette" <Karen.Ouellette@eiffel.com> writes:
> Please be so kind as to distribute the attached Call for Papers
> further in your geographical and scientific area.

You just distributed it all over the world. How many more geographical
areas are there that you expect papers from?
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Advertising:  The science of arresting
Commercial Dynamics Pty. Ltd.       | the human intelligence long enough to
NSW, Australia                      | get money from it.


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

Date: 11 Feb 1998 01:39:46 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: Re: Using flock?
Message-Id: <6bqvh2$8if$1@news.ml.com>

Jerry Davis <gedavis3@vt.edu> wrote:
>Well most OS will prevent two operations from writing at the same time but
>they wont prevent this

prevent or not prevent? does the latter part of the sentence
contradict the first part, or I read it wrong? 


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

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

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