[16906] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4318 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 13 21:11:50 2000

Date: Wed, 13 Sep 2000 18:10:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968893814-v9-i4318@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 13 Sep 2000     Volume: 9 Number: 4318

Today's topics:
        Problem with STDIN (newbie question) <krazykat@welikekrazykat.com>
    Re: Prune doesn't work in find (Mike Nelsen)
    Re: Qualifications for new Perl programmer????? <nospam@david-steuber.com>
    Re: Qualifications for new Perl programmer????? <nospam@david-steuber.com>
        Req.: The perfect Perl Editor? <andreas@gispi-sport.de>
    Re: Running Program without wait for finish <barna@megapage.ch>
    Re: Running Program without wait for finish (Abigail)
    Re: sending multiple attachments (David Efflandt)
        Sockets question <lhswartw@ichips.intel.com>
    Re: Strange characters when using forms ^M <lr@hpl.hp.com>
    Re: Stuck with a perl script <timewarp@shentel.net>
    Re: Teaching Perl <spragg@cs.ucdavis.edu>
    Re: Teaching Perl (Randal L. Schwartz)
    Re: This Code Isn't Working? (Randal L. Schwartz)
    Re: This Code Isn't Working? rathmore@tierceron.com
    Re: This Code Isn't Working? rathmore@tierceron.com
        transliterating file names in a dir pault4282@my-deja.com
        XML parser in perl poojakumari@hotmail.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Sep 2000 17:40:32 -0700
From: "kk" <krazykat@welikekrazykat.com>
Subject: Problem with STDIN (newbie question)
Message-Id: <39c01f25$1_3@california.uncensored-news.com>

I am new to perl, so I apologize for the newbie question. My problem is that
when using the code from the "Learning Perl" manual, I am unable to get the
program to pause (and accept my name) after I prompt for user input.
According to the book, the <STDIN> construct is there for that reason. Am I
missing something here? I'm convinced that I am, because the result is the
same in Linux or Win98.

#!/usr/bin/perl
print "What is your name?\n" ;
$name = <STDIN>;
chomp ($name);
print "Hello, $name!\n;

   which returns these lines:
What is your name
Hello,

So, if someone could point out what I have done wrong, I'd be very grateful.

John Davis
krazykatNOSPAM@inreach.net




______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
 With Servers In California, Texas And Virginia - The Worlds Uncensored News Source
  


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

Date: Thu, 14 Sep 2000 00:49:13 GMT
From: mnelsen@nc.rr.com (Mike Nelsen)
Subject: Re: Prune doesn't work in find
Message-Id: <39c01e45.52159163@news-server>

Thanks, that did the trick!

On 13 Sep 2000 13:25:10 +0100, brianr@liffe.com wrote:

>mnelsen@nc.rr.com (Mike Nelsen) writes:
>
>> On 12 Sep 2000 13:36:21 +0100, brianr@liffe.com wrote:
>> >sub wanted {
>> >    print "$File::Find::name\n";
>> >    $File::Find::prune=1 if -d && $opt_nosub;
>> >}
>> >
>> >Should work
>> Unfortunately, it doesn't. The -d doesn't really make any difference.
>
>Ooops that should have been:
>
>sub wanted {
>    print "$File::Find::name\n";
>    $File::Find::prune=1 if -d && $_ ne '.' && $opt_nosub;
>}
>
>Sorry, I should have tested the code I posted rather than expect it to
>work just because it came from a working script.
>
>-- 
>Brian Raven
>Perl itself is usually pretty good about telling you what you shouldn't
>do. :-)
>             -- Larry Wall in <11091@jpl-devvax.JPL.NASA.GOV>



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

Date: Wed, 13 Sep 2000 23:58:42 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <m3em2nu9n3.fsf@solo.david-steuber.com>

Brendon Caligari <bcaligari@my-deja.com> writes:

' Doh....I think any self-respecting programmer does end up with a
' portfolio of programs/modules/whatever which he could very well present
' at an interview....just like designers/etc.  It's stupid asking some 27
' year old programmer, with a couple of degrees, and years of experience
' to sit for an exam....but then again..what do you expect from a
' headmistress.

A code portfolio is a nice idea.  Of course, it only works when you
are allowed to take the code home with you and keep it.  That has not
been an option for me in the past when working for others.  I can only
show off the code I wrote for fun.

I did my own base64 decoder in C myself.  I don't have it on hand
because I did it for a company that wouldn't let me take code home
with me.

There are times when you may well want to do somthing that n other
people have done already.  Just for fun.  Maybe to learn how the
language makes you think about a problem.  There is nothing wrong with
that at all.

There are other times when you need to get some task done in the
shortest possible time frame.  Then you have to weigh the time it
takes to build your own wheel or learn to use an existing wheel.  I
will generally follow the path of least resistance.  At least, the
path that I think will have the least resistance.

When it comes to programming, there is more than just the language.
If you pick up a dictionary, you can pretty quickly learn to speak
gibberish in the language for which that dictionary was written.
Learning to write poetry in that language takes longer.  However, many
forms of poetry have similar constructs like rime and meter.  In
programming you have algorithms and data.  It's Wirth's famous
equation.  If you don't understand the fundamentals of algorithms and
data, then it really doesn't matter if you have memorized the special
variables in Perl or all the key words and libraries.  None of it will
do you any good because you will only be able to speak gibberish, not
poetry.

A good programmer can get a job done in just about any language.  A
bad programmer can't get anything done in any language.

-- 
David Steuber | "Are you now, or have you ever been, a member
NRA Member    | of the NRA?" --- HUAC, 2004

Happiness is a SAAB Gripen <http://www.gripen.saab.se/> in the
garage, an FN-FAL in the safe, and an HK P7M8 on the hip.


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

Date: Thu, 14 Sep 2000 00:08:04 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <m3bsxru97f.fsf@solo.david-steuber.com>

"Christopher M. Jones" <christopher_j@uswest.net> writes:

' I suppose I could if I had the money and I really wanted
' one.  It's not like the chinese are very picky about who
' they sell those things too.

I doubt that the ATF will give approval on the Form 6 (if I've got
that right).  Then there is the U.S. Customs to deal with, the same
$200 tax for a 'destructive device', etc, etc.

Still, it might be less trouble than exporting encryption code from
the US used to be (still is?).

Note followups, and no, I do not go to t.p.g.  It's not a friendly
neighborhood like rec.guns is.

-- 
David Steuber | "Are you now, or have you ever been, a member
NRA Member    | of the NRA?" --- HUAC, 2004

Happiness is a SAAB Gripen <http://www.gripen.saab.se/> in the
garage, an FN-FAL in the safe, and an HK P7M8 on the hip.


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

Date: Thu, 14 Sep 2000 02:22:27 +0200
From: "Andreas Leiberger" <andreas@gispi-sport.de>
Subject: Req.: The perfect Perl Editor?
Message-Id: <8pp5mh$dl1rv$1@ID-41787.news.cis.dfn.de>

Hi !!!

Is there a software for creating perl scripts that includes an excellent
help documentation. I'm a fan of  the mark+F1 technique. I kind of miss that
in Notepad. :-)
Can you recommend any programm in this context.

Thanks ANDREAS

ps.: I know my english sucks. Neverzheless I hope you know what I mean.





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

Date: Thu, 14 Sep 2000 00:12:14 +0200
From: Barna <barna@megapage.ch>
Subject: Re: Running Program without wait for finish
Message-Id: <39BFFBBE.F24A8108@megapage.ch>

Its not just a script, it's a big program,
I need it in one of many subs and i get an error (a perl-crash, in win32) when I
try to fork in the sub...

is there a possibility to do this?

thanks


Abigail schrieb:

> Barna (barna@megapage.ch) wrote on MMDLXX September MCMXCIII in
> <URL:news:39BFF52B.67FC5601@megapage.ch>:
> ~~ Hi All
> ~~
> ~~ I want to execute a program, but i don't want to wait for it's end, and
> ~~ without of using alarm....
> ~~ I'd like to run the script on win32 and linux
>
> fork() and exec().
>
> Abigail
> --
> # Perl 5.6.0 broke this.
> %0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
> (.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi



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

Date: 13 Sep 2000 22:32:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Running Program without wait for finish
Message-Id: <slrn8s001o.ku0.abigail@alexandra.foad.org>

Barna (barna@megapage.ch) wrote on MMDLXX September MCMXCIII in
<URL:news:39BFFBBE.F24A8108@megapage.ch>:
## Its not just a script, it's a big program,
## I need it in one of many subs and i get an error (a perl-crash, in win32) whe
## try to fork in the sub...
## 
## is there a possibility to do this?

DO NOT POST JEOPARDY STYLE!

That's very bad netiquette.

DO NOT USE LINES 80 CHARACTERS LONG.

That's very bad netiquette.


As for the size of the program, it doesn't matter. On Unix, the only 
way to start another process is to use fork(). 

As for win32, perl 5.6.0 is supposed to support fork(). If it's perl that
crashes, you found a bug. Use perlbug.



Abigail
-- 
perl -wlne '}print$.;{' file  # Count the number of lines.
#    A pair of swallows
#    flying towards the north-west.
#    The Astronomer.


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

Date: Thu, 14 Sep 2000 00:21:49 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: sending multiple attachments
Message-Id: <slrn8s06ge.pji.efflandt@efflandt.xnet.com>

On Wed, 13 Sep 2000, Megean McDuffy <mmcduffy@mathworks.com> wrote:
>
>I'm trying to send an email with multiple attachments from a browser.
>I have been sucessful in sending a single attachment using sendmail in my
>program, but I can't figure out how to alter it to allow multiple files to
>attach.  I found something somewhere that suggested using system because the
>system version will allow this, but this has puzzled me as well.  If anyone
>has an idea, please let me know.

You might try MIME::Lite.  I have used it to optionally attach files, if
files are uploaded from a form (handled by CGI.pm).  It should be able to
similarly handle multiple attachments.  See the following under MORE
EXAMPLES in the perldoc (or Lite.pm itself):

Create a multipart message exactly as above, but using the "attach to
singlepart" hack:

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Wed, 13 Sep 2000 17:04:36 -0700
From: Larry Swartwood <lhswartw@ichips.intel.com>
Subject: Sockets question
Message-Id: <39C01613.ACF2FF2B@ichips.intel.com>

Hi all,

New to newsgroups so please bear with me.

I am receiving the following error when running my client/server script:

Bad arg length for Socket::unpack_sockaddr_in, length is 1, should be 16
at Socket.pm line 311.

In the script I setup a client and server like so:

#Server part
my serv_port = \11000;
my $proto = getprotobyname('tcp');

 socket( BF_SERVER, AF_INET, SOCK_STREAM, $proto )    or die "socket:
$!";
 setsockopt( BF_SERVER, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) or die
"setsockopt: $!";
 bind( BF_SERVER, sockaddr_in( $$serv_port, INADDR_ANY))   or die "bind:
$!";
 listen( BF_SERVER, SOMAXCONN)

#Client part
my $azureus_port = \10000;

 $iaddr = inet_aton( $remote) or die "no host: $remote";
 $paddr = sockaddr_in( $$azureus_port, $iaddr);

 socket( SOCK, AF_INET, SOCK_STREAM, $proto) or die "socket: $!";
 connect( SOCK, $paddr) or die "connect: $!";

I receive the error when my server accepts an incoming connection and a
data transfer is supposed to happen.
Any ideas?

Thanks,
Larry S.



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

Date: Wed, 13 Sep 2000 17:48:18 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Strange characters when using forms ^M
Message-Id: <MPG.1429c02ea1496c0798ad5e@nntp.hpl.hp.com>

[Rearranged in logical sequence -- question before answer.]

In article <39BFD3DE.36405F2E@notlighthousemarketingnot.com> on 13 Sep 
2000 19:20:16 GMT, Kevin Metcalf 
<notkmetcalf@notlighthousemarketingnot.com> says...
> Tom Fotheringham wrote:
> 
> > I use:
> >
> > $data=$q->param("whatever");
> >
> > ,when recieving info from a TEXT AREA, I get a couple of ^M
> >
> > Can anyone please point me in the right direction as how to get TEXT
> > AREA information to work as a normal text field?
>  
> The ^M is a control character representation of a return.  When the data
> is returned, use something like:
> $value =~ s/%0D//g;

That would remove every occurrence of the three-character string '%0D'.

To remove every occurence of the single character "\cM":

  $value  =~ tr/\cM//d;

You could also use "\x0D", or "\15", or "\r" (except on a Mac).

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


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

Date: Wed, 13 Sep 2000 18:05:50 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Stuck with a perl script
Message-Id: <39BFFA3D.D38AA15D@shentel.net>

SANDEEP NACHANE wrote:

> Hello Perl Guru's
>
> I am coding a perl script for my site which would allow the visitor to vote.
> It has 3 radio buttons and a
> submit button ( to submit the vote ).
>
> I have already tried the following code in my form
>
> <form action="http://www.mysite.com/cgi-bin/vote.pl" target="_NEW"
> method=get >
>
> This opens a new window, but I do not have control over its height and
> width. It takes default values from my browser. Is there a way to control
> the height and width of the 'popup' browser window from a perl script ?
>
> Any help will be appreciated. I am just a novice in this language.
>
> -Sandeep

To my knowledge, you cannot control the size of a window or open one with Perl
on a server. This is done quite easily with javascripting, though. The thing you
have to do is to is to tie the returning response that the server sends out into
the new window. I have done this many times in a number of the projects I have
worked on. Let me know more about the specifics of your project and I can help
you more with a good strategy here as there are more than one way to do this
depending on your needs.

Albert Dewey




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

Date: 14 Sep 2000 00:15:48 GMT
From: Adam Trace Spragg <spragg@cs.ucdavis.edu>
Subject: Re: Teaching Perl
Message-Id: <8pp5bk$83o$1@mark.ucdavis.edu>

Tim <SPAM+indigo@dimensional.com> wrote:
: For people who have do this sort of thing before, any general advice?

I haven't done this sort of thing, but I still have some general advice.  
Knowing Perl will not automatically make you a good teacher.  Teaching is a
skill in and of itself, regardless of the subject matter.

I decided to describe Perl (and general) programming to my girlfriend recently
(who is a recent math major graduate).  I described variables and values, and
that went well.  If a=5 and b=6, then c=a+b would result in c being 11.  It
was when I said that you could do "c=c+1" that she sort of flipped out.  In
a math sense, "c=c+1" rarely ever makes sense.  :)  Also, if c is reassigned
c+1, then when would the cycle stop?  Etc, etc.

My point of all this is to show that even though I thought it would be simple
to describe even the most elementary concepts, it was much more difficult than
I anticipated.  

I guess this doesn't really apply if you are teaching computer savvy folk, but
might if you are teaching newbies.

HTH
Adam



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

Date: 13 Sep 2000 17:35:36 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Teaching Perl
Message-Id: <m1itrzdd47.fsf@halfdome.holdit.com>

>>>>> "Adam" == Adam Trace Spragg <spragg@cs.ucdavis.edu> writes:

Adam> I haven't done this sort of thing, but I still have some general
Adam> advice.  Knowing Perl will not automatically make you a good
Adam> teacher.  Teaching is a skill in and of itself, regardless of
Adam> the subject matter.

Yup.  What I've noticed, and what I look for in other people who want
to work for me, is some ability to be introspective... "how do I know
this?" "how did I learn it?"  "what prior knowledge did that build on
or presume?".  And then the harder problem (I think) of being able to,
in real time, decode someone else's "world view" when they ask a
question, and bridge that from their world to a path that works for
the rest of the classroom.

It's a "show biz" job too, which some people can't hack.  Eight hours
a day, 10-15 days a month or so, I'm on stage.  I can't just take a 15
minute break because I got paged or because my brain is now hurting.
(And yes, that comes up.)  I've got to be friendly, capable, and deal
with whatever my internal state is while still engaging in their
external state and my internal model of their internal state.  And not
just one of them -- usually more like 10 to 20 of "them" at the same
time.  And according to the timeline, even though we got distracted
for 10 minutes because someone didn't get how the $a and $b could
really make that sort be a numeric sort.

I have a huge admiration for anyone who makes it in the training biz
without going totally nuts.  Sometimes, I'm not so sure about
myself. :)

print "_Not_ just another Perl trainer,"

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


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

Date: 13 Sep 2000 15:07:21 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: This Code Isn't Working?
Message-Id: <m17l8geyjq.fsf@halfdome.holdit.com>

>>>>> "Lauren" == Lauren Smith <lauren_smith13@hotmail.com> writes:

Lauren> <rathmore@tierceron.com> wrote in message
Lauren> news:8poka9$c4c$1@nnrp1.deja.com...
>> sub convertSize {
>> $count = @SKU_list;
>> for ($i = 0; $i < $count; $i++) {
>> if ($SKU_list[$i] eq $SKU ) {
>> $size = ""; # Convert size to blank
>> return;
>> }
>> }
>> }

Lauren> I wish Deja would fix their indentation issues.

They should be using Text::AutoFormat from the CPAN. :)

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


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

Date: Wed, 13 Sep 2000 22:10:02 GMT
From: rathmore@tierceron.com
Subject: Re: This Code Isn't Working?
Message-Id: <8potv8$o79$1@nnrp1.deja.com>

First, let me thank both of you for taking the time to reply to my
inquiry. I appreciate that a lot!

>japhy@pobox.com wrote:
>   for (@SKU_list) {
>     $size = "", return if $_ eq $SKU;
>   }

I'm all for this shorter syntax, but I don't understand it. I'll play
with it and see if I can figure it out.

> >$size and $SKU are part of the below array:
>
> That statement is false.  The value of $size and the value of $SKU
are in
> the @Item array.  $size and $SKU can change, and that won't effect the
> @Item array.

Right you are! And that was the trouble. I think because of my C
background, I keep thinking of @Item as a struct and not a array. What
I really did was assign the value of the scalars to the array, the
scalars aren't a part of the array, or IN the array. I figured this out
on a hunch that fixed my code.

Thanks again!


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


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

Date: Wed, 13 Sep 2000 22:24:23 GMT
From: rathmore@tierceron.com
Subject: Re: This Code Isn't Working?
Message-Id: <8poupv$p8e$1@nnrp1.deja.com>


> I wish Deja would fix their indentation issues.

I am trying to get trn installed so I won't have to use deja!


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


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

Date: Thu, 14 Sep 2000 00:53:06 GMT
From: pault4282@my-deja.com
Subject: transliterating file names in a dir
Message-Id: <8pp7hc$3e0$1@nnrp1.deja.com>

I have been trying with little success to transform a directory with a
large number of file whose names contain capital letters and white
spaces, to names which have now uppercase letters and which have dashes
(-) instead of white space.  For example:

Some file in My directory.jpg would become
some-file-in-my-directory.jpg

I have been using opendir and glob and foreach tr =~ A-Z/a-z/-/c but
nothing seems to work.  I recieve an error: transliteration pattern not
terminated.  Any suggestions?

thanks

paul






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


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

Date: Wed, 13 Sep 2000 23:37:52 GMT
From: poojakumari@hotmail.com
Subject: XML parser in perl
Message-Id: <8pp34e$uf7$1@nnrp1.deja.com>



I am writing some perl scripts, which manipulate XML to produce HTML
docs.  At the moment I am calling Apache Xalan-Java to translate the XML
to HTML, but this is very slow as a new JVM is started for every page
(about 200).  What I need is a perl XML parser so I can use the
XML::XSLT and XML::Generator modules. However, as far as I can tell,
XML::Parser uses expat, which is C code and needs to be compiled.  I
really need a cross-platform solution, so that my perl can load modules
from the current directory (so only base perl needs to be on each
machine) and parse XML without running any native code.  Does such a
parser exist?

Thanks,

-Pooja


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


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4318
**************************************


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