[12423] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6023 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 16 18:07:13 1999

Date: Wed, 16 Jun 99 15:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 16 Jun 1999     Volume: 8 Number: 6023

Today's topics:
    Re: a thread on threads (Tramm Hudson)
    Re: a thread on threads (Cameron Laird)
        concatenate lines in a group of files <mej014@my-deja.com>
    Re: cookies <upsetter@ziplink.net>
    Re: cookies <cassell@mail.cor.epa.gov>
    Re: creating a chat room <rootbeer@redcat.com>
    Re: creating a chat room (Greg Bacon)
    Re: ENV Question (Kenneth Herron)
    Re: forceing only post methods with perl CGI module <rootbeer@redcat.com>
    Re: Fun with STDERR... (Tad McClellan)
        How can I 'edit' a datafile? (AJ)
    Re: How can I 'edit' a datafile? (Greg Bacon)
        How to continuosly communicate with serial port?? <seongbae@students.uiuc.edu>
        How To Do EBCDIC Transfer using PERL <krahman@uswest.com>
    Re: How To Do EBCDIC Transfer using PERL (Greg Bacon)
    Re: How To Do EBCDIC Transfer using PERL vcuya@mindspring.com
    Re: how2 find first occurence of... <rootbeer@redcat.com>
        informix www dbi problem todd_downing@my-deja.com
    Re: Is it better perl than awk ? (Michael Mauch)
        LD_LIBRARY_PATH setting within the perl program <myparu@usa.net>
    Re: Makefile.PL when you're not the admin <burton@lucent.com>
    Re: Makefile.PL when you're not the admin <rootbeer@redcat.com>
    Re: memory question <aqumsieh@matrox.com>
    Re: my and interpolation? <cassell@mail.cor.epa.gov>
    Re: newbie learning "my" declarations (Lee)
    Re: newbie learning "my" declarations (Tramm Hudson)
        newbie questions re conditional operators (Rory C-L)
    Re: newbie questions re conditional operators <upsetter@ziplink.net>
    Re: newbie questions re conditional operators <rootbeer@redcat.com>
    Re: pattern matching question (Greg Bacon)
    Re: pattern matching question <cassell@mail.cor.epa.gov>
    Re: Perl print to stdout not functioning <rootbeer@redcat.com>
    Re: sending to html page... <jbowers@bsat.com>
    Re: sending to html page... <rootbeer@redcat.com>
    Re: sending to html page... <upsetter@ziplink.net>
    Re: sending to html page... <jbowers@bsat.com>
    Re: win32 perl problems <cassell@mail.cor.epa.gov>
    Re: Win32::NetAdmin <cassell@mail.cor.epa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 16 Jun 1999 15:00:31 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: a thread on threads
Message-Id: <7k939f$5uf@llama.swcp.com>
Keywords: scheme, perl, state machine, closure, continuation

[posted and cc'd to cited author]

Uri Guttman  <uri@sysarch.com> wrote:
> actually it sounds more like co-routines to me. since the ordering is
> sequential, why have the subs sleep? why not have them keep a simple
> state and return to the main loop. when they are rescheduled, they just
> continue from the saved state.

That sure sounds like a continuation...  Wouldn't it be nice if we
had true call-with-current-continuation ability rather than having
to build explicit state machines with closures to deal with such
issues?  Of course, the proper answer to my rhetorical question is:

	"If you want scheme, you know where to find it."

> in fact you
> could do all of this with a single state machine which is easy to
> implement with refs to subs and hash tables. just break up all your subs
> so that where you would call sleep, store the next state (a code ref) so
> that it can return there when scheduled. much easier to write and debug
> than threads or forks.

This is a great programming tool that sees limited application since
the "popular" languages for teaching do not support closures or
first class functions.  It is trivial to tie up all of the state into
a closure that behaves like a state machine.  The only real issue is
that since all of the functions are now anonymous closures rather than
"real" subroutines things like caller and die report unhelpful messages
like:

	main::__ANON__() called at (eval 5) line 2

I've used the state machine technique for CDDB lookups so that my
Tk application doesn't hang for a few minutes while the jukebox
retrieves the table of contents and then contacts the server for
the CDDB information.

Full code was posted back in May:

	http://www.deja.com/getdoc.xp?AN=475045630&fmt=text

Grr -- as I reread my code I realize that there are several places
that I could clean things up.  My home copy of my module has
the fixes to avoid passing variables around since everything is
bound lexically in the closure state machine.

Continuations would have made me happier, but this is a fine way
to get around it.  Perhaps with a little more work I could write
a real tool that would construct such state machines automatically.

Does anyone else write scheme- or functional-style code in Perl?

Tramm
-- 
  o   hudson@swcp.com                 tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.266.59.96   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

Date: 16 Jun 1999 16:39:50 -0500
From: claird@Starbase.NeoSoft.COM (Cameron Laird)
Subject: Re: a thread on threads
Message-Id: <7k95j6$sb8$1@Starbase.NeoSoft.COM>
Keywords: scheme, perl, state machine, closure, continuation

In article <7k939f$5uf@llama.swcp.com>, Tramm Hudson <hudson@swcp.com> wrote:
>[posted and cc'd to cited author]
			.
		[co-routines]
			.
			.
>That sure sounds like a continuation...  Wouldn't it be nice if we
>had true call-with-current-continuation ability rather than having
>to build explicit state machines with closures to deal with such
>issues?  Of course, the proper answer to my rhetorical question is:
>
>	"If you want scheme, you know where to find it."
			.
			.
			.
>Continuations would have made me happier, but this is a fine way
>to get around it.  Perhaps with a little more work I could write
>a real tool that would construct such state machines automatically.
The original questioner indicated that
one of his requirements is to expose
connections so end-users can write
little computations to be performed at
the bottom of his simulations.  Must
those be parseable as Perl?  More to
the point, should the whole project be
re-done in a language that explicitly
expresses continuations?
>
>Does anyone else write scheme- or functional-style code in Perl?
			.
			.
			.
-- 

Cameron Laird           http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com      +1 281 996 8546 FAX


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

Date: Wed, 16 Jun 1999 20:49:19 GMT
From: Maury <mej014@my-deja.com>
Subject: concatenate lines in a group of files
Message-Id: <7k92kb$vi0$1@nnrp1.deja.com>

I wrote a script which takes a group of text files as input and
concatenates lines in each file if the first character in the line is a
'+', then writes the altered files back out.   In other words, the file:

Now is the time
+ for all good men
+ to come to
+ the aid of their country.
Four score
+ and seven years ago.
asdfsadf
dfksfdkjfdsa

becomes:

Now is the time for all good men to come to  the aid of their country.
Four score and seven years ago.
asdfsadf
dfksfdkjfdsa



I couldn't escape the feeling while I was writing the script that there
was an elegant solution, perhaps even a succinct one-line hack, but,
alas, the muse would not cooperate.  I tried using edit-in-place a-la
Learning Perl using $^I and a regex like s/\n\+/\n/s but couldn't figure
how to edit more than one line at a time with that method.  Following is
what I came up with.  I know someone has a beautiful solution, if you do
please let me know or point me in the direction of the correct perldoc.
Thanks!,

------
#!/usr/bin/perl -w

    while ( defined ( $infile = shift(@ARGV))) {
        open(INFILE, "$infile") || die "Can't open $infile: $!";

        open(OUTFILE, ">$infile.out") || die "Can't open $infile.out:
$!";

        $new_line = "";
        while ( defined( $line = <INFILE>)) {
            chomp($line);
            if ( $line !~ /^\+/ ) {
                print OUTFILE "$new_line\n" unless $new_line eq "";
                $new_line = $line;
            } else {
                $line =~ s/\+//;
                $new_line .= $line;
            }

        } #while

        print OUTFILE "$new_line\n";

        close(INFILE);
        close(OUTFILE);
    } #while
--
Maury Jarrell
Koch Petroleum Group
"Mine, not theirs"


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 16 Jun 1999 21:26:25 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: cookies
Message-Id: <5EU93.120$7X1.27948@news.shore.net>

Leonid Goltser <leonid76@erols.com> wrote:
: Where can I find some kind of tutoring to make cookies with perl?

print "Set-cookie: <cookie values here>\n";

--Art


-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Wed, 16 Jun 1999 14:33:57 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: cookies
Message-Id: <37681845.B5AD004E@mail.cor.epa.gov>

Leonid Goltser wrote:
> 
> Where can I find some kind of tutoring to make cookies with perl?

I think you'll find the examples in the docs for CGI.pm are
a good start.  If you want more help than that, then you may
want to buy a copy of Lincoln Stein's book.  You can find out
more about it at:
http://www.perl.com/perl/critiques/index.html

HTH, 
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 16 Jun 1999 14:08:32 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: creating a chat room
Message-Id: <Pine.GSO.4.02A.9906161407290.26850-100000@user1.teleport.com>

On Wed, 16 Jun 1999 dhulnick@my-deja.com wrote:

> I would like to create a question and answer forum chatroom, 

> how should i go about doing this?

It sounds as if you may want to write one or more programs for the CGI
programming environment. Check the docs, FAQs, and newsgroups about CGI
programming. Cheers!

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



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

Date: 16 Jun 1999 21:10:09 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: creating a chat room
Message-Id: <7k93rh$nqs$2@info2.uah.edu>

In article <7k8rrn$sm3$1@nnrp1.deja.com>,
	dhulnick@my-deja.com writes:
: I would like to create a question and answer forum chatroom, where the
: user sends the question, then a moderator receives it, checks for
: appropriateness and then sends it on the the person who answers it who
: then posts the answers up -- this will be a live sort of conference --

I hope you won't be one of these moderators after your poor display of
determination of appropriateness.  What's your Perl question?

Greg
-- 
Nothing inspires forgiveness quite like revenge. 
    -- Dogbert


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

Date: 16 Jun 1999 21:07:55 GMT
From: kherron@sgum.mci.com (Kenneth Herron)
Subject: Re: ENV Question
Message-Id: <7k93nb$2i07@news2.newsguy.com>

On solaris at least, the runtime dynamic linker only reads
LD_LIBRARY_PATH once, the first time it's used.  The perl interpreter
is normally dynamically linked, so the dynamic linker initializes
itself long before your script even starts running and changes the
variable.

We have two perl packages in use here, one based on 5.004_03 and one on
5.005_02. The latter has a later version of DBI and DBD::Oracle than the
former.  With 5.004_03, you can change LD_LIBRARY_PATH before using
DBD::Oracle and it'll work, but not with 5.005_02.  Presumably,
DBD::Oracle used to start a separate sub-process to talk to oracle, and
now it doesn't.  Annoying, ain't it?
-- 
Kenneth Herron -- kherron@sgum.mci.com
"Subversion has always been our best tactic...It leaves the competition
confused, and they don't know what to shoot at anymore."
    -- John Ludwig, Vice president, Microsoft


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

Date: Wed, 16 Jun 1999 14:38:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: forceing only post methods with perl CGI module
Message-Id: <Pine.GSO.4.02A.9906161436140.26850-100000@user1.teleport.com>

On Wed, 16 Jun 1999, Andrew S Gianni wrote:

> Subject: forceing only post methods with perl CGI module
> 
> Is there anyway to do this? I'd like to be able to protect some scripts
> from people passing whatever arguments to them they want. Is there a
> pragma in this module I can use?

It may be that you're trying to tell a browser what values to permit in
certain blanks. If that's it, check the docs, FAQs, and newsgroups about
browsers.

Or maybe you're simply wanting to validate data. The Perl FAQ talks about
that.

Good luck with it!

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



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

Date: Wed, 16 Jun 1999 12:28:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Fun with STDERR...
Message-Id: <9bj8k7.b9h.ln@magna.metronet.com>

Mitch (portboy@home.com) wrote:

[snip wants to capture STDERR]

: Here is one of my many attempts:

:         my $output;
:         $output = open(IFCONFIG, "/sbin/ifconfig $parm 2>&1
: 1>/dev/null");


   That is pretty darn close...


: So, how do I grab the stderr output, and not have it echo'd to the
: user?  


   Perl FAQ, part 8:

      "How can I capture STDERR from an external command?"


: All methods tried so far have failed.


   You should update your methods so that the *first place* that
   you look when having a Perl problem is in the docs that
   came with your perl...


: Thanks in advance,

   Uh huh.



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


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

Date: Wed, 16 Jun 1999 21:02:53 GMT
From: jhawk39@idt.net (AJ)
Subject: How can I 'edit' a datafile?
Message-Id: <37680c79.17411156@news.idt.net>

I have no problem appending to a file or even 'writing over' a file
with data from a form.

Here's my problem. I can't find a way to change specific lines or
elements in that file.

I can set the file up to in any shape....delimited with colons,
pipes...doesn't matter to me.

Let's say the datafile looks like this:
001|Client 1| Bob
002|Client 2| Steve
003|Client 3| Frank
 ...
050|Client 50|Gary

basically, 
client #|Company name| contact name
>From a form, I would like to be able to replace one of those lines
with other information. In other words, I want the script to take data
from the form (using those 3 elements)...find the line in the datafile
and replace it with the new information.

I simply cannot figure out a way to do this. 

I've tried opening the file until it comes to the line I want to
change....writing that array to a second file....then writing the form
information in. Then going back to the first file and reading
everything that followed the line I was changing into an array....and
then writing that to the 'second file'. It didn't work, and I decided
the God of Perl hated me.

Any general suggestions on ways to go about this? I'm not looking for
code....unless there's some easy, short code that  will open and
change a specific line of a file (without changing it's order) that I
have not been able to discover.

Thanks for any help,
John


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

Date: 16 Jun 1999 21:15:44 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How can I 'edit' a datafile?
Message-Id: <7k9460$nqs$4@info2.uah.edu>

In article <37680c79.17411156@news.idt.net>,
	jhawk39@idt.net (AJ) writes:
: I can set the file up to in any shape....delimited with colons,
: pipes...doesn't matter to me.
: 
: Let's say the datafile looks like this:
: 001|Client 1| Bob
: 002|Client 2| Steve
: 003|Client 3| Frank
: ...
: 050|Client 50|Gary

Those are pipe separated records.

: From a form, I would like to be able to replace one of those lines
: with other information. In other words, I want the script to take data
: from the form (using those 3 elements)...find the line in the datafile
: and replace it with the new information.
: 
: I simply cannot figure out a way to do this. 

No problem.  It's in the FAQ.  Did you bother to check?

Greg
-- 
Eye of newt, spleen of censor...


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

Date: Wed, 16 Jun 1999 16:06:16 -0500
From: seong joon bae <seongbae@students.uiuc.edu>
Subject: How to continuosly communicate with serial port??
Message-Id: <Pine.GSO.4.10.9906161553580.4847-100000@ux9.cso.uiuc.edu>


Hello,
I finally figured out how to communicate with serial port.
But now, I run into another problem.
When I give a command to this device that's connected to the serial port,
I get a response.
But when I try to give another command after getting the first response,
I don't get anything.
my script is like this:

open (filehandler)

use FileHandle;
STDOUT->autoflush(1);

give command1
get response1
print response1

give command2
get response2
print response2

close (filehandler)

When I run this, I get response1 but not response2.
Does anyone have any idea..?
Thank you.





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

Date: Wed, 16 Jun 1999 15:07:46 -0600
From: Kalilur Rahman <krahman@uswest.com>
Subject: How To Do EBCDIC Transfer using PERL
Message-Id: <37681222.C415FA26@uswest.com>

Hi

 I Wanted to know whether are there any possibility of transferring
EBCDIC Data using PERL? I guess(If I am not mistaken) Net::FTP forces
ASCII Transfer by default. What needs to be done for EBCDIC File
Transfer?? Any help in this aspect is highly appreciated.

Thanks
Kalil



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

Date: 16 Jun 1999 21:14:30 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How To Do EBCDIC Transfer using PERL
Message-Id: <7k943m$nqs$3@info2.uah.edu>

In article <37681222.C415FA26@uswest.com>,
	Kalilur Rahman <krahman@uswest.com> writes:
:  I Wanted to know whether are there any possibility of transferring
: EBCDIC Data using PERL? I guess(If I am not mistaken) Net::FTP forces
: ASCII Transfer by default. What needs to be done for EBCDIC File
: Transfer?? Any help in this aspect is highly appreciated.

I know it sounds like a crazy idea, but did you bother to search the
Net::FTP documentation for EBCDIC?

Greg
-- 
If a tree falls in the forest and nobody hears it, is Bambi squashed beneath
it any less dead? 
    -- Mason Capwell


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

Date: 16 Jun 1999 21:28:24 GMT
From: vcuya@mindspring.com
Subject: Re: How To Do EBCDIC Transfer using PERL
Message-Id: <7k94to$45f$1@nntp1.atl.mindspring.net>

Kalil,

you can use Convert::EBCDIC to do it. You can download it from CPAN.

Good Luck


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

Date: Wed, 16 Jun 1999 14:15:56 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: how2 find first occurence of...
Message-Id: <Pine.GSO.4.02A.9906161415210.26850-100000@user1.teleport.com>

On Wed, 16 Jun 1999, Marshall V Pierce wrote:

> there must be a more efficient way to code this?

I think you wanted 'last'. Cheers!

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



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

Date: Wed, 16 Jun 1999 20:36:31 GMT
From: todd_downing@my-deja.com
Subject: informix www dbi problem
Message-Id: <7k91se$v7n$1@nnrp1.deja.com>

accessing informix on redhat 5.2 from perl dbi using the
command line works fine.  however, when calling from html
page, i get the following log message:

install_driver(Informix) failed: Can't load
'/usr/lib/perl5/site_perl/i386-linux
/auto/DBD/Informix/Informix.so' for module DBD::Informix: libifsql.so:
cannot op
en shared object file: No such file or directory at
/usr/lib/perl5/i386-linux/5.
00404/DynaLoader.pm line 168.

this happens at the $dbh = DBI-connect('DBI:Informix:dbname'); line in
my script.

any help is greatly appreciated.

todd


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 16 Jun 1999 22:12:11 +0200
From: michael.mauch@gmx.de (Michael Mauch)
Subject: Re: Is it better perl than awk ?
Message-Id: <re09k7.3b3.ln@elmicha.333200002251-0001.dialin.t-online.de>

Uri Guttman <uri@sysarch.com> wrote:

> awk in some ways is not a regular programming language while perl
> is. awk has an fixed implied loop over all the lines of the input and it
> has great difficulty breaking out of that mode.

I can't see that great difficulty: you having no standalone patterns and 
doing everything in the BEGIN statement and functions will suffice.

> it has limitations on
> the size of the data it can handle (line lengths) and has a very short
> set of builtin operations and functions.

GNU awk doesn't have a maximum line length, only the awks that come with 
some OSes do.

> perl can emulate the awk loop
> (-n option) but it is a true general purpose language. as such
> perl is much bigger and it has a massive public library of code and goes
> many places awk never dreams about.

That's surely true, but on the other hand, you have to install/carry
along all those libraries. Awk is just one small binary, whereas Perl has
lots of libraries accompanying it.

Regards...
		Michael


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

Date: Wed, 16 Jun 1999 17:02:40 -0400
From: murali <myparu@usa.net>
Subject: LD_LIBRARY_PATH setting within the perl program
Message-Id: <376810F0.106ED28E@usa.net>

Hello,
I am trying to use Sybase::DBlib from a script. it works fine when I run
it, gets data and shows, but when I run it as a cgi, it complains abt
unable to load some library. I added /opt/sybase/lib to the
LD_LIBRARY_PATH in the %ENV from the program but that didnt work.  what
else can I do?
tia,
murali



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

Date: Wed, 16 Jun 1999 16:08:42 -0500
From: Burton Kent <burton@lucent.com>
To: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Makefile.PL when you're not the admin
Message-Id: <3768125A.452BC0AD@lucent.com>

> I don't see why this should be unreliable, but I'm not completely certain
> how PREFIX and LIB interact. They should do the Right Thing, but the docs
> say
> 
>     Conflicts between parameters LIB, PREFIX and the various INSTALL*
>     arguments are resolved so that XXX
> 
> It seems that I can't see the rest of that paragraph because the V-chip
> just kicked in on my WebTV. :-)
> 
> Seriously, this looks as if someone left off in the middle of updating
> that part of the docs. Oops! But you should probably check that you're
> getting everything installed in the right places when you do 'make
> install' by reading through the Makefile you're getting. (You are using
> 'make install', aren't you?) Then make sure that you're also using 'use
> lib' correctly in your code. (You _are_ using 'use lib', aren't you?) And
> double-check that you're doing what the docs say for installing your own
> collection of modules.
> 
> Good luck!
> 
I am using make, make test, make install.  I have the library directory
added TWICE to @INC using #!/usr/bin/perl -l /home/burton/lib/perl
and BEGIN {shift @INC, '/home/burton/lib/perl'}

The error message shows up at "use", so yes, I am using use:
Can't locate loadable object for module String::Approx in @INC ....

Thanks,

Burton

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

Intel == facist scum.  Geez.


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

Date: Wed, 16 Jun 1999 14:35:11 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Makefile.PL when you're not the admin
Message-Id: <Pine.GSO.4.02A.9906161431570.26850-100000@user1.teleport.com>

On Wed, 16 Jun 1999, Burton Kent wrote:

> I have the library directory
> added TWICE to @INC using #!/usr/bin/perl -l /home/burton/lib/perl

That won't do it (although you're close).

> and BEGIN {shift @INC, '/home/burton/lib/perl'}

And that won't do it correctly (although you're even closer).

You probably want this:

    use lib '/home/burton/lib/perl';
    use String::Approx qw( or whatever... );

> Intel == facist scum.  Geez.

:-)

We all got a laugh a month or so ago when they accidentally sued a company
they were trying to negotiate with. Oops, didn't mean to sue you. It was
just a habit.... :-)

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



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

Date: Wed, 16 Jun 1999 15:18:26 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: memory question
Message-Id: <x3yzp20ymwu.fsf@tigre.matrox.com>


bing-du@tamu.edu writes:

> %test = (...=>..., ...=>..., ...);  # %test is a big associative array
> # do something with %test
> %test = ();
> 
> if the space ever taken by %test can be reused by the program after
> '%test=()'?

Yes. Perl will recycle the memory, and will use it if it needs to.

> What's the difference between '%test=()' and 'undef %test'?

Nothing that I am aware of. Note that undef()ing a scalar is
different from undef()ing a hash or an array. The former actually
undefines the scalar, so any access to it will result in a
warning. The latter will simply empty the hash/array.

HTH,
Ala



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

Date: Wed, 16 Jun 1999 14:13:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Tramm Hudson <hudson@swcp.com>
Subject: Re: my and interpolation?
Message-Id: <3768135C.2373C8B5@mail.cor.epa.gov>

[cc e-mail sent also]

Tramm Hudson wrote:
> [snip of good reply] 
> 
> Obligatory flame bait: I L1k3 symbolic referencez, d00d!!!1!

Obligatory flame reply:  Your random-capitalizer script is 
broken.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 16 Jun 1999 16:22:31 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: newbie learning "my" declarations
Message-Id: <B38D7FC7966826AA8@0.0.0.0>

In article <Pine.GSO.4.02A.9906161332510.26850-100000@user1.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:

>> With -w, my $total; $total = $total + 1; gives a warning.
>
>At least, it gives a warning unless it gives the wrong answer. (That is,
>unless the answer it happens to give happens to be the answer you happen
>to want. :-)

my $total; $total = $total + 1;

and

my $total; $total++;

both give the same answer (without declarations and use strict, the same
answers they've given since Perl 4, at least) but the former gives a
warning with -w.

Both are semantic oddities, relying on DWIM to not give random gibberish
for answers, but I don't understand why the latter is not a warnable
offence.

Lee




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

Date: 16 Jun 1999 15:43:28 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: newbie learning "my" declarations
Message-Id: <7k95q0$6uf@llama.swcp.com>

[posted and cc'd to cited author]

Tom Phoenix  <rootbeer@redcat.com> wrote:
> On Wed, 16 Jun 1999, Lee wrote:
> > Someone else wrote
> > >	my $total = $total + 1;
> > With use strict, that gives a compilation error.

Only because there is no variable named $total in scope.  This is
strict clean if either a lexical $total or global $total is defined.

> > With -w, my $total; $total = $total + 1; gives a warning.
> 
> At least, it gives a warning unless it gives the wrong answer. (That is,
> unless the answer it happens to give happens to be the answer you happen
> to want. :-)
> 
>     $total = 17;		#  global $total is 17
>     my $total = $total + 1;	# lexical $total is 18

As it should be.  This means that my declarations are equivalent to
let statements in scheme:

	(define x 10)
	(let ((x (+ x 1))) ... )

set x in the innermost scope (...) to 11.  The expressions are
evaluated in the outside scope and then the new lexicals are created.
Note that you will get a warning from perl with:

	my $x = 10;
	my $x = $x + 1;
"my" variable $x masks earlier declaration in same scope

but it still does the proper thing.

> Yow!

There's a dwarf running for office on a platform of asparagus in Chicago!

Tramm
-- 
  o   hudson@swcp.com                 tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.266.59.96   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

Date: Wed, 16 Jun 1999 22:10:25 +0100
From: 'x'campbell-lange@easynet.co.uk (Rory C-L)
Subject: newbie questions re conditional operators
Message-Id: <'x'campbell-lange-1606992210250001@campbell-lange.easynet.co.uk>

Conditional Operators

Quote from perlop.pod:
"...It works much like an if-then-else.  If the argument before the ? is
true, the argument before the : is returned, otherwise the argument after
the : is returned..."

$ok = "ok";
$a = "ok";
$b = "match";
$c = "no match"; 

($a eq $ok) ? $a = $b : $a = $c;
print "$a\n"; 

I thought the above code means if $a stringwise equals $ok then make $a to
"match" else make it to "no match"

The above prints "no match", even through $a does eq $a.

Help appreciated!
Rory

-- 
please remove the 'x' to reply by mail


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

Date: Wed, 16 Jun 1999 21:34:10 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: newbie questions re conditional operators
Message-Id: <mLU93.122$7X1.27948@news.shore.net>

Rory C-L <'x'campbell-lange@easynet.co.uk> wrote:
: ($a eq $ok) ? $a = $b : $a = $c;
: print "$a\n"; 

: I thought the above code means if $a stringwise equals $ok then make $a to
: "match" else make it to "no match"

: The above prints "no match", even through $a does eq $a.

That's odd. I'm not sure why the above doesn't work (I rarely use the ? :
syntax myself), but based on code I've seen posted in this ng, it's more
common to use the form

	$a = ( $a eq $ok ? $b : $c);

which does work.

Hope this helps!

--Art


-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Wed, 16 Jun 1999 14:57:06 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: newbie questions re conditional operators
Message-Id: <Pine.GSO.4.02A.9906161445220.26850-100000@user1.teleport.com>

On Wed, 16 Jun 1999, Rory C-L wrote:

> ($a eq $ok) ? $a = $b : $a = $c;

Complex precedence? Just: say no.

The ?: operator has higher precedence ("sticks together more tightly")
than assignment. So what you wrote is like this:

    (    ($a eq $ok) ? $a = $b : $a    ) = $c;

If the condition is true, it assigns $b to $a, then overwrites that 
with $c.

You probably meant this:

    $a eq $ok ? ($a = $b) : ($a = $c) ;

Although this is better:

    $a = $a eq $ok ? $b : $c;

And this is better yet, in most cases:

    if ($a eq $ok) { 
	$a = $b;
    } else {
	$a = $c;
    }

> please remove the 'x' to reply by mail

please remove the 'x' to get replies by mail

Cheers!

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



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

Date: 16 Jun 1999 21:07:33 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: pattern matching question
Message-Id: <7k93ml$nqs$1@info2.uah.edu>

In article <xkfemjblvx0.fsf@valdemar.col.hp.com>,
	Eric The Read <emschwar@rmi.net> writes:
: gbacon@itsc.uah.edu (Greg Bacon) writes:
: > If you're determined to use a regular expression
: > 
: >     ($path = $url) =~ s,^.*?//.*?/,,;
: 
: It's entirely possible that those are the ugliest delimiters I've ever
: seen for s///.

No one ever accused Perl of being a beauty pageant. :-)

Greg
-- 
Two most common elements in the universe: Hydrogen & Stupidity.


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

Date: Wed, 16 Jun 1999 14:27:01 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Deamon George Scapin <dscapin@harris.com>
Subject: Re: pattern matching question
Message-Id: <376816A5.F54AE00B@mail.cor.epa.gov>

[courtesy cc sent to poster]

Deamon George Scapin wrote:
> 
> I am trying to take the first part off of a url and return only the
> sub-directories and files.
> 
> Eg.  http://www.someplace.com/dir1/dir2/dir3/picture.jpg
>        to
>        dir1/dir2/dir3/picture.jpg
> 
> I looked at perldoc perlre but have a difficulty understanding all the
> rules.  Guess I have to read, re-read, re-read until it clicks but can
> someone help me out with this simple task?

George, others have already pointed out a regex to try, and a
module which will help.  But I want to add one more thought.
If you're having trouble grokking all the regex stuff, you might
want to go to this URL:
http://www.netcat.co.uk/rob/perl/win32perltut.html
and read through his tutorial on regular expressions.  It may
help move you further along the learning curve.  If you get
really interested in regexen but find the text of perlre and
perlop heavy going, you might consider buying Jeffrey Friedl's
book "Mastering Regular Expressions" (from O'Reilly).  A few
of its points are no longer valid for Perl, as he based it on 
5.003, but it still explains the art of regexen like no other
book I've found.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 16 Jun 1999 14:06:17 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl print to stdout not functioning
Message-Id: <Pine.GSO.4.02A.9906161403270.26850-100000@user1.teleport.com>

Did you realize that you posted this (at least) six times? If you don't
think posting is working, don't keep posting. Instead, try posting in a
test newsgroup until you've gotten everything working right, so we won't
keep seeing your messages again and again.

On Wed, 16 Jun 1999 gharris8158@my-deja.com wrote:

Deja, huh? I thought I'd seen this before. :-)

> CGI Error
> The specified CGI application misbehaved by not
> returning a complete set of HTTP headers. 

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

Hope this helps!

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



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

Date: Wed, 16 Jun 1999 16:54:58 -0400
From: Jeff Bowers <jbowers@bsat.com>
Subject: Re: sending to html page...
Message-Id: <37680F22.A09F9568@bsat.com>

Good Morning..

  Actually, your suggestion worked!  I used it as a test to verify the code
for the password was good to that point.  Now instead of a print statement, I
need it to "push" (I hate that term) a web page.

               Thanks for a quick response.

                                         -Jeff Bowers
Scratchie wrote:

> Jeff Bowers <jbowers@bsat.com> wrote:
> : The problem is the syntax to say "Yes your Password is
> : correct, here is your page".
>
> print "Yes your Password is correct, here is your page";
> (Sorry, couldn't resist!)
>



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

Date: Wed, 16 Jun 1999 14:14:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: sending to html page...
Message-Id: <Pine.GSO.4.02A.9906161411280.26850-100000@user1.teleport.com>

On Wed, 16 Jun 1999, Jeff Bowers wrote:

> I'm new to this newsgroup, so if this has come up before, forgive.

Okay, I'll forgive you. But the next time that you're about to ask a
question which may have come up before, be sure to check the relevant docs
and FAQs, and see whether your favorite Usenet archive might help you to
find the previous discussion. But, since you asked nicely, I forgive you.

> The problem is the syntax to say "Yes your Password is
> correct, here is your page".

> What (or where is) the scriptology to send a URL back to the browser?

It sounds as if you want to tell a browser to do something. Check the
docs, FAQs, and newsgroups about browsers and the protocols they use.
Cheers!

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



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

Date: Wed, 16 Jun 1999 21:27:40 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: sending to html page...
Message-Id: <gFU93.121$7X1.27948@news.shore.net>

Jeff Bowers <jbowers@bsat.com> wrote:
: Good Morning..

:   Actually, your suggestion worked!  I used it as a test to verify the code
: for the password was good to that point.  Now instead of a print statement, I
: need it to "push" (I hate that term) a web page.

I'm still not sure what you're trying to accomplish. If you want to
re-direct the user to a static HTML page, you print out a "Location: "
header. 

--Art
-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Wed, 16 Jun 1999 17:25:52 -0400
From: Jeff Bowers <jbowers@bsat.com>
Subject: Re: sending to html page...
Message-Id: <37681660.BD9FD9D5@bsat.com>

Actually... I just want a .pl script in cgi-bin to "send" a web page back to
the users browser on a Proper exit.  I did find something in the Perl pages,
buts it's a bit obscure about a CPAN  CGI.pm module.  I'm trying that
route at this time.  That instruction was at ...

 ftp://uiarchive.uiuc.edu/pub/lang/perl/CPAN/doc/manual/html/pod/perlfaq9.html#How_do_I_redirect_to_another_pag

but I must not have the appropriate module pre-compiled as the sample syntax
don't woik.

-Jeff Bowers
Tom Phoenix wrote:

> Okay, I'll forgive you. But the next time that you're about to ask a
> question which may have come up before, be sure to check the relevant docs
> and FAQs, and see whether your favorite Usenet archive might help you to
> find the previous discussion. But, since you asked nicely, I forgive you.
>
> It sounds as if you want to tell a browser to do something. Check the
> docs, FAQs, and newsgroups about browsers and the protocols they use.
> Cheers!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 16 Jun 1999 14:59:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: gheppner@my-deja.com
Subject: Re: win32 perl problems
Message-Id: <37681E4B.1F3B14D9@mail.cor.epa.gov>

[courtesy cc sent to poster]

gheppner@my-deja.com wrote:
> 
> Hi all,
> 
> Ok folks, here's my situation:  we resently upgraded our version of
> perl to the most recent.  all of our perl scripts ran fine before this.
>  Now we have a couple of scripts that return this error when you run
> them: CGI ERROR:
>       The specified CGI application misbehaved by not returning a
> complete set of HTTP headers.  The headers it did return are:
> 
> Bareword "main:NTGetCWD" not allowed while "strict subs" in use at
> C:Perl\lib/cwd.pm
>  line 238.
> Array found where operator expected at c:\perl\lib/cwd.pm line 238 near
> "main::NTGetCWD @_"
>       (Do you need to predeclare main::NTGetCWD?)
> Begin failed--complitaion aborted at ... etc etc...
> 
> It looks like this NTGetCWD is not a recognized function, even though
> it's included in the CWD package.

Hmmm.  I don't have a CWD module.  There is a Cwd module, but
it does *not* have a NTGetCWD function in it.  Is this a
homegrown function, or does it come from one of the 300-series
ActiveState builds?

You may have to change this to one of the functions in Cwd.pm
such as cwd(), getcwd(), fastgetcwd(), abs_path(), or
fast_abs_path() .  One [or more] of these should do what you
want.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 16 Jun 1999 14:53:24 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Chuck Hirstius <chirstius@mediaone.net>
Subject: Re: Win32::NetAdmin
Message-Id: <37681CD4.FAEBCE77@mail.cor.epa.gov>

[courtesy cc sent to poster]

Chuck Hirstius wrote:
> 
> I know WinNT is the lessor OS around here, but maybe someone can offer some

Not *everyone* around here has the flexibility to avoid all OSes
that offend their sensibilities.  Join the club.  And that's "lesser",
not "lessor" - Bill Gates only *thinks* he owns all of us and rents
pieces out.  :-)

> [snip of problem]

Since no one has posted an answer here, I wanted to let you know 
that you'll probably have better luck getting an answer in one of the
win32-centric listservs at ActiveState.  You can subscribe by
going to http://www.activestate.com/support/mailing_lists.htm
and then you can ask there.

> I'm perfectly aware that I'm an idiot as well, and feel free to tell me so,
> just include an answer to my question with the insult, so that next time I
> will be LESS of an idiot.  : )

Having a difficult problem doesn't make you an idiot.  It only makes
you frustrated.  If you had posted here with a trivial question
which was way off-topic for the ng, or which was answered in the
FAQ, or if you had announced that you couldn't be bothered to read
the FAQ or the docs but you wanted help anyway, or if you rudely
asked for someone to write you a custom script.. well then, you
might have appeared to be an idiot.  I don't see any such signs.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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