[7476] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1102 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 30 05:34:21 1997

Date: Tue, 30 Sep 97 02:00:35 -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           Tue, 30 Sep 1997     Volume: 8 Number: 1102

Today's topics:
     re: Advanced Perl Programming (Tony Baldassare)
     any faith in me? <branchms@foto.infi.net>
     Re: Anyone ever written to a GIF file from perl <ghowland@hotlava.com>
     Re: chopping second to last char? <bholzman@mail.earthlink.net>
     Re: chopping second to last char? (brian d foy)
     Re: chopping second to last char? (Tom Grydeland)
     connect() <tekman@aimnet.com>
     Re: couldn't spawn child process <sbekman@iil.intel.com>
     Re: couldn't spawn child process (Ben Reser)
     Generating bit patterns "00000000" .. "11111111" <ricky.roque@bigfoot.com>
     Help Req'd <webmaster@createyourweb.com>
     Re: HELP! on Attaching files to email. <Jan.Krynicky@st.mff.cuni.cz>
     Re: How to change date with perl? (Ben Reser)
     How to run Perl? <Bernhard.Kuegle@lottery.co.at>
     I failed to install the Perl. Could you help me? fallings@cdi.cheongjo.co.kr
     Re: Java CGI Post to Perl Script (Ben Reser)
     Re: Many CGI/PERL forms don't work with Lynx? gwynp_nouce@artware.qc.ca
     Re: New Perl syntax idea <Steve_Kilbane@cegelecproj.co.uk>
     new@cgi <vcamille@u.washington.edu>
     Re: Newbie ques: How to concatenate two strings? <jgostin@shell2.ba.best.com>
     Re: Newbie ques: How to concatenate two strings? (Ben Reser)
     Re: newbie question : crypt library (Helmut Jarausch)
     Options & No Wrong Answers <MELTON@PITNET.NET>
     output of cms in $_ instead of print ? (hw vantyen)
     Re: Perl Generator? gwynp_nouce@artware.qc.ca
     Re: Perl4 is *not* Y2K (was Re: Y2K) (Kevin Connery)
     Re: Reading each word from a file <bholzman@mail.earthlink.net>
     Recursive object reader <jaydee@worsdall.demon.co.uk>
     Re: Recursive object reader (Martien Verbruggen)
     Re: Syntax Question using regular expressions. (brian d foy)
     Re: week-of-the-year calculation (Ben Reser)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 30 Sep 1997 05:19:07 GMT
From: tb@hm.com (Tony Baldassare)
Subject: re: Advanced Perl Programming
Message-Id: <60q2pt$m90$1@Masala.CC.UH.EDU>

In article <342FC07C.C81E9E6B@weblogic.com>, Sriram Srinivasan <sriram@weblogic.com> wrote:

>   For example, there is a client perl program which uses IO::Socket.
>   At first, I trusted the source program and was wondering why it won't
>   work. After wasting lots of time,  I found that it was not PeerHost 
>   as printed in the book, but that it was PeerPort (or PeerAddr).
>>>
>
>I'm surprised. The examples have been tested on Solaris and NT. Can you 
>please point out the page number where the error is supposed to be? 

Sriram,
even though I had some trouble in time-tight situation because of
the above mentioned problem (yes, thus I complained :-) ), 
I think that the book itself is quite good.  
It is in  p193.  PeerHost should have been PeerAddr.


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

Date: Tue, 30 Sep 1997 00:23:40 -0400
From: BrAnCh <branchms@foto.infi.net>
Subject: any faith in me?
Message-Id: <34307ECC.6C87A690@foto.infi.net>

Hi,

  I learned HTML form Laura Lemay's Teach yourself web publishing with
HTML 3.2 in a week.
and now i'm working on Teach yourself CGI programming with perl5 in a
week (Eric Herrmann)
is this enough for me to learn with, or would you suggest I read
something else first??

thanks for your time,
Mark shellard.
with aspirations of being a web site developer in the next 3 months.





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

Date: Tue, 30 Sep 1997 09:10:09 +0100
From: Gary Howland <ghowland@hotlava.com>
Subject: Re: Anyone ever written to a GIF file from perl
Message-Id: <3430B3E1.3CB1@hotlava.com>

Ken Williams wrote:
> 
> Hi-
> 
> Yup, I've done this before, and I have zero expertise on the file format
> of GIF files.  I used GD.pm, which probably stands for Graphics Drawing or
> something like that.  But definitely investigate this package, it will
> make your work much easier if you want to create GIFs from inside a Perl
> script.
> 
> In article <EH9o6y.37J.C.amo@bath.ac.uk>, ab6rah@bath.ac.uk (R A Hart) wrote:
> 
> >I was wondering if anybody has any example code to write a GIF file (or
> >something that most browsers can read) from say a 2-d array of colourvalues.
> >
> >It needn't be too complex (i.e. I'll only want to do single images,
> >256-colours, and only the control blocks necessary to get the image onto
> >the screen.)


Try PerlMagick, the perl interface to ImageMagick - it is very good at
writing GIF files.

Gary
-- 
pub  1024/C001D00D 1996/01/22  Gary Howland <gary@hotlava.com>
Key fingerprint =  0C FB 60 61 4D 3B 24 7D  1C 89 1D BE 1F EE 09 06


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

Date: Mon, 29 Sep 1997 22:51:06 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: jaudall@students.wisc.edu
Subject: Re: chopping second to last char?
Message-Id: <3430691A.A75526F9@mail.earthlink.net>

[posted & mailed]

> I wrote a little perl program that did just this (stripped the last
> character) - and it worked.  However, instead of stripping the character
> (^M) - it stripped all
> the ^J (now I have one big line with ^Ms still in the code.)  Looks
> like I need something to strip the second to last character.   I
> included my perl script. Any suggestions or help would be appreciated?

If it exists on your system, you could use the dos2unix command.  If you
want to use perl, here's a safer and more perlish way to do what you
want:

#!/usr/local/bin/perl -np
s/\r$//;

If you put this in a script called, say, dos2unix.pl, you can convert
files like this:
perl dos2unix.pl _dosfile_ > _unixfile_

or

cat _dosfile_ | perl dos2unix.pl > _unixfile_

If you want to do the edits "in-place", you can do this:
perl -i.bak dos2unix.pl _file_

Hope this helps!

Benjamin Holzman




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

Date: Tue, 30 Sep 1997 00:34:27 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: chopping second to last char?
Message-Id: <comdog-ya02408000R3009970034270001@news.panix.com>

In article <34305876.414F9593@students.wisc.edu>, jaudall@students.wisc.edu wrote:

>In other words, DOS has (^J) and (^M) at the end of each line?
>
>I wrote a little perl program that did just this (stripped the last
>character) - and it worked.  However, instead of stripping the character
>(^M) - it stripped all
>the ^J (now I have one big line with ^Ms still in the code.)  Looks
>like I need something to strip the second to last character.   I
>included my perl script. Any suggestions or help would be appreciated?

if you want to get rid of control characters, just get rid of them
and stop fooling with chop ;)

sub strip_m
   {
   open(FILE, $file) or return undef;
   local $/ = undef;

   $all_the_marbles = <FILE>;

   close FILE;
   
   $all_the_marbles =~ s/\cM//g;

   return $all_the_marbles;
   }

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 30 Sep 1997 07:58:50 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: chopping second to last char?
Message-Id: <slrn631c9q.oir.Tom.Grydeland@mitra.phys.uit.no>

On Mon, 29 Sep 1997 22:51:06 -0400,
Benjamin Holzman <bholzman@mail.earthlink.net> wrote:

> #!/usr/local/bin/perl -np

Ehem: (quoting perlrun)

       To suppress printing use the -n switch.  A -p overrides a -n
       switch.

> cat _dosfile_ | perl dos2unix.pl > _unixfile_

Useless use of cat #1 this week.

> Benjamin Holzman

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Tue, 30 Sep 1997 01:25:55 -0700
From: Khayman <tekman@aimnet.com>
Subject: connect()
Message-Id: <3430B792.7518@aimnet.com>

Hey there, I'm working on an IRC Bot in Perl, had one previously but my
isp got hacked and all my coding was lost.  I can't get my connection
routine working again and it's terribly frustrating.  If someone could
please drop me an email to tekman@aimnet.com with some help, or even a
complete connection routine I would be most thankful :-)

	Tek


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

Date: Tue, 30 Sep 1997 09:54:24 +0200
From: Bekman Stanislav <sbekman@iil.intel.com>
To: DAVID GILMARTIN <david@gilmartin.uk.com>
Subject: Re: couldn't spawn child process
Message-Id: <3430B030.59E2@iil.intel.com>

DAVID GILMARTIN wrote:
> 
> [Sun Sep 28 12:55:59 1997] access to
> /ftp/webs/gilmartin.uk.com/summerhill/guestbook.cgi failed for
> ttym1b.powernet.co.uk, reason: couldn't spawn child process
> 
> what does "couldn't spawn child process" mean

I think that you system has finished its processes spawning resources
So it just can't start a new process. Or I remember that it's possible
to limit some tools to spawn a limited number of processes
Once I was using 'expect' language on the overloaded system and many
times my scripts failed with "too many spawned processes" message.
Talk to your sysadmin, I believe it might help.

-- 


______________________________________________________________________
Stas Bekman     mailto:sbekman@iil.intel.com.il [WebMaster Intel Corp]
Address:        Aba Silver 12/29, Haifa, 32694, Israel  
Phones:         [w]  972-(0)4-865-5188, [h]  972-(0)4-828-2264/3020
Home Page:      http://techunix.technion.ac.il/~ofelix     
Resource Center http://www.eprotect.com/stas/TULARC (Java,CGI,PC,Linux)
Linux-il Home:  http://www.linux.org.il/


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

Date: Tue, 30 Sep 1997 08:24:55 GMT
From: ben@reser.org (Ben Reser)
Subject: Re: couldn't spawn child process
Message-Id: <3430b5e9.24079234@192.168.0.1>

On 28 Sep 97 11:51:39 GMT, "DAVID GILMARTIN" <david@gilmartin.uk.com>
wrote:

>[Sun Sep 28 12:55:59 1997] access to
>/ftp/webs/gilmartin.uk.com/summerhill/guestbook.cgi failed for
>ttym1b.powernet.co.uk, reason: couldn't spawn child process
>
>what does "couldn't spawn child process" mean


First of all this is a WEB/CGI question that doesn't really belong in
this newsgroup.

However, generally it means that the web server is either too busy to
start to spawn the CGI or it means that you have run into the infamous
memory leak in Apache.  

Take a look at this reference if you're running Apache:
http://www.apache.org/docs/mod/core.html#maxrequestsperchild

This problem tends to show up in Solaris a lot because of some bugs in
the libraries that come with it.

************************* IMPORTANT *************************
Why the new email address you ask?
Simple, I'm attempting to simplify the way I filter my mail.
Please direct all personal mail to ben@reser.org
Not directing personal mail to this address may cause
delays in me reading your mail or may even get it deleted.
************************ IMPORTANT *************************

---
Ben Reser <ben@reser.org>
http://ben.reser.org
	
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d-(+)@ s:- a-- C++++$ UBVC++++(++)$ P+++$>++++ L- !E---- W@ N(+)>++ o? K--? w++$@>+++ !O---- !M V PS+(++)@>+++ PE++(+++)@ Y+(++)@ PGP+(++)>+++ t+()@ 5 X !R tv-(+)@>-- b+(++)>+++ DI++ D G e h++ r-()>+++ y? 
------END GEEK CODE BLOCK------ 


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

Date: Tue, 30 Sep 1997 17:22:14 +0900
From: Ricky Roque <ricky.roque@bigfoot.com>
Subject: Generating bit patterns "00000000" .. "11111111"
Message-Id: <3430B6B6.66894D5B@bigfoot.com>

I'm trying to generate pattern like the following
  "00000000"
  "00000001"
  "00000010"
        :
        :
 "11111110"
 "11111111"
with the following scripts.

> #!/usr/local/bin/perl
> $start = pack('B8','00000000');
> $end   = pack('B8','11111111');
>
>  for($start..$end)
> { for($i=0;$i<16;$i++)
>   {  unshift @vector, vec($_,$i,1); }
>   print  @vector,"\n";
>   $#vector = -1; print ;
> }

It stops at $start and doesn't increment upto $end.
Why? Please help.

Any other method of doing the task?
Thanks.



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

Date: Tue, 30 Sep 1997 03:33:47 -0300
From: Neil Trenholm <webmaster@createyourweb.com>
Subject: Help Req'd
Message-Id: <34309D4A.C360D767@createyourweb.com>

Please Help !

     	I have 2 html pages which are form based and identical except that
one POSTS to hello.cgi and the other GETS to hello.cgi.

The GET works.

The POST doesn't. It won't even allow access to the hello.cgi.

The hello.cgi script is

     #!/usr/local/bin/perl 
     print "Content-type: text/html\n\n"; 
     print "Hello World<BR>"; 

so it shouldn't be this script. (I hope...)

The GET test  www.createyourweb.com/test.html
The POST test www.createyourweb.com/test2.html 

Test em out, read the source code, please help.
Also, since POST used STDIN - could this be where the permission problem
lurks ?

Thanks,
Neil


-- 
Hayward Hudson's Community Pages
Cumberland County Nova Scotia On-line
http://business.atcon.com/hayward/index.html

Creative Web Design
Web Design, Creation & Site Management, Graphics, Internet Marketing
http://www.createyourweb.com

(902) 447-3779, RR2, 2695 Hansford Road, Oxford,  Cumberland Co., NS,
Canada


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

Date: Mon, 29 Sep 1997 20:53:01 -0700
From: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
To: Rob Nedelcu <nedelcu@algonet.se>
Subject: Re: HELP! on Attaching files to email.
Message-Id: <3430779D.6616@st.mff.cuni.cz>

Rob Nedelcu wrote:
> 
> Hi!
> 
> I need some help on attaching files when emailing individuals who have
> filled in their email adress in a form. Collecting it and sending a
> message is no problem, but I need to send 2 files along with it as
> word documents. How do I do this one? I've tried almost anything!
> 
> I'm using sendmail...
> 
> Please, any help would be very appreciated...
> 
> Best regs...
> 
> Rob

You'd better use a module.
Say Mail::Sender.pm from http://www.chipnet.cz/depot/perl.htm

HTH, Jenda


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

Date: Tue, 30 Sep 1997 08:38:36 GMT
From: ben@reser.org (Ben Reser)
Subject: Re: How to change date with perl?
Message-Id: <3430ba20.25158686@192.168.0.1>

Get the Date::DateCalc module from CPAN.
http://www.perl.com/CPAN-local//modules/by-module/Date/DateCalc-3.2.tar.gz

After you've got that installed do a perldoc DateCalc and look for the
function named: calc_new_date_time

On 29 Sep 1997 09:49:26 GMT, "David" <mysun@mbox2.singnet.com.sg>
wrote:

>Hi, there,
>
>I use function localtime to get current local date&time. But I do not know
>use which function to add a few days to this date? 
>
>For instance, today is 9-29-1997, if I add 7days to it, how do I do?
>
>Is there a simple way other than programming a logic procedure?
>
>I use perl for win32 under windows 95.
>
>Thanks in a advance.
>


************************* IMPORTANT *************************
Why the new email address you ask?
Simple, I'm attempting to simplify the way I filter my mail.
Please direct all personal mail to ben@reser.org
Not directing personal mail to this address may cause
delays in me reading your mail or may even get it deleted.
************************ IMPORTANT *************************

---
Ben Reser <ben@reser.org>
http://ben.reser.org
	
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d-(+)@ s:- a-- C++++$ UBVC++++(++)$ P+++$>++++ L- !E---- W@ N(+)>++ o? K--? w++$@>+++ !O---- !M V PS+(++)@>+++ PE++(+++)@ Y+(++)@ PGP+(++)>+++ t+()@ 5 X !R tv-(+)@>-- b+(++)>+++ DI++ D G e h++ r-()>+++ y? 
------END GEEK CODE BLOCK------ 


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

Date: Tue, 30 Sep 1997 10:36:14 +0100
From: Bernhard K|gle <Bernhard.Kuegle@lottery.co.at>
Subject: How to run Perl?
Message-Id: <3430C80E.7DBE@lottery.co.at>

I am an absolute beginner to Perl and I4d like to run it on my
NT-System. But it doesn4t work really although I think that I have tried
everything (permissions checked, Perls scripts associated). 

When I run a Perl script on the command line it works fine. But when I
try to run it from my browser (Explorer, Netscape) it doesn4t work. I
see only the file content, not the result. 

Within the Perls script I have also used the recommended header 
print "HTTP/1.0 200 OK\n";
print "Content-type: text/html\n\n";

So what to do else? Thanks for your help in advance.

bernd

(bernd.kuegle@theoffice.net)


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

Date: Mon, 29 Sep 1997 07:50:02 GMT
From: fallings@cdi.cheongjo.co.kr
Subject: I failed to install the Perl. Could you help me?
Message-Id: <342f5d03.24915509@news.dacom.co.kr>

Hello.
I have a problem about installing the latest version of perl in my
system.

My system is here.

Os : Sun Unix and solaris 2.5.1
system : spark station 20

and the c compiler of Sun Soft is installed.

I typed the command in the process of your installation.

first, I decompress the .tar.gz file in a tmp directory.

and typed "sh Configure -des".

then the process continued. but it stopped in here..

>>>>>>>>>>>>>>>>>>>>
cat: cannot open .clist
cat: cannot open .hlist
>>>>>>>>>>>>>>>>>>>>

I suspect that there are two makefiles, 'Makefile' and 'makefile'.

I think that my system is the standard and it has no problem in system
and the compiler.

This is my first time to install the Perl.

Please, May I get your good opinion?

I hope your answer as fast as possible.

bye.

mail : fallings@cdi.cheongjo.co.kr



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

Date: Tue, 30 Sep 1997 08:27:16 GMT
From: ben@reser.org (Ben Reser)
Subject: Re: Java CGI Post to Perl Script
Message-Id: <3430b774.24474171@192.168.0.1>

There is always an error message that is stored in the log files for
your server (as the idiot's guide suggests that you look at).  Try to
look at it and figure out what the associated error message is with
regards to your problem.  After you do that try posting to a more
appropriate newsgroup. CLPM isn't for CGI or WEB debugging and you'll
get better answers from another newsgroup that is.

On Mon, 29 Sep 1997 16:58:55 GMT, peterpan@mailexcite.com (Peter)
wrote:

>Hello Ben,
>
>	I have checked that Guides and FAQ. It didn't help.
>
>ben@reser.org (Ben Reser) wrote:
>
>>You might want to refer to the following references to help you:
>>
>>The Idiot's Guide to Solving Perl CGI Problems
>>http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html
>>
>>Perl CGI Programming FAQ 
>>http://www.perl.com/CPAN-local/doc/FAQs/cgi/perl-cgi-faq.html
>>


************************* IMPORTANT *************************
Why the new email address you ask?
Simple, I'm attempting to simplify the way I filter my mail.
Please direct all personal mail to ben@reser.org
Not directing personal mail to this address may cause
delays in me reading your mail or may even get it deleted.
************************ IMPORTANT *************************

---
Ben Reser <ben@reser.org>
http://ben.reser.org
	
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d-(+)@ s:- a-- C++++$ UBVC++++(++)$ P+++$>++++ L- !E---- W@ N(+)>++ o? K--? w++$@>+++ !O---- !M V PS+(++)@>+++ PE++(+++)@ Y+(++)@ PGP+(++)>+++ t+()@ 5 X !R tv-(+)@>-- b+(++)>+++ DI++ D G e h++ r-()>+++ y? 
------END GEEK CODE BLOCK------ 


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

Date: Tue, 30 Sep 1997 07:31:11 GMT
From: gwynp_nouce@artware.qc.ca
Subject: Re: Many CGI/PERL forms don't work with Lynx?
Message-Id: <3430a9e6.4914073@news.videotron.ca>

On 29 Sep 1997 14:49:34 GMT, lvirden@cas.org wrote:

>
>According to Patrick Kellum <patrick@syix.com>:
>:Could Lynx be sending the form data back wrong?  I know the copy of Lynx
>
>In my experience, the most common problems I have had with lynx is
>incorrectly written forms which happen to work okay with MS IE or Netscape.

That could very likely be the problem.  Lynx is picky about HTML code,
much more so than MSIE or Netscape.

Another possibility is that you are using a GET method and the string
is too long for Lynx's HTTP routines.  RFC-1945 says that GETs should
be avoided for this very reason, if my memory serves me correctly. 

-Philip


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

Date: Tue, 30 Sep 1997 09:17:35 GMT
From: Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
Subject: Re: New Perl syntax idea
Message-Id: <91e7cd$91123.10d@news.cegelecproj.co.uk>

Actually, I quite like this idea. It seems reminiscent of the magic
that while(<>) inflicts upon $ARGV.

In article <comdog-ya02408000R2909972102480001@news.panix.com>, comdog@computerdog.com (brian d foy) writes:
> where does this magic variable live?

A reasonable question, but it makes sense to have the magic variable
be lexically scoped, i.e.

method foo {
	...
}

would be exactly the same as

sub foo {
	my $self = shift;
	...
}

	"In fact, as of this writing, it's implemented that way."
		-- Camel I, p78.

So if you were to put "my $self" in a method with -w turned on,
you'd get the "hides a previous declaration" warning.

> even if a syntax such as this were available, i would still end
> up doing something like
> 
>    my $self = $MAGIC_VARIABLE;
> 
> since i like to give my objects names.  things are a lot easier
> to maintain that way.

Indeed. More importantly, how many folks' fur would be
ruffled by the decision to call the object ref $self, when they
come from a different obect camp? Or would there be a
request for a corresponding class_method/$class aliasing,
when there isn't any real difference?

In the end, though, I'd question how much effort this would
save on the part of the programmer.
-- 
<Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
Kilbane's law of integration: standardise on protocols and file
formats, and the applications take care of themselves.



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

Date: Tue, 30 Sep 1997 00:51:43 -0700
From: Victoria Hawkins <vcamille@u.washington.edu>
Subject: new@cgi
Message-Id: <3430AF8F.2F5F@u.washington.edu>

Hello,

I am trying to write a DNA sequence($sequence) to a file called SEQUENCE
as part of a cgi script.  If I execute the script at the unix prompt,
SEQUENCE appears in the directory, and inside is the sequence. If I use
the browser to execute the program, then SEQUENCE doesn't get created. 
The following is what I use:  



$sequence=$query{'SEQ'}; #$ENV{'SEQ'} from cgi-input is re-assigned
open(OUT, ">SEQUENCE"); # open SEQUENCE file for writing
print OUT $sequence; #print the sequence into SEQUENCE
close(OUT);


I know that the program is getting all the name-value pairs from the
POST input(so $sequence above is something like GGTAGGTGTG...). 
Alternatively, I've tried to execute a system call like 

system("echo $sequence >SEQUENCE");

but this doens't seem to work with browser execution either(still fine
at the prompt).


How come it works in Lincoln Stein's book('How to Set...'), and not
here? 


-Victoria
vcamille@u.washington.edu


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

Date: 30 Sep 1997 07:54:04 GMT
From: Jeff Gostin <jgostin@shell2.ba.best.com>
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <60qb6s$91g$2@nntp1.ba.best.com>

Joseph <jglosz@san.rr.com> wrote:
: Jefff, thanks. That works. The "join" function also works well.  Thanks
: for a useful answer. Unlike old Abigail here.

	Glad to help. :) I'm "Just Another Perl Rookie" (to quote another
poster), but I figure, if I knew the answer, I should contribute what little
I can. :)

	On another topic, one newbie to another: Abigail's post wasn't out
of line, insofar as her recommending that one doesn't mess with what one
doesn't know about. The tone wasn't too great, but the message is a good
one. It was valid advice, but it failed to answer your question. Newbies
shouldn't be playing with code that people are relying on unless they have
no choice.... it leads to more problems than it fixes. :)


				--Jeff


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

Date: Tue, 30 Sep 1997 08:32:13 GMT
From: ben@reser.org (Ben Reser)
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <3430b8a5.24779761@192.168.0.1>

You're right this is bad style.

Whenever you can avoid interpolation do so.  That means if you don't
need to quote something with double quotes don't.  

Also, join is another bad choice for whoever posted that, though a bit
better than the interpolation method.

Basically unless you have a need to do otherwise:
$x = $y . $z;
is the best code.

On 29 Sep 1997 03:10:19 GMT, Jeff Gostin <jgostin@shell2.ba.best.com>
wrote:

>Tad McClellan <tadmc@flash.net> wrote:
>:    $value = "$name$value"; # this is called 'interpolation' but it
>:                            # has the same effect if used as shown
>
>Ah, cool... Yet Another Way. :) When would one use interpolation rather than
>concatenation?
>
>: But please don't call it that. 'lvalue' already has a meaning, and it
>: isn't that ;-) $name and $value are *both* lvalues...
>
>Do I get style points at least? :) They were bad choices, admittedly, but
>were the first ones to come to mind. I probably should've called them value1
>and value2. Ah, what's in a name? ;)
>
>
>				--Jeff


************************* IMPORTANT *************************
Why the new email address you ask?
Simple, I'm attempting to simplify the way I filter my mail.
Please direct all personal mail to ben@reser.org
Not directing personal mail to this address may cause
delays in me reading your mail or may even get it deleted.
************************ IMPORTANT *************************

---
Ben Reser <ben@reser.org>
http://ben.reser.org
	
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d-(+)@ s:- a-- C++++$ UBVC++++(++)$ P+++$>++++ L- !E---- W@ N(+)>++ o? K--? w++$@>+++ !O---- !M V PS+(++)@>+++ PE++(+++)@ Y+(++)@ PGP+(++)>+++ t+()@ 5 X !R tv-(+)@>-- b+(++)>+++ DI++ D G e h++ r-()>+++ y? 
------END GEEK CODE BLOCK------ 


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

Date: 30 Sep 1997 08:29:20 GMT
From: jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch)
To: "Jean-Francois Deschenes" <deschenj@rc.gc.ca>
Subject: Re: newbie question : crypt library
Message-Id: <60qd90$576$1@news.rwth-aachen.de>

In article <01bccd33$5f957db0$42fc888e@beer_factory>, "Jean-Francois Deschenes" <deschenj@rc.gc.ca> writes:
|> I have just started to learn perl and I was trying to create a password
|> file with the crypt function.  When i tried it at first it said crypt() not
|> implemented.  So i got the crypt library (international version) from my OS
|> site (SCO).  I installed it and it said installation successful, no
|> problem. 
|> 
|> I now have the libcrypt_i.a file but i still have the same problem with
|> perl.  I guess i must add this new library to perl but I don't know how. 
|> Do I have to reinstall perl or can just type a command?
|> 
|> I realize it's a very simple question but I have looked at the perl FAQ and
|> have not found an answer ( maybe i did not see it ).
|> 

I am afraid the question has no such simple answer.
I see two choices. If you must stick to this library, you probably have to
write 'glue' between Perl and this library. That requires you to write
so-called XS-code (a sort of precompiler for fitting you C-code to Perl)
It's not that difficult but needs some time if you haven't used it before.
Look at  perlxs, perlxstut and perlguts.

If you don't have to use that specific library, you can try the package
Cryptix-1.16 (see http://www.systemics.com/software/ )

Hope, this helps, anyway.
Helmut.

-- 
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany


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

Date: Tue, 30 Sep 1997 00:56:47 -0500
From: "April D. Melton" <MELTON@PITNET.NET>
Subject: Options & No Wrong Answers
Message-Id: <3430949D.965612B7@PITNET.NET>

I am writng a "Scoring/Gradebook" type script & having some trouble. I
wouldn't have written here, but I couldn't find any similar examples any
where else.

There are 26 questions & each has four possible responses. None of the
responses are incorrect, just different.

Example: Rate Yourself:<SELECT name="Z26" size="1">
<OPTION value="0">Needs Work</OPTION>
<OPTION value="1">Fair</OPTION>
<OPTION value="2">Good</OPTION>
<OPTION value="3">Excellent</OPTION>
</SELECT><INPUT type="submit"
name="finish" value="Submit">

At the end of the quiz, I want the script to perform two functions:
1. Add the numerical score.
     This part is simple:
     $score = $A1 + $B2  + $C3;
2. Print to screen the option chosen for each question.
     Example: For question A, you rated yourself as "Excellent."
     How do I reconvert the numerical choice back to a text choice?
     I tried putting it into a hash but it didn't work. I think I
probably didn't reference it correctly.

Does anyone have any suggestions? If so, please email me at
melton@pitnet.net

April D. Melton



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

Date: 30 Sep 1997 07:37:29 GMT
From: henq@phsoft.knoware.nl (hw vantyen)
Subject: output of cms in $_ instead of print ?
Message-Id: <1997093009385065478@[120.200.55.22]>

Hi,

I am struggling with the following:
I CAN do:

    open (CMD, "|myCmd myArguments") or die "no $!";
    print CMD;

The output myCmd produces is lost. I want to capture it into a variable.

I can NOT do:

    open (CMD, "|myCmd myArguments|") or die "no $!";
    $myVar = <CMD>;
-UHenq -Phenkie -s@ -w512  

wh
or something similar.

Can anyone point me towards a solution ?

-Henk


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

Date: Tue, 30 Sep 1997 06:14:59 GMT
From: gwynp_nouce@artware.qc.ca
Subject: Re: Perl Generator?
Message-Id: <3430988e.473300@news.videotron.ca>

On 27 Sep 1997 11:11:26 -0700, danny@lennon.postino.com (Danny Aldham)
wrote:

>jack (jss@mailzone.com) wrote:
>: I was wondering if anyone knows of a Perl generator where you either
>: use common, pre-written commands (drop & drag) or write simple
>: statements that are expanded into Perl modules?  I need to write some
>: Perl and am pretty much a neophyte.
>
>Sure, something like Visual Perl , soon to be release by MS. ;-)

You laugh... MS provided a lot of the money that went into the main
win32 port.

-Philip


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

Date: 29 Sep 1997 09:55:26 -0700
From: keradwc@mustang.via.net (Kevin Connery)
Subject: Re: Perl4 is *not* Y2K (was Re: Y2K)
Message-Id: <60omhu$ma5@mustang.via.net>

In article <342FA53B.6341C9DA@absyss.fr>, Doug Seay  <seay@absyss.fr> wrote:

>I learned to use perl back at 4.036, but that doesn't mean that I didn't
>drop it like a hot potato the minute perl5 came out.  Perl5 does more
>than Perl4.  Perl4 has security holes (many of which weren't know 3
>years ago) that have been fixed.  Perl has evolved and moved on to
>bigger and better things.  While pre-ANSI C compilers still exist, I
>don't recomend them for new development either.  Version 7 Unix was
>good, but I don't recomend it (if only because I've never heard of a
>port of Perl5 to Version 7 :-).
>
>Yes, one can use Perl4, but "can" doesn't imply "should".

Agreed. But that doesn't make it _dead_, either. A 1940's automobile
can still navigate the road effectively, even though it's not competitive,
nor as safe as the modern vehicles. *If used in the proper places*, it's
a reasonable alternative.

(Such reasonable places are for in-house use, where the costs of
upgrading [time], while low, are exceeded by the benefit: i.e., none
of the _current_ sysadmins know perl, but there's a large body of 
existing scripts from previous ones. Even the minor switch and
occasional/rare syntax change would cost time.

Now, for _new_ development, or _web_ or _cgi_, sure, Perl5 is the
best choice--the cost of doing it otherwise is extremely high compared
to using a set of modules. That doesn't make it unusable, or unsafe in
other environments.

>PS - I think you mean "objects" not "structures".  Hashes haven't
>changed in any way that I can remember.

Nope. "Structures": using references [scalars] in hashes or arrays
gives structure-like capabilities not available in v4. (Objects, too,
but I've not gotten that far myself.)

--kdc



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

Date: Mon, 29 Sep 1997 23:25:34 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Nadeem Rana <nrana@aludra.usc.edu>
Subject: Re: Reading each word from a file
Message-Id: <3430712E.CA5EBA9B@mail.earthlink.net>

Here's a nice, compact script:

#!/usr/bin/perl -n00
# The '00' enables reading a paragraph at a time
my($word, $meaning) = split ':';
$meaning =~ s/^\s*//gsm; # Strip all leading whitespace, if desired
open(FILE, ">$word") or die "Couldn't open $word: $!";
print FILE $meaning;
close FILE;



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

Date: Tue, 30 Sep 1997 03:53:33 +0100
From: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: Recursive object reader
Message-Id: <hr$09jAtmGM0Ewv5@worsdall.demon.co.uk>

Hi,

Has anyone got a perl script that will recurse through a directory
structure reading and displaying file objects last modifed date?

I would be grateful for an example.
-- 
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydee@worsdall.demon.co.uk  WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmaster@shadow.org.uk    WEB site:- http://www.shadow.org.uk


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

Date: 30 Sep 1997 06:21:08 GMT
From: mgjv@mali.comdyn.com.au (Martien Verbruggen)
Subject: Re: Recursive object reader
Message-Id: <60q5ok$219$1@comdyn.comdyn.com.au>

In article <hr$09jAtmGM0Ewv5@worsdall.demon.co.uk>,
	Mark Worsdall <jaydee@worsdall.demon.co.uk> writes:
> Hi,
> 
> Has anyone got a perl script that will recurse through a directory
> structure reading and displaying file objects last modifed date?
> 
> I would be grateful for an example.

The following code isn't optimised. It isn't even very clean or nice.
But I hope it gets the message across.

A lot of the code isn't necessary, and parts of it can be done faster
and more elegantly using grep/map and other functionality. I just
figured that you might prefer readable code.

--- SNIP ---
#!/usr/local/bin/perl5 -w

use strict;

process_dir($ENV{HOME});

exit 0;

sub process_dir
{
	my $DIR = shift;

	my @files = ();
	my @dirs = ();

	opendir(DIR, $DIR) or die "Cannot open dir $DIR: $!";

	while (defined(my $entry = readdir(DIR)))
	{
		# Skip . and ..
		next if $entry =~ /^\.{1,2}$/;

		# sort the files from the directories
		(-f "$DIR/$entry") and push(@files, $entry);
		(-d "$DIR/$entry") and push(@dirs, $entry);
	}

	closedir(DIR);

	foreach my $subdir (sort @dirs)
	{
		process_dir("$DIR/$subdir");
	}

	foreach my $file (sort @files)
	{
		my $mtime = (stat("$DIR/$file"))[9];
		# You might want to do some formatting of $mtime here
		print "$DIR/$file : $mtime\n";
	}
}
--- SNIP ---

You could move a lot out of the subroutine, by returning a list of
files from it, and storing that in the caller. Then doing the stat
processing in a loop outside of the subroutine.

I'll leave that to you.

Alternatively, you can use the File::Find Module:

--- SNIP ---
#!/usr/local/bin/perl5 -w

use strict;
use File::Find;

find(\&print_mtime, $ENV{HOME});

sub print_mtime
{
    my $file = "$File::Find::dir/$_";
    my $mtime = undef;
    
    -f $file 
	and 
    $mtime = (stat($file))[9] 
	and 
    print "$file : $mtime\n"
	;
}
--- SNIP ---

The stat is where it is to avoid doing a time consuming stat on
directories as well.

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


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

Date: Tue, 30 Sep 1997 00:41:33 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Syntax Question using regular expressions.
Message-Id: <comdog-ya02408000R3009970041330001@news.panix.com>

In article <34304d8a.25707272@news.zippo.com>, ramonr@earthlink.net (Ramon Rodriguez) wrote:

>I want to test a scalar variable to determine what kind of data it
>holds (numeric or alphabetic)  If it's alphabetic I want to print
>something out and exit the Perl script if it's numeric then do
>nothing.  I was told to use regular expression pattern matching using
>the /\D/ syntax but I don't know how to implement it in a simple if
>statement.

a simple line might look like:

   exit(0) if ( $test_string =~ m/[^0-9a-fA-F]/ );

in which case the exit() is invoked if the test succeeds (in this
case matches something that is not a hexadecimal digit).

for basic language questions, you might want to consult (or even
read completely) Learning Perl [1].

good luck :)

[1]
Learning Perl
Randal L. Schwartz & Tom Christensen
ISBN 1-56592-284-0. 
<http://www.oreilly.com>

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 30 Sep 1997 08:13:47 GMT
From: ben@reser.org (Ben Reser)
Subject: Re: week-of-the-year calculation
Message-Id: <3430b475.23707419@192.168.0.1>

On Mon, 29 Sep 1997 13:54:28 -0700, Tom Phoenix
<rootbeer@teleport.com> wrote:
>If the module doesn't come with tests which prove this, you should write
>some and send a patch to the author. :-)

But Tom, we should have to do any work. 
We just want to enjoy letting someoen else do it.

The author of this email is not responsible for any sarcastic comments
it might contain. :)

************************* IMPORTANT *************************
Why the new email address you ask?
Simple, I'm attempting to simplify the way I filter my mail.
Please direct all personal mail to ben@reser.org
Not directing personal mail to this address may cause
delays in me reading your mail or may even get it deleted.
************************ IMPORTANT *************************

---
Ben Reser <ben@reser.org>
http://ben.reser.org
	
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d-(+)@ s:- a-- C++++$ UBVC++++(++)$ P+++$>++++ L- !E---- W@ N(+)>++ o? K--? w++$@>+++ !O---- !M V PS+(++)@>+++ PE++(+++)@ Y+(++)@ PGP+(++)>+++ t+()@ 5 X !R tv-(+)@>-- b+(++)>+++ DI++ D G e h++ r-()>+++ y? 
------END GEEK CODE BLOCK------ 


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

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

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