[8327] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1944 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 20 20:07:53 1998

Date: Fri, 20 Feb 98 17:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 20 Feb 1998     Volume: 8 Number: 1944

Today's topics:
    Re: 5.004 bug? invisible object dereferencing (William R. Ward)
    Re: 5.004 bug? invisible object dereferencing <zenin@best.com>
        A Few Questions about Form Handling (Katy Jackson)
    Re: A Few Questions about Form Handling <sfarrell+usenet@farrell.org>
        Avoid direct call to perl <rgy@scscompany.com>
    Re: Being Nice 2 Nice Beings [Was: Reading The FAQ's et <dannyman@arh0300.urh.uiuc.edu>
    Re: Canonical absolute file paths; or, removing up (../ <vallon@pearl.fi.bear.com>
    Re: Delete record from fixed-length random access datab (Jonathan Feinberg)
    Re: FAQless Forays (was: Code Example Needed) (Josh Fishman)
    Re: Generic Config-file maintenance (William R. Ward)
        Getting GET/POST requests (Roger Liu)
        HELP! exec doesn't work properly! <lsj@bnl.gov>
        HELP! exec doesn't work properly! <lsj@bnl.gov>
        HELP! exec doesn't work properly! <lsj@bnl.gov>
        How to synchronize multiple writes to a file? jckwong@hotmail.com
    Re: if (-d $filename) in Win32 (Jonathan Feinberg)
        newbie: breaking a line of text into two chunks <joew@xaostools.com>
    Re: newbie: breaking a line of text into two chunks <franzen@pmel.noaa.gov>
    Re: on reading FAQs and gurus answering questions (Greg Bacon)
    Re: on reading FAQs and gurus answering questions (Greg Bacon)
    Re: PERL CGI AUTHENTICATION (Jonathan Feinberg)
    Re: Problems with gnuplot in perl CGI (Jonathan Feinberg)
    Re: Year 2000 Compliance: Lawyers, Liars, and Perl (Kaz Kylheku)
    Re: Year 2000 Compliance: Lawyers, Liars, and Perl (Abigail)
    Re: Year 2000 Compliance: Lawyers, Liars, and Perl (Daniel P. B. Smith)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 20 Feb 1998 14:10:37 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: 5.004 bug? invisible object dereferencing
Message-Id: <waau39u0vxe.fsf@ese.UCSC.EDU>

Curtis Hrischuk <ceh@sce.carleton.ca> writes:
> Yes, references do spring into existence but that has little to do
> with my problem.  In the example, the reference is a scalar value,
> which is having a method called from its symbol table.  Although perl
> is powerful, scalars do not have a symbol table.  This is similar to
> trying to execute a method on an integer.
> 
> The code that works is:
>    print "mytime is " . $rap_time->stringize() . "\n"; # error!!
> 
> The good code should be: 
>    print "mytime is " . $$rap_time->stringize() . "\n"; # note dereference
> 
> >> stringize()'s first argument is going to be a reference of type
> >> AppTime.
> Yes, but to get there requires dereferencing $rap_time from a scalar
> to a package's symbol table to find the method call.

Nope, you are misunderstanding how Perl handles scalars.  The usual
way to call a method is $objref->method(), which does two things:

1. Finds the appropriate method() function depending on which package
   $objref was blessed into
2. Calls that function, prepending $objref as the first argument.

The only time when you would want to do $$objref->method() is if
$objref is a reference to an object reference, something like:
  $ref = new Package::Name;
  $objref = \$ref;
  $$ref->method();

I hope this helps make things more clear for you.

--Bill.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862
 PGP Key 0x2BD331E5; Public key at http://www.bayview.com/~hermit/pubkey.txt


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

Date: 21 Feb 1998 00:37:58 GMT
From: Zenin <zenin@best.com>
Subject: Re: 5.004 bug? invisible object dereferencing
Message-Id: <888021723.709634@thrush.omix.com>

[ posted & mailed ]

Curtis Hrischuk <ceh@sce.carleton.ca> wrote:
: Yes, references do spring into existence but that has little to do
: with my problem.  In the example, the reference is a scalar value,
: which is having a method called from its symbol table.  Although perl
: is powerful, scalars do not have a symbol table.  This is similar to
: trying to execute a method on an integer.

	I think you don't fully understand what bless() does to references,
	and you also seem to be making the incorrect assumption that a Perl
	reference is the same as a C pointer, which it isn't.  Unlike a
	pointer, a Perl reference holds much more then just the memory
	location.  It is not the same as an int, nore is it stored as such.
	Yes, they are stored in scalar values, however scalar values hold
	far more then just an "int" or "string" themselfs.  See man perlguts
	if you really want to know the gorry details, but it isn't needed to
	use or build objects and classes.

: The code that works is:
:    print "mytime is " . $rap_time->stringize() . "\n"; # error!!

	Because it should.  The '->' IS the dereference, kinda...
	This is the correct way to call it.  There is no error here.

: The good code should be: 
:    print "mytime is " . $$rap_time->stringize() . "\n"; # note dereference

	Nope.  Not unless $rap_time is itself a reference to the real
	object (eg, you've got two levels of references.  For this to work,
	you would have to have code like:

	my $foo = new Bar;
	$rap_time = \$foo;
	$$rap_time->stringize();
	## *exactly* the same as:
	${ $rap_time }->stringize();

: Yes, but to get there requires dereferencing $rap_time from a scalar
: to a package's symbol table to find the method call.

	This is where you misunderstand what the bless() function actually
	does.  When you bless a reference, you change it's reference type
	to that of the package it's blessed into.  After that point, if you
	ever call a method off that reference, Perl checks to see if it is
	blessed, if it is it looks into the package it is blessed into for
	the method (inheritance not withstanding), and once it finds it Perl
	calls the method with the object (the blessed reference) inserted
	as the first argument.  You do not have to "help" Perl by manually
	extracting the package name.  That's Perl's job.

	When using method, you can think of the '->' as "dereferencing" your
	method if you like, the same way it's used to dereference "normal"
	values from references.  It's true you can call methods off the
	string package name (eg, "Foo::Bar"->method()), but this isn't the
	normal method of calling them.  Besides, if you really wanted to
	pull the string package name out first, you'd have to call your
	method like this:

	    print "mytime is " . ref($rap_time)->stringize($rap_time) . "\n";

	Blgh, no thank you...  :-)

	Besides, this would still break your code as the first argument to
	your method would now the class and the second would be your
	object.

	Hope this helps!

-- 
-Zenin
 zenin@best.com


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

Date: Fri, 20 Feb 1998 22:01:24 GMT
From: katyjack@mindspring.com (Katy Jackson)
Subject: A Few Questions about Form Handling
Message-Id: <34eef69c.11331179@news>

I'm going through the excellent Perl tutorial
http://www.lightsphere.com/dev/class/

and I've been working through lesson 3, which covers the ever popular
topic of form handling and e-mail. I'd like to tweak the script a
little bit, but I've got a couple of questions before I can do that.

Here's the script I'm working with:

>#!/usr/bin/perl
>
>     print "Content-type:text/html\n\n";
>
>     read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>     @pairs = split(/&/, $buffer);
>     foreach $pair (@pairs)
>     {
>         ($name, $value) = split(/=/, $pair);
>         $value =~ tr/+/ /;
>         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>         $value =~ s/~!/ ~!/g;
>         $FORM{$name} = $value;
>     }
>
>     $mailprog = '/usr/sbin/sendmail';
>
>     # change the email address to your own (so you get the mail and not me) :)
>     $recipient = 'email@server.com';
>
>     # this opens an output stream and pipes it directly to the sendmail
>     # program.
>     open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
>
>     # here we're printing out the header info for the mail message.  The
>     # reply-to can be set to the email address of the sender, assuming you
>     # have actually defined a field in your form called 'email'.
>     print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
>
>     # print out a subject line so you know it's from your form cgi.
>     # The two \n\n's end the header section of the message.  anything
>     # you print after this point will be part of the body of the mail.
>     print MAIL "Subject: Form Data\n\n";
>
>     # here you're just printing out all the variables and values, just like
>     # before in the previous script, only the output is to the mail message
>     # rather than the followup HTML page.
>     foreach $key (keys(%FORM)) {
>       print MAIL "$key = $FORM{$key}\n";
>     }
>
>     # when you finish writing to the mail message, be sure to close the
>     # input stream so it actually gets mailed.
>     close(MAIL);
>
>     # now print something to the HTML page, usually thanking the person
>     # for filling out the form, and giving them a link back to your homepage
>     print <<EndHTML;
>     <h2>Thank You</h2>
>     Thank you for writing.  Your mail has been delivered.<p>
>     Return to the <a href="http://www59.metronet.com/dev/class/">CGI Class</a><p>
>     </body></html>
>     EndHTML

This works great except that when I receive the email the fields are
in seemingly random order. It seems to happen when I store the parsed
values in the associative array %FORM, but I don't know why or what to
do about it. I'd like for the fields to appear in the email in the
order in which they appeared on the form.

I'd also like to specify more than one recipient. Can I do that just
be separating the two email addresses with a comma like this?

$recipient = firstemail@server.com, secemail@server.com

Thanks for looking at this. My apologies if this answer is covered in
the FAQ - I did look at it, I promise.




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

Date: Sat, 21 Feb 1998 00:22:49 GMT
From: stephen farrell <sfarrell+usenet@farrell.org>
Subject: Re: A Few Questions about Form Handling
Message-Id: <87oh01olgm.fsf@phaedrus.uchicago.edu>

katyjack@mindspring.com (Katy Jackson) writes:

> I'm going through the excellent Perl tutorial
> http://www.lightsphere.com/dev/class/
> 
> and I've been working through lesson 3, which covers the ever popular
> topic of form handling and e-mail. I'd like to tweak the script a
> little bit, but I've got a couple of questions before I can do that.
> 
> Here's the script I'm working with:
> 
> >#!/usr/bin/perl
> >
> >     print "Content-type:text/html\n\n";
> >
> >     read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> >     @pairs = split(/&/, $buffer);
> >     foreach $pair (@pairs)
> >     {
> >         ($name, $value) = split(/=/, $pair);
> >         $value =~ tr/+/ /;
> >         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> >         $value =~ s/~!/ ~!/g;
> >         $FORM{$name} = $value;
> >     }
> >
> >     $mailprog = '/usr/sbin/sendmail';
> >
> >     # change the email address to your own (so you get the mail and not me) :)
> >     $recipient = 'email@server.com';
> >
> >     # this opens an output stream and pipes it directly to the sendmail
> >     # program.
> >     open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
> >
> >     # here we're printing out the header info for the mail message.  The
> >     # reply-to can be set to the email address of the sender, assuming you
> >     # have actually defined a field in your form called 'email'.
> >     print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
> >
> >     # print out a subject line so you know it's from your form cgi.
> >     # The two \n\n's end the header section of the message.  anything
> >     # you print after this point will be part of the body of the mail.
> >     print MAIL "Subject: Form Data\n\n";
> >
> >     # here you're just printing out all the variables and values, just like
> >     # before in the previous script, only the output is to the mail message
> >     # rather than the followup HTML page.
> >     foreach $key (keys(%FORM)) {
> >       print MAIL "$key = $FORM{$key}\n";
> >     }
> >
> >     # when you finish writing to the mail message, be sure to close the
> >     # input stream so it actually gets mailed.
> >     close(MAIL);
> >
> >     # now print something to the HTML page, usually thanking the person
> >     # for filling out the form, and giving them a link back to your homepage
> >     print <<EndHTML;
> >     <h2>Thank You</h2>
> >     Thank you for writing.  Your mail has been delivered.<p>
> >     Return to the <a href="http://www59.metronet.com/dev/class/">CGI Class</a><p>
> >     </body></html>
> >     EndHTML
> 
> This works great except that when I receive the email the fields are
> in seemingly random order. It seems to happen when I store the parsed
> values in the associative array %FORM, but I don't know why or what to
> do about it. I'd like for the fields to appear in the email in the
> order in which they appeared on the form.

Ha!  yes, associative arrays do lose any ordering informatoin.  You
can run sort on the output, however:

	foreach $key (sort {$a cmp $b } keys %FORM) { ...

this will sort them alphabetically (well, by ASCII so "Z" comes before
"z",e.g.).  However, it won't necessarily get them in the same order
as on the form.  I"m not even sure if the http standard dictates any
ordering of the cgi strings as it comes back to you.  If it does, then
you could rework that unwebify function to use references that
encode the order.  A bit awkward, and requires learning references.
 ...and I'm not even sure it would work the same for all browsers.  You
could rename the variables so they work out alphabetically, or prefix
with numbers (and perhaps chop thse off before you print them).


one other possibility would be to write a structure that encodes the
desired order information... e.g.,

%order = ( name => 0,
	   whatever => 1,
	   whateverelse => 2 );

and then

foreach ( sort { $order{$a} <=> $order{$b} } keys %FORM) { ...


> 
> I'd also like to specify more than one recipient. Can I do that just
> be separating the two email addresses with a comma like this?
> 
> $recipient = firstemail@server.com, secemail@server.com

this is a mailer issue--man sendmail is the place to look.  But, to
anwer your question: yes (if sendmail under unix).

--sf



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

Date: Fri, 20 Feb 1998 18:38:14 -0500
From: "Robert Yacobucci" <rgy@scscompany.com>
Subject: Avoid direct call to perl
Message-Id: <6cl41m$bhu@ecuador.earthlink.net>

I would like to know if my cgi script is begin called from within my
web-page, or the user has directly typed it in the browser.

I have a cgi script that goes and gets a page and displays it...but I only
want the action to occur if the calls was from within one of my own
web-pages.

I currently check the $ENV{'HTTP_REFERER'}) variable which seems to work.
Is this the proper thing to do?  Is there a better way to do this with perl?

Please email me answer and thank you for your help.

Bob




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

Date: 21 Feb 1998 00:26:22 GMT
From: dannyman <dannyman@arh0300.urh.uiuc.edu>
Subject: Re: Being Nice 2 Nice Beings [Was: Reading The FAQ's etc.: a teacher's perspective...]
Message-Id: <6cl6ve$l34$3@vixen.cso.uiuc.edu>

Bart Lateur <bart.mediamind@tornado.be> wrote:
> twod@not.valid wrote:

>>I wish people would stop trying to rewrite history by changing the
>>expansion of the letter F. It is, and always has been, 'Fucking' -
>>apologies to those offended or shocked by the use of a word that is in most
>>modern dictionaries (of any repute) and could I suggest that they use the
>>alternate 'RTCM' (Read The Copulating Manual) acronym instead.

> Why not create a censored version. Something like

> 	RT*M

YM "RTM" or "RTDM" - HTH ...

-- 
  //Dan   -=-     This message brought to you by djhoward@uiuc.edu    -=-
\\/yori   -=-    Information - http://www.uiuc.edu/ph/www/djhoward/   -=-
aiokomete -=-   Our Honored Symbol deserves an Honorable Retirement


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

Date: 20 Feb 1998 16:55:42 -0500
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: Canonical absolute file paths; or, removing up (../) segments
Message-Id: <x6en2fmlz4x.fsf@pearl.fi.bear.com>

The following is much the same, but here's some more code.  How about a 
general "CanonicalizePath"?

sub CanonicalizePath {
    my $path = join '/', @_;
    my @work = split '/', $path;
    my @out;
    my $is_absolute;

    if (@work && $work[0] eq "") {
        $is_absolute = 1;
        shift @work;
    }

    while (@work) {
        my $seg = shift @work;
	if ($seg eq "." || $seg eq "") {
        } elsif ($seg eq "..") {
            if (@out && $out[-1] ne "..") {
                pop @out;
            } else {
                # Leading "..", or "../..", etc.
                push @out, $seg;
            }
        } else {
            push @out, $seg;
        }
    }

    unshift @out, "" if $is_absolute;
    return join('/', @out);
}

die 1 unless "/a/b/c"         eq CanonicalizePath "/a/b/c";
die 2 unless "/a/b/d/e"       eq CanonicalizePath "/a/b", "d/e";
die 3 unless "/usr/local/bin" eq CanonicalizePath "/usr/local", 
                                         "X11", "../bin";
die 4 unless "/a/b"           eq CanonicalizePath "/a//b";
die 5 unless "/a/d/e"         eq CanonicalizePath "/a/b", "../d", "e";
die 6 unless "../bin"         eq CanonicalizePath "a/../../bin";

local $pwd = "/a/b/c";

sub GetAbsPath {
    local ($path) = @_;
    $path = $pwd . "/" . $path unless $path =~ /^\s*\//;
    return CanonicalizePath $path;
}

die 10 unless "/a/b/c/d"     eq GetAbsPath "d";
die 11 unless "/x"           eq GetAbsPath "/x";
die 12 unless "/a/b/y"       eq GetAbsPath "../y";

print "yea!\n";

Manoj Srivastava <srivasta@datasync.com> writes:

> #! /usr/bin/perl -w
> use strict;
> use diagnostics;
> 
> my $pathsep = '/';
> 
> my $thisdir; chop($thisdir = `pwd`);
> 
> sub get_abs_path {
>   my $pathname = shift;
>   my $retpath = "";
> 
>   $pathname =~ s/\s+//og;
>   return $pathname if $pathname =~ m|^/|o;
>   
>   my @components = split ($pathsep, $thisdir . $pathsep . $pathname);
>   while (@components) {
>     my $segment = pop @components;
>     
>     if    ($segment =~ m/^\.\.$/o)  { pop @components; next; }
>     elsif ($segment =~ m/^\.$/o)    { next; }
>     else {
>       $retpath = $segment . $pathsep . $retpath if $retpath;     
>       $retpath = $segment unless $retpath;
>     }
>   }
>   return $retpath;
> }
> 
> print "pathname = ", &get_abs_path (shift), "\n";
> 
> __END__
> 
> # sample output
> __> perl -w ~/respath.pl /home/srivasta/junk
> pathname = /home/srivasta/junk
> __> perl -w ~/respath.pl ../srivasta/junk
> pathname = /home/srivasta/junk
> __> perl -w ~/respath.pl ./junk
> pathname = /home/srivasta/junk
> __> perl -w ~/respath.pl ./lib/emacs/../X11/app-defaults/Xfm.ad 
> pathname = /home/srivasta/lib/X11/app-defaults/Xfm.ad
> 
> 
> -- 
>  What we do not understand we do not possess. Goethe
> Manoj Srivastava  <srivasta@acm.org> <http://www.datasync.com/%7Esrivasta/>
> Key C7261095 fingerprint = CB D9 F4 12 68 07 E4 05  CC 2D 27 12 1D F5 E8 6E

-- 
-Justin
vallon@bear.com


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

Date: Fri, 20 Feb 1998 17:24:19 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Delete record from fixed-length random access databases
Message-Id: <MPG.f57cc9d189676af98971b@news.concentric.net>

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

Aniz@auctionz.com said...
: However when I want to delete a specify record in a file.
: 1) I want to use seek to move a particular record.
:     seek(AA, 80, 0)

I don't *quite* understand your question, though it sounds like a good match 
for one of the FAQs, "How do I randomly update a binary file?" in perlfaq5.

HTH.
-- 
#!/usr/bin/perl -w --                     Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg         jdf@pobox.com        Sunny Brooklyn, NY


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

Date: Fri, 20 Feb 1998 18:23:45 -0500
From: josh@vortex.nyu.edu (Josh Fishman)
Subject: Re: FAQless Forays (was: Code Example Needed)
Message-Id: <slrn6es47p.vuu.josh@vortex.nyu.edu>

On Thu, 12 Feb 1998 10:58:50 GMT, sean broderick <creepy@!domain.com> wrote:
 [ snip ]
>on the other hand, i could not live without my macintosh, which satisfies
>my primitive needs without requiring me to learn many archaic utilities or
>spend huge amounts of money on windowing software...
>
>(* just don't start with linux, i would not want to use an
>intel-architecture personal computer for *anything* *)

Linux-PPC?

 - Josh

(PS: :-) )

-- 
   O<      ( (      [ Josh Fishman      GPL DNA NOW! ]
 _NH >=O    ) )     [  <mailto:jmf9936@is4.nyu.edu>  ]
<_>-<_   + :::::-.  [ Linux:                         ]
 HCl<O>     :::`-'  [  hex, bugs, flock() and poll() ]


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

Date: 20 Feb 1998 14:33:18 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: Generic Config-file maintenance
Message-Id: <waara4x29g0.fsf@ese.UCSC.EDU>

tgdcuro1@swissptt.ch (Roy Culley) writes:
> Tom Christiansen <tchrist@mox.perl.com> writes:
>> Just make the config file straight perl!  Anything else is dubious at best.
> 
> Thats ok for perl hackers but what if the config file is maintained
> by non-programmers?

And also, the users might not be trusted to write Perl.  The scripts,
modules, etc. may be SetUID or CGI scripts that have privileges that
the users don't have, and by inserting special code into the config
file the users can violate the desired security restrictions....

--Bill.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862
 PGP Key 0x2BD331E5; Public key at http://www.bayview.com/~hermit/pubkey.txt


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

Date: 20 Feb 1998 17:41:19 -0500
From: rwliu@romulus.rutgers.edu (Roger Liu)
Subject: Getting GET/POST requests
Message-Id: <6cl0qf$8tu$1@romulus.rutgers.edu>
Keywords: POST,GET,server,PERL

Hi,

I'm writing a mini-server for class, (right now with no network connectivity)
But I'm having trouble understanding some things...basically I have a form
set up to send in a POST request and then write the form info to a file.
I want to grab the information that's passed from the browser, namely 
the GET/POST url HTTP/1.0 stuff...isn't this supposed to be sent by the client(browser?)

Reading in from STDIN into a buffer just gets the form info, not the actual
HTTP request. I tried writing the $ENV{'REQUEST_METHOD'} to get either GET
or POST, but that didn't seem to work. Am I totally off in terms of concept?

If anyone could give me some suggestions, I would appreciate it...

rwliu@remus.rutgers.edu



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

Date: Thu, 19 Feb 1998 14:00:11 -0500
From: "Lance" <lsj@bnl.gov>
Subject: HELP! exec doesn't work properly!
Message-Id: <6chva0$li7$2@sun20.ccd.bnl.gov>

Hi,

    I have the following lines in a perl script on a HP-UX:

    open(jj,">junk") || die "Couldn't open junk: $!\n";
    print jj <<EOF;                # line A
1
1
0
4
0
5
0
0
EOF

exec "trans.x < junk";        # line B

Note: "trans.x" is a Fortran executable file which uses "junk" as a
redirected input file

But it just doesn't work! line A does generate the file "junk", but line B
not only doesn't recognize "junk" but also makes it null.

If I comment line B and run the rest.  It generates  "junk". And then I
uncomment line B and comment the rest of it. (so "junk" already exits)  and
run it.   Line B works!  I don't understand why they can't work together.

Any advice will be greatly appreciated!


--
Regards,
Lance
lsjATbnl.gov




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

Date: Thu, 19 Feb 1998 14:18:19 -0500
From: "Lance" <lsj@bnl.gov>
Subject: HELP! exec doesn't work properly!
Message-Id: <6ci0c1$lv6$1@sun20.ccd.bnl.gov>

Hi,

    I have the following lines in a perl script on a HP-UX:

    open(jj,">junk") || die "Couldn't open junk: $!\n";
    print jj <<EOF;                # line A
1
1
0
4
0
5
0
0
EOF
exec "trans.x < junk";        # line B

Note: "trans.x" is a Fortran executable file which uses "junk" as a
redirected input file
But it just doesn't work! line A does generate the file "junk", but line B
not only doesn't recognize "junk" but also makes it null.

If I comment line B and run the rest.  It generates  "junk". And then I
uncomment line B and comment the rest of it. (so "junk" already exits)  and
run it.   Line B works!  I don't understand why they can't work together.

Since I'm new in Perl Programming, this could be a dumb question.
Any advice will be greatly appreciated!


--
Regards,
Lance
lsjATbnl.gov




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

Date: Thu, 19 Feb 1998 14:09:35 -0500
From: "Lance" <lsj@bnl.gov>
Subject: HELP! exec doesn't work properly!
Message-Id: <6chvrk$loa$2@sun20.ccd.bnl.gov>

Hi,

    I have the following lines in a perl script on a HP-UX:

    open(jj,">junk") || die "Couldn't open junk: $!\n";
    print jj <<EOF;                # line A
1
1
0
4
0
5
0
0
EOF
exec "trans.x < junk";        # line B

Note: "trans.x" is a Fortran executable file which uses "junk" as a
redirected input file

But it just doesn't work! line A does generate the file "junk", but line B
not only doesn't recognize "junk" but also makes it null.

If I comment line B and run the rest.  It generates  "junk". And then I
uncomment line B and comment the rest of it. (so "junk" already exits)  and
run it.   Line B works!  I don't understand why they can't work together.

Any advice will be greatly appreciated!


--
Regards,
Lance
lsjATbnl.gov




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

Date: Fri, 20 Feb 1998 16:36:39 -0600
From: jckwong@hotmail.com
Subject: How to synchronize multiple writes to a file?
Message-Id: <6cl0hn$vu3$1@nnrp1.dejanews.com>

Hi,

Can someone give me an example of how to synchronize multiple writes from many
instances of a perl script, to a file?  I know there's a command called
"select", but if I do:

($nfound, $timeleft) = select(undef, $win, undef, $timeout
if ($nfound) {
       print FILEHANDLE $stuff; ## What if $win is not ready anymore
                                ## two statements later??
}

I tried playing with flock instead, but wasn't successful either.

Anyone who have any examples?  Helps are greatly appreciated.

I tried the FAQ but didn't find what I want.

John

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Fri, 20 Feb 1998 17:10:46 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: if (-d $filename) in Win32
Message-Id: <MPG.f57c96caa04f256989719@news.concentric.net>

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

perl.user@sndk.se said...
: Why isn't the following ok in Win32? Is -d only working in unix perl?
: I want to scan the whole of d:\ for perl-files (extension "pl").

: @dirs = 
: (
:   'd:\\'
: );

Oof.  Get rid of those backslashes; Perl treats / as the directory separator 
on all platforms.

 @dirs = ( 'd:/' );

Also, here's a handy idiom to read a directory without . and .. :
 
 @files = grep {!m#^\.\.?$#} readdir DIRHANDLE;

Try using regular slashes, and see if your troubles dissolve.

-- 
#!/usr/bin/perl -w --                     Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg         jdf@pobox.com        Sunny Brooklyn, NY


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

Date: Fri, 20 Feb 1998 15:59:12 -0800
From: Joe Wahrhaftig <joew@xaostools.com>
Subject: newbie: breaking a line of text into two chunks
Message-Id: <34EE18D0.1559581B@xaostools.com>


--------------AEFF896B91F8332F794DCC6D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

  Yes I expect to get flamed for this one:

I've got a database where the entries are as follows


            item1_name        "comment string for item 1"
            item2_name        "comment string for item 2"

                                            ... etc.

I want to take the item_name and "comment about item n" and store them
in different variables. I tried reading these two entries per line with
a split as shown below:

 ($Item_Name, $Comment_String) = split(/ /, $_);

This worked fine for $Item_Name. $Comment_String however, now only holds
one word. Does anyone out there have a suggestion for putting the entire
comment string
(plus the quotes around it) in into $Comment_String?

Thanks for your help.



--------------AEFF896B91F8332F794DCC6D
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
<TT>&nbsp; Yes I expect to get flamed for this one:</TT><TT></TT>

<P><TT>I've got a database where the entries are as follows</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
item1_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "comment string for
item 1"</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
item2_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "comment string for
item 2"</TT><TT></TT>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 ... etc.

<P><TT>I want to take the item_name and "comment about item n" and store
them in different variables. I tried reading these two entries per line
with a split as shown below:</TT><TT></TT>

<P><TT>&nbsp;($Item_Name, $Comment_String) = split(/ /, $_);</TT><TT></TT>

<P><TT>This worked fine for $Item_Name. $Comment_String however, now only
holds one word. Does anyone out there have a suggestion for putting the
entire comment string</TT>
<BR><TT>(plus the quotes around it) in into $Comment_String?</TT><TT></TT>

<P><TT>Thanks for your help.</TT>
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;</HTML>

--------------AEFF896B91F8332F794DCC6D--



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

Date: Fri, 20 Feb 1998 16:49:20 -0800
From: Nathan Franzen <franzen@pmel.noaa.gov>
Subject: Re: newbie: breaking a line of text into two chunks
Message-Id: <Pine.SOL.3.96.980220164036.1705C-100000@corona.pmel.noaa.gov>


On Fri, 20 Feb 1998, Joe Wahrhaftig wrote:

>   Yes I expect to get flamed for this one:

Maybe, your answer is in the documentation for "split".  But no flames
from a fellow neophyte like me.
 
> I want to take the item_name and "comment about item n" and store them
> in different variables. I tried reading these two entries per line with
> a split as shown below:
> 
>  ($Item_Name, $Comment_String) = split(/ /, $_); 

I think you want to split the variable into only two fields, as:
  perl -e '$x=q{item1_name "comment here"};@a=split " ",$x,2;print"$a[1]\n"'
which returns:
 "comment here"

Hope this helps,

-Nathan




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

Date: 20 Feb 1998 22:42:47 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: on reading FAQs and gurus answering questions
Message-Id: <6cl0t7$b4o$1@info.uah.edu>

In article <6cbe3l$8mn$1@news.orst.edu>,
	stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
: So they get driven into the moderated group and you win. Or are you
: worried that the smart lazy people aren't going to use a group where
: they have to hand their email addresses to spammers on a silver
: platter?

Give it a rest, man!  Look at all the smart (and probab^H^H^H^Hperhaps
lazy) people who don't munge their address in clpm alone!

It is the slow witted PoBs who have no clue what the Internet or even
Usenet is all about who would break what has always worked and avoid
a clearly better forum for the false sense of security that their
selfishness gives them.

If the terms of the charter of the new group would keep the mungers
and other ne'er-do-wells out, then I would call that a feature. :-)

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 20 Feb 1998 22:45:42 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: on reading FAQs and gurus answering questions
Message-Id: <6cl12m$b4o$2@info.uah.edu>

In article <6c9ncc$dle$1@news.orst.edu>,
	stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
> In article <34E655C3.986593A7@5sigma.com>,
> Joseph N. Hall <joseph@5sigma.com> wrote:
>>Since spending some time in IRC (after all these years not bothering) 
>>I have realized what USENET needs is a kick button.  p5p could use
>>one too.  :-)
> 
> It's called a killfile. 

But it's much more entertaining and satisfying to watch an annoying
or trouble making person be publicly removed from the forum and
furthering  the Greater Good.

ops? :-)

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Fri, 20 Feb 1998 17:31:57 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: PERL CGI AUTHENTICATION
Message-Id: <MPG.f57ce6487920dc198971c@news.concentric.net>

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

ernie@law.harvard.edu said...
: We've written some CGI scripts and plopped them in a sub-dir of
: cgi-bin.
: These cgi's are to be restricted to a group of about 12 individuals at
: the site where we're working.  I would like the users to be prompted
: for
: authentication every time a cgi is called (without having to exit
: netscape).

This newsgroup has *nothing* *whatsoever* to do with with any of that stuff.  
This newsgroup is about the Perl programming language

[This list courtesy of Tom Christiansen.]

    CGI FAQ
        http://www.webthing.com/page.cgi/cgifaq

    The CGI Newsgroup (NOT THIS ONE):
        comp.infosystems.www.authoring.cgi

    CPAN's Web-related modules in Perl:
http://www.perl.com/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/

    The Idiot's Guide to solving Perl/CGI problems 
        http://www.perl.com/perl/faq/idiots-guide.html

    Perl FAQs
        http://www.perl.com/CPAN/doc/FAQs/

    Perl Manpages (old)
        http://www.perl.com/CPAN/doc/manual/html/

    WWW Security FAQ
        www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html

    Web FAQ
        http://www.boutell.com/faq/

    HTTP Spec
        http://www.w3.org/pub/WWW/Protocols/HTTP/

    HTML Spec
        http://www.w3.org/pub/WWW/MarkUp/

    CGI Spec
        http://hoohoo.ncsa.uiuc.edu/cgi/interface.html

-- 
#!/usr/bin/perl -w --                     Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg         jdf@pobox.com        Sunny Brooklyn, NY


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

Date: Fri, 20 Feb 1998 17:21:11 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Problems with gnuplot in perl CGI
Message-Id: <MPG.f57cbdfb94066fb98971a@news.concentric.net>

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

wityshyn@telusplanet.net said... 
: open(GP,"|\\gnuplot\\gnuplot.exe");
: print GP "set terminal gif\n";
: print GP "plot x**3\n";
: close GP;

Hmm.  It looks to me like the output from gnuplot.exe is going into the bit 
bucket.  You're going to have to do some trickery with open2 (which may or may 
not work on a Win32 box, I don't know).  See perlipc.  Or, perhaps you can 

  open(GP, "/gnuplot/gnuplot.exe -some -fancy -options -here |") or die "$!";

where those options thell gnuplot to take its commands from a file or from the 
command line itself.  I don't know gnuplot.  Then you'd

  print STDOUT <GP>;

and be done with it.

As an aside, you're not checking the return value of the open call, and you 
really ought to use foward slashes for directory separators (even on Win32).

-- 
#!/usr/bin/perl -w --                     Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg         jdf@pobox.com        Sunny Brooklyn, NY


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

Date: 20 Feb 1998 22:42:45 GMT
From: bill@cafe.net (Kaz Kylheku)
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <6cl0t5$sm6$1@brie.direct.ca>

In article <34EDBD17.16475955@medit3d.com>,
Colin Dooley  <colin@medit3d.com> wrote:
>Steve Dover wrote:
>> 
>> Time marches on, but by design, a given date or timestamp datam
>> will only be allocated so many bits.  At some point in time,
>> more bits will need to be allocated.  There's no way around it.
>
>In a billion years the Sun will explode and you won't need to
>worry about it any more. This suggests that a 64 bit time_t
>ought to be enough...

That assumes that by then we will not have figured out a way to
survive the death of the Sun.

Ye of little faith.


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

Date: 20 Feb 1998 23:01:31 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <6cl20b$hd3$5@client2.news.psi.net>

Colin Dooley (colin@medit3d.com) wrote on 1634 September 1993 in
<URL: news:34EDBD17.16475955@medit3d.com>:
++ Steve Dover wrote:
++ > 
++ > Time marches on, but by design, a given date or timestamp datam
++ > will only be allocated so many bits.  At some point in time,
++ > more bits will need to be allocated.  There's no way around it.
++ 
++ In a billion years the Sun will explode and you won't need to
++ worry about it any more. This suggests that a 64 bit time_t
++ ought to be enough...


We already have machines outside of the solar system. What makes
you think we won't have another one in the next billion years?



Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


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

Date: Sat, 21 Feb 1998 00:16:05 GMT
From: dpbsmith@world.std.com (Daniel P. B. Smith)
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <EopCqt.J75@world.std.com>

In article <34EDBD17.16475955@medit3d.com>,
Colin Dooley  <colin@medit3d.com> wrote:
>Steve Dover wrote:
>> 
>> Time marches on, but by design, a given date or timestamp datam
>> will only be allocated so many bits.  At some point in time,
>> more bits will need to be allocated.  There's no way around it.
>
>In a billion years the Sun will explode and you won't need to
>worry about it any more. This suggests that a 64 bit time_t
>ought to be enough...

How can you tell?  When I was in junior high school, the continents didn't
drift.  I don't mean that scientists didn't KNOW they drifted.  I mean
that scientists DID know that they DIDN'T drift.  Continental drift had
been a cockamamie theory put forward by a few geologists in the 1930's and
it had been disproved, debunked.  It didn't happen.

Sometime between the fifties and the eighties, the continents cut loose
from their mooring and began to drift.

And I've lost track of what the Universe does--we've gone through so many
cycles of it's-continuous-creation, no-it's-a-big-bang,
no-it-explodes-then-collapses, does to, does not, 'tis to, 'tis not...

No, I wouldn't want to gamble on 64 bits being enough.  

(As for expecting to live that long: no, dammit, I don't.  And it's very 
annoying, because some scientists just think they found out the basic
clue to cell aging--the DNA gradually forms endless loops or something.  I
can just see it: with MY luck, the secret of immortality will be
discovered a decade or so after I die.  It's enough to make one pout.)

-- 
Daniel P. B. Smith
dpbsmith@world.std.com


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

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

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