[7147] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 772 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 24 16:18:08 1997

Date: Thu, 24 Jul 97 13:00:26 -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           Thu, 24 Jul 1997     Volume: 8 Number: 772

Today's topics:
     Re: A problem with references and bless (Charles DeRykus)
     Re: attack of little squares!  Help! <kluff@enterprise.net>
     Re: attack of little squares!  Help! <nik@ty.com>
     CGI Cookies != JavaScript Cookies.  ARRGH! <mark@sierra-inc.com>
     CGI href <allroy@wpi.edu>
     CGI.PM Form refreshing <gibsonc@aztec.asu.edu>
     CGI.pm Push & Javascript (Sean Dougherty)
     Re: DON"T Pay For $ex Site Entry (David Faciane)
     encryption <dev@sgi.net>
     Re: flock() function <rootbeer@teleport.com>
     Re: How to call a subroutine from a variable? (M.J.T. Guy)
     Re: Looking for a routine to trim white space  (like VB (Steve O'Hara Smith)
     Re: Looking for a routine to trim white space  (like VB <mark@sierra-inc.com>
     Re: Making an optional backreference (Tad McClellan)
     Memory usage <frederic@xilinx.com>
     Re: multi-dimensional arrays in PERL - solved (Dominic Feeley)
     Re: National Medal of Technology: Let's nominate Larry! <rootbeer@teleport.com>
     Re: Problem - Help <sibsib@hotmail.com>
     Re: problem searching w/ string ridden with metachars. (Tad McClellan)
     problem with perl homepage generator (Arielle Sumits)
     python envy ? (Bruce Dumes)
     Re: Question: About strings, replacements and collapsin <dsd@oar.com>
     questions re: a sendmail script <mbosley@games-online.com>
     Re: questions re: a sendmail script <rootbeer@teleport.com>
     Re: Reading one character unbuffered. Is there a better (Shawn Halpenny)
     Re: Req help: Any easy way to CRC a file? Steve_Kilbane@cegelecproj.co.uk
     Re: rlogin with Perl (Vasudev Dalal)
     The Most Dangerous Script on the NET silvern@vetrol.com
     turning off "<variable name> used only once" warning (+jeff)
     Re: Unix <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Jul 1997 17:40:25 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: A problem with references and bless
Message-Id: <EDu3rE.4v7@bcstec.ca.boeing.com>

In article <wkg1t6u4nf.fsf@RIDO.i-have-a-misconfigured-system-so-shoot-me>,
 <w.stanton@auckland.ac.nz> wrote:
:" > I am using a Hash of references to blessed objects like so...
 > 
 >    $self->{list}->{$design} = $evaluation;
 >    my $d;
 >    foreach $d (keys %{$self->{list}}){
 > 	print $d;
 > 	print "\t";
 > 	print ref $d;
 > 	print "\n";
 > 	print $design;
 > 	print "\t";
 > 	print ref $design;
 > 	print "\n";
 > 	print "\n" . $design->toString;
 > 	print "\n" . $d->toString;
 >     }
 > 
 > 
 > 
 > The output from the above is...
 > 
 > 
 > Design=HASH(0xb77bf0)
 > Design=HASH(0xb77bf0)   Design
 > 
 > x 0.1   y 2.9
 > 
 > Can't locate object method "toString" via package
 > "Design=HASH(0xb77bf0)" at Des ignCache.pm line 39.
 > 
 > 
 > $d and $design appear to be the same.
 > But ref $d != ref $design
 > 
 > When I try to bless $d (a C programmer trying to cast...) to Design as
 > bless $d, Design;
 > I get the error message 
 > Can't bless non-reference value at DesignCache.pm line 30.
 > 
 > But I can (re) bless $design.
 > 
 > Is there some magic I am missing with keys of Hash?
 > 

Once stringified and buried as a hash key, the original blessed 
reference is lost I believe. (maybe the Data::Dumper can retrieve
the ref. though. See CPAN)


Here's a possible workaround:

      $self->{list}->{$design} = [$design, $evaluation ];
      my $d;
      foreach $d (keys %{$self->{list}}){
         ....
   	 print ref @{$d}[0],"\n";    # replaces: ref $d 
   	 print @{$d}[0]->toString;   # replaces: $d->toString
         ....
      }


HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com


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

Date: Thu, 24 Jul 1997 18:31:21 +0100
From: Kevin Luff <kluff@enterprise.net>
To: Nik Trivedi <nik@ty.com>
Subject: Re: attack of little squares!  Help!
Message-Id: <33D79168.201A0E63@enterprise.net>

Don't want to point out the obvious, but your editor does save in plain
ascii doesn't it ?

Nik Trivedi wrote:

> My text data files always manage to insert lines and lines of little
> squares causing problems in my scripts - do any of you know where
> these
> squares come from?  I thought it was the RETURN character, but that is
>
> not it.  Any other ideas?





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

Date: Thu, 24 Jul 1997 14:26:25 -0500
From: Nik Trivedi <nik@ty.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: attack of little squares!  Help!
Message-Id: <33D7AC60.1666F528@ty.com>

thank you for your response!  Following is an excerpt from my script
that is causing me the problems .... I am not "moving files" per se -
the squares are developing from my script opening the file, amending and
closing.  I've tried all sorts of file locks and that does not seem to
have an effect either ... Please help!

   while(-f guestlock.lock){
      select(undef,undef,undef,0.1);
   }
   open(LOCK, ">guestlock.lock");
   open (STORAGE2, "$filename") || die "Can't open $filename: $!\n";
   flock (STORAGE2, 2);
   @GUESTBOOKLINES=<STORAGE2>;
   close (STORAGE2);
   flock (STORAGE2, 8);

   open (STORAGE, ">$filename") || die "Can't open $filename: $!\n";
   flock (STORAGE, 2);
   print STORAGE "<b>$FORM{'comments'}</b><br>";   if ($FORM{'url'}) {
      print STORAGE "\<a href=\"$FORM{'url'}\"\>$FORM{'userid'}\</a\>";
   }
   else {
      print STORAGE "$FORM{'userid'}";
   }
   if ( $FORM{'username'} ){
      print STORAGE " \&lt;<a href=\"mailto:$FORM{'username'}\">";
      print STORAGE "$FORM{'username'}</a>\&gt;";
   }
   print STORAGE "<br>";
   if ( $FORM{'city'} ){
      print STORAGE "$FORM{'city'},";
   }
   if ( $FORM{'state'} ){
      print STORAGE " $FORM{'state'}";
   }
   if ( $FORM{'country'} ){
      print STORAGE " $FORM{'country'}";
   }
   $date = `$date_command +"%A, %B %d, %Y"`; chop($date);
   $time = `$date_command +"%I:%M:%S %p (%Z)"`; chop($time);
   print STORAGE " - $date at $time<hr>\n\n";

   print STORAGE @GUESTBOOKLINES;
   undef @GUESTBOOKLINES;


   close (STORAGE);
   flock (STORAGE, 8);
   close(LOCK);
   unlink(guestlock.lock);

   exit;




Tom Phoenix wrote:

> On Thu, 24 Jul 1997, Nik Trivedi wrote:
>
> > My text data files always manage to insert lines and lines of little
>
> > squares causing problems in my scripts - do any of you know where
> these
> > squares come from?  I thought it was the RETURN character, but that
> is
> > not it.
>
> It sounds as if you might be moving files from one kind of machine to
> another, such as from a DOS/Windows machine to a Unix-type machine. If
>
> you're doing this via FTP, use a text transfer mode to properly
> convert
> the files.
>
> If that's not it, can you post a short (ten line) program which
> demonstrates what's happening? That would help all of us to know what
> you're talking about. Thanks!
>
> --
> Tom Phoenix           http://www.teleport.com/~rootbeer/
> rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
> Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/





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

Date: Tue, 22 Jul 1997 15:03:28 -0400
From: mark <mark@sierra-inc.com>
Subject: CGI Cookies != JavaScript Cookies.  ARRGH!
Message-Id: <33D50400.AB3@sierra-inc.com>

>I'm trying to write a script involving several frames in which data is >sent to a CGI function via a cookie.  (Since VRML is involved, this >eliminates the ability to use HIDDEN fields in normal POST operations). > Unfortunately, CGI cookies do not talk to JavaScript cookies and >vice-versa (don't know why; they should be passed along with the >content-type information).  My JavaScript cookies do speak to my other
>JavaScript applications and my CGI cookies do speak to other CGI's.
>
>Oddly enough, my cookies do not write themselves into my Netscape 3.0's >'cookies.txt' file.  Should this be happening?

I've received several emails doubting this is possible.  Below is a
script where I set a cookie in javascript & then attempt to read it with
a CGI:

Javascript:
--------------------------------------------------------
<HTML><HEAD><TITLE></TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!-- The script

function load_fn(){
  document.cookie = "my_cookie=chocolate_chip;expires=Wednesday,
23-Jul-97 23:59:59 GMT";
  alert("Cookie set");
}

// -->
</SCRIPT>

</HEAD>
<BODY OnLoad="load_fn()">

<P><A HREF="http://206.108.246.26/cgi-bin/c_in.cgi">To the
cookie</A></P>

</BODY></HTML>
--------------------------------------------------------

And this is the script I use to read it:
--------------------------------------------------------
#!/usr/bin/perl

print "Content-type: text/html\n\n";

print "The cookie:<P>";

print $ENV{"HTTP_COOKIE"};

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


I've also tried using the perl module 'CGI.pm'.  I've also tried with &
without 'expires' parameters on the cookie.  Although the above CGI
works fine for CGI written cookies, it ignores javascript ones.

Any idea how to make CGI and JavaScript like each other?  I'd appreciate
any emails on the subject.

Mark


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

Date: Thu, 24 Jul 1997 13:46:29 -0400
From: Tim McGilvreay <allroy@wpi.edu>
Subject: CGI href
Message-Id: <Pine.OSF.3.95q.970724133906.15375A-100000@wpi.WPI.EDU>

Hi,
	I am totally new to CGI and Perl so I was wondering if any of you
out there might be able to help me out.  The basic problem is that I am
trying to get a text link to refer to a CGI (this is not the problem), but
only a specific subroutine of the CGI.

for example:

<a href="something.cgi but only a specific subroutine">Link</a>

The answer is probably something simple, but experience is something I
lack.  If anyone can help out... thanks in advance.

Also...

Say I wanted one of the tasks of this particular subroutine to be opening
a document in an HTML frame.  For example:
I click on the "LINK" in some type of menu frame, and it changes the
document in the main frame.  I know this is simple in HTML, but have no
clue in Perl.  Any ideas...

please email
allroy@wpi.edu

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

				Tim McGilvreay


    "THOU SHALT NOT ALLOW ANYTHING TO DETER YOU IN YOUR QUEST FOR ALL!"


 	  _   _  
	 / `-' )         ,,, 
	 | IU U|||||||||[:::]
	 \_.-.(          '''




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

Date: Thu, 24 Jul 1997 09:36:24 -0700
From: Gip <gibsonc@aztec.asu.edu>
Subject: CGI.PM Form refreshing
Message-Id: <33D78488.247F@aztec.asu.edu>

After the user hits the 'submit' button, I want the browser to refresh
the form, not post the new form after it. (Based on what the user has
entered, I auto-fill the remaining portion of the form, but the new form
is posted after the old form) 

What do I have to do to do this?

(I've just started using CGI.PM on nt 3.51)

Thanks for your time.


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

Date: 24 Jul 1997 18:09:46 GMT
From: sean@cortex.ama.ttuhsc.edu (Sean Dougherty)
Subject: CGI.pm Push & Javascript
Message-Id: <5r85pa$al8$1@medulla.ama.ttuhsc.edu>

I'm trying to push a javascript every so often using cgi.pm.  And I'm not 
having much luck...  When I run the script, it loads, and there are no 
errors, the javascipt just doesn't run :(

When I run the script from the command line, I get all of the right 
information.  I'm so confused.

the basic script looks like

>#!/usr/local/bin/perl -w
>
>use CGI::Push qw(:standard :html3);
>
>do_push(-next_page=>\&show_mess,-delay=>30);
>
>sub show_mess {
>blah blah blah
>}

The funny thing is, if I edit the above to read...

>#!/usr/local/bin/perl -w
>
>use CGI::Push qw(:standard :html3);
>
>#do_push(-next_page=>\&show_mess,-delay=>30);
>print &show_mess;
>
>sub show_mess {
>blah blah blah
>}

then the information is displayed correctly, not pushed like I want, but 
displayed.

Anyone else try something like this?  Recognize the problem?  Any ideas 
would be appreciated.

thanks

sean
sean@cortex.ama.ttuhsc.edu


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

Date: 22 Jul 1997 00:27:18 -0400
From: dave@nws.fsu.edu (David Faciane)
Subject: Re: DON"T Pay For $ex Site Entry
Message-Id: <5r1cr6$sb3@kate.nws.fsu.edu>

What about @ex, %ex and regex?

:-)

-- 
David Faciane                 |web: http://www.nws.fsu.edu/~dave	 
NOAA National Weather Service |Real-Time Worldwide Marine Weather Reports 
Tallahassee, FL               |  http://www.nws.fsu.edu/buoy	 
Sender of unsolicited email agrees to pay $500 for my proofreading services. 


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

Date: Wed, 23 Jul 1997 11:07:06 -0400
From: Devin Anderson <dev@sgi.net>
Subject: encryption
Message-Id: <33D61E1A.4524@sgi.net>

I'm looking for a perl routine or module that will encrypt data with the
same DES that the system uses for authnication. Ant idea? I believe the
crypt() function is just the old crypt program. I need be to able to
authenticate users from a web site.

I just need the function.

Please cc any responce to dev@sgi.net.

Thanks!!

---								
Devin P. Anderson							
Webmaster, Systems Administrator					
Stargate Industries, Inc.	      
http://www.sgi.net/		
Phone: 412.930.STAR (7827) ext. 241	
F a x: 412.930.7110  					        	

This should clear up any confusion:
								
anti-match - v. To reverse the match process. Show all patterns that
                *DON'T* match.

-----PGP PUBLIC KEY AVAILABLE-----


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

Date: Thu, 24 Jul 1997 11:21:16 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: michel@saintrochtree.com
Subject: Re: flock() function
Message-Id: <Pine.GSO.3.96.970724111938.13627l-100000@kelly.teleport.com>

On Thu, 24 Jul 1997 michel@saintrochtree.com wrote:

> In my PERL 4 manual, I've poor information about the flock() function. 
> Where can I find more? 

When you install Perl 5.004 (if it's not installed already) you'll have
access to the perlfunc(1) manpage. If you have more questions after you've
read those docs, feel free to ask them here. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 21 Jul 1997 11:08:32 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: How to call a subroutine from a variable?
Message-Id: <5qvfvg$rkt@lyra.csx.cam.ac.uk>

Toutatis <toutatis@remove.this.toutatis.net> wrote:
>My code:
>
>use strict;
>foreach $var(@vars){
>   $subroutine = "check_$var";
>   &$subroutine($arguments);
>}
>
>strict complains it cannot use $subroutine as a subroutine reference.
>Ok, well how DOES this have to be written?

By saying "use strict;", you are saying that you wish not to use certain
Perl features which are sometimes considered undesirable.    In particular,
"use strict 'refs';" says to reject "symbolic references" such as in your
example.

If you change your mind and _do_ want to use these features, you can
use "no strict 'refs';", which removes the restriction for the duration
of the block in which the statement appears.   So:

 use strict;
 foreach $var(@vars){
    no strict 'refs';
    $subroutine = "check_$var";
    &$subroutine($arguments);
 }

will achieve the effect you want without losing checking for the rest of
the script.

For more information on symbolic references (aka soft references), see
perldoc perlref.   For more information on "use strict;" see perldoc strict.


Mike Guy


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

Date: 21 Jul 1997 10:53:51 GMT
From: sohara@mardil.elsevier.nl (Steve O'Hara Smith)
Subject: Re: Looking for a routine to trim white space  (like VB trim$)
Message-Id: <5qvf3v$sek$1@ns.elsevier.nl>

pk (pk@flexsol.co.nz) wrote:
: I am looking for a routine like the Visual Basic trim$() to trim leading and 
: trailing spaces from a string.  

	Try

($stripped) = $unstripped =~ /^\s*(\S.*\S)\s*$/;


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

Date: Tue, 22 Jul 1997 11:19:09 -0400
From: mark <mark@sierra-inc.com>
To: pk <pk@flexsol.co.nz>
Subject: Re: Looking for a routine to trim white space  (like VB trim$)
Message-Id: <33D4CF6D.3323@sierra-inc.com>

pk wrote:
> 
> I am looking for a routine like the Visual Basic trim$() to trim leading and
> trailing spaces from a string.
> 
> It must not remove embeded white space.  Looking at the Perl manual there does
> not seem to be one.
> 
> Has anyone written such a beast and if so could they either post it or e-mail
> me a copy.
> 
> Thanks.

pk wrote:
> 
> I am looking for a routine like the Visual Basic trim$() to trim leading and
> trailing spaces from a string.
> 
> It must not remove embeded white space.  Looking at the Perl manual there does
> not seem to be one.
> 
> Has anyone written such a beast and if so could they either post it or e-mail
> me a copy.
> 
> Thanks.

Actually, perl has quite a few neat functions to make string
manipulation quite easy (Perl's my language of choice when I have to
manipulate text!)

Let's say your text is in variable $text.  Then,

to remove whitespace to the left:

$text =~ s/^\s+//;

>translation: 
>s - do a search and replace operation
>^ - only concider the left side of the string
>\s - whitespace
>\s+ - one or more characters of whitespace
>/^\s+/ - search for one or more characters of whitespace at the start
>of the string.
>// - nothing
>s/^\s+// - search for one or more characters of whitespace at the start >of the string and replace them with nothing.

and to remove whitespace from the right:

$text =~ s/\s+$//;

>translation:
>as above, but a trailing $ means 'end of string' in the same way a
>leading ^ means 'start of string'.

Of course, if your string is stored in $_, you can simply use

s/^\s+//;

or

s/\s+$//;

Hope this helps!

Mark
---------------------------------------------------
Check out my cool site with CGI, Java & JavaScript games!
http://www.kitfox.com/index.htm


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

Date: Wed, 23 Jul 1997 18:10:29 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Making an optional backreference
Message-Id: <5136r5.e77.ln@localhost>


[ Please follow the usual Usenet custom of limiting your line lengths to
  70-72 characters.
]


Kevin Swope (obsidian@shore.net) wrote:

: I cant seem to make a backreference optional in a regex.  This is the sample code I'm
: experimenting on.  If I take out the '?', then the b is captured in $3, but then it cant be
: optional.  If I put in the '?' then it become optional and the whole string matches, but there
: is nothing in $3.  There must be a way.  By the way, the 'b' will probably be a larger string
: in practice- thats why I leave the parens in there when I add the '?'.  THANKS.


$TheString=~ s/((a).*?(b)?.*(c))/++++$1++++/x; 
                     ^
                     ^

Please do a word search for 'greedy' in the hundreds of pages of free
documentation that was included with the perl distribution.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 24 Jul 1997 11:59:15 +0100
From: Frederic RIVOALLON <frederic@xilinx.com>
Subject: Memory usage
Message-Id: <33D73582.9F29CDC4@xilinx.com>

Hi,

Is there a set of commands that will report the memory usage of a
command launched on a Unix system:

If in perl I have: system("myunixprogram");
How can I access to the memory that 'myunixprogram' grabs on my system?

I'm also looking for a way to identify the type of machine for a given
host. Is there a perl module that will tell me if 'thishost' is a
Sparc20 or an UltraSparc2...

If any idea please reply to my email address also: frederic@xilinx.com

Frederic Rivoallon



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

Date: 24 Jul 97 13:42:13 GMT
From: dfe@unixa.nerc-keyworth.ac.uk (Dominic Feeley)
Subject: Re: multi-dimensional arrays in PERL - solved
Message-Id: <33d75bb5.0@wltss01.nerc-wallingford.ac.uk>


Hi, I was advised to read man perllol ( or perlLoL )
which solved my problems. Thanks.

-- 
Dominic Feeley
CEH Computer Support, Wallingford





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

Date: Thu, 24 Jul 1997 11:25:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Richard K. Downer" <rkd7949@ballard.ca.boeing.com>
Subject: Re: National Medal of Technology: Let's nominate Larry!
Message-Id: <Pine.GSO.3.96.970724112151.13627m-100000@kelly.teleport.com>

On Thu, 24 Jul 1997, Richard K. Downer wrote:

> After reading the referenced web page regarding the National Medal of
> Technology, I doubt if Larry Wall qualifies. They're looking for people
> who have benefitted USA businesses, and what Larry did 1) benefits
> people world-wide, 2) doesn't provide any measureable cash to the USA,
> and worst of all 3) is free. They're looking for people who create jobs
> in the USA and bring money into the USA. Perl does neither (since
> everyone using Perl would use something else if Perl did not exist).

And Shakespeare didn't do anything important, because people who like his
plays would watch reruns of "Who's the Boss". :-D

> At least, that's how I think the judges will view a Larry Wall
> nomination, if past winners are any indication. 

You might be right on that count.

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 24 Jul 1997 14:12:50 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: Problem - Help
Message-Id: <33D79B22.4868ACA2@hotmail.com>

Afgin Shlomit wrote:
> if ($country_str == /[0-9]*/) {

1.  Change '==' to '=~'

2.  Anything will match '/[0-9]*/'.  You probably want to change the '*'
to a '+'.  ('*' means 0 or more; '+' means 1 or more.)

Scott

-- 
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net


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

Date: Wed, 23 Jul 1997 17:55:29 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: problem searching w/ string ridden with metachars.
Message-Id: <1526r5.s17.ln@localhost>

dcd@k12-dev.arc.nasa.gov wrote:
: The snippet of code below is supposed to search through the text from an
: html file (in $data), for a search string ($search_string) of more html
: text.  Previously I had the problem that the spacing of the text in
: $search_string was different than when it appeared in $data.  I had
: several helpful suggestions and fixed the problem by saying
:  $search_string =~ s/\s/\\s+/g; and $data =~ s/$search_string/$text/g;

:  It struck me that there were probably tons of other meta characters
: that could appear in $search_string, and so I added some lines to
: backslash them out.  But the resulting code below, which by my estimations
: should work, doesn't.  If anyone could figure out why and explain it to
: me, I'd be very grateful.


$search_string = quotemeta($search_string); # this wheel already exists  ;-)
                                            # see the perlfunc man page...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 24 Jul 1997 19:45:13 GMT
From: arielle@mit.edu (Arielle Sumits)
Subject: problem with perl homepage generator
Message-Id: <arielle-2407971548110001@olc-mac-12.mit.edu>


Hi,

I have the following code in a homepage generator. It is supposed to read
information in from a form which allows users to specify the names
('links') and urls of their 7 favorite web pages. Thus there are seven
inputs markes "link" and seven inputs marked "url". However, the perl
script never seems to recognize these inputs as empty, and always prints
"<h3>Links:</h3>" even if there are no links. Anyone have any idea why?

Thanks.

Arielle




      if (($INPUT{'link'} ne '') && ($INPUT{'url'} ne '')) {
         @links = &SplitParam($INPUT{'link'});
         @urls = &SplitParam($INPUT{'url'});
         if ($#links != $#urls) {
            &CgiDie('Error','Some links were not filled out correctly. 
Please go back and correct.');
         }
         print FILE "<h3>Links:</h3><ul type=square>\n";
         for ($i = 0; $i <= $#links; $i++) {
            print FILE "<li><a href=\"http://$urls[$i]\">$links[$i]</a>\n";
         }
         print FILE "</ul><p>\n";
      }


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

Date: 24 Jul 1997 17:15:42 GMT
From: dumes@hks.com (Bruce Dumes)
Subject: python envy ?
Message-Id: <5r82ju$css$1@argo.hks.com>

I've been doing some research on some "real life" perl vs. python 
comparisons.  I'm not sure there's any real point, because it still seems
to me that people who like perl will like perl and people who like python will
like python no matter what "evidence" is produced.  And I don't have
a real problem with this.  

What seems funny to me, though, is that in my studies, I see the python
groups constantly comparing python to perl to show why python is the one 
and true scripting language, but I rarely see perl afficianos saying that
anything python can do, perl can do better.

The general feeling I get is that the perl community says there's a place
for both.

Am I just seeing things from my own biased perspective (and I *am* a perl 
fan, by the way) or have others observed this?   Of course, I'm writing 
the perl group, so what does that prove? :-) 

Cheers!
Bruce

--
Bruce Dumes                     bad@ici.net  or dumes@hks.com
WWW Home Page                  http://www.ici.net/cust_pages/bad/bad.html
"Help, help, I'm being repressed.  Did you see him repressing me?"



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

Date: Wed, 23 Jul 1997 15:33:59 -0700
From: "Donald S. Dunbar" <dsd@oar.com>
Subject: Re: Question: About strings, replacements and collapsing white space
Message-Id: <33D686D7.50C8@oar.com>

I think this does what you want (at least it worked in a test I tried):

$searchstring=~s/\s+/\\s+/g;
$data=~s/$searchstring/$text/g;

dcd@k12-dev.arc.nasa.gov wrote:
> 
> I'm relatively new to Perl and have a somewhat complicated question
> (hopefully just complicated to explain and not to solve :) )....
> 
> I have a string ($data) that contains the contents of a text file, as
> well as a search string ($searchString) that I want to replace with
> $text in all instances (ie globally).  The problem arises that, as my
> search string could be rather lengthy, and not spaced the same as when
> it appears in $data, a straight $data =~ s/$searchString/$text/g won't
> work.  For example....
> 
> if my search string is..
> 
> 'this is a search string'
> 
>  ...and I want it to match...
> 
> '
> this    is
> a search
>    string'
> 
>  ....it won't do it unless I collapse the white space.  So that's what
> I did, with ($copy = $data) =~ s/\s+/ /g;  If I collapse both $data
> and $searchString this way, they match up just fine and I can make a
> straight replacement using a s///;  But here's the real problem
> (finally).  Since I plan to write $data back to a file, I don't want
> it's white space to be collapsed.  I need some way to un-collapse the
> white space after I've made the replacements, or find an entirely new
> way to do it.
> 
>   If you've been patient enough to read through all that I thank you,
> and would greatly appreciate any help you could give me.
> 
>  -Thanks a lot
>    David

D.S. Dunbar, Ph.D.  (dsd@oar.com)
Ocean Applied Research Ltd.
http://www.oar.com


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

Date: Thu, 24 Jul 1997 13:18:51 +0000
From: mbosley <mbosley@games-online.com>
Subject: questions re: a sendmail script
Message-Id: <33D75640.8C284711@games-online.com>

Hi all,

I am writing a script to parse a database and email people various information
from the database.  It doesn't actually work yet, but I would like to get some
feedback before I start:

Would sending messages out in 'bulk' overload sendmail and possibly crash the
system?  There will be between a 100 and 2000 messages sent at a time, about 4
to 5 times per month.

Which would be more efficient:
  use a socket call to sendmail
         or
  open(BLARG,"/usr/...../sendmail -? -??? |");  print BLARG $message; (if that
even works)
         or
  or some other way (maybe building a cue and sending 50 messages at a time?)

Any and all feedback is greatly appreciated, and, if possible, please cc to me
at mbosley@games-online.com

Thanks!!!

random


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

Date: Thu, 24 Jul 1997 11:29:41 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: mbosley <mbosley@games-online.com>
Subject: Re: questions re: a sendmail script
Message-Id: <Pine.GSO.3.96.970724112808.13627n-100000@kelly.teleport.com>

On Thu, 24 Jul 1997, mbosley wrote:

> Would sending messages out in 'bulk' overload sendmail and possibly
> crash the system?  

Hey, you're not going to be sending junk mail, are you? And isn't that a
question about sendmail? It doesn't seem to be about Perl. Hope this
helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 24 Jul 1997 16:29:22 GMT
From: rsh@sun38.humb.nt.com (Shawn Halpenny)
Subject: Re: Reading one character unbuffered. Is there a better way?
Message-Id: <EDu0Gz.6r2@sunsrvr6.cci.com>

On 24 Jul 1997 07:59:54 +0200, Ronald Fischer <rovf@earthling.net> wrote:
>Under Unix (Solaris 2.4), I use the following statement to get one
>character from the keyboard:
>    chop(
>      $c=
>        qx(
>                stty raw -echo; 
>                echo `dd if=/dev/tty bs=1 count=1 2>/dev/null`; 
>                stty -raw echo
>        )
>    );
>This is probably the worst way to do it. Although it works fine for my
>purposes, I would highly appreciate if someone could suggest a cleaner
>solution, or at least point out where to look for. 

Check out the Term::ReadKey module from your local CPAN.  It's very nice
for this sort of thing.

(Interesting solution, BTW).

-- 
Shawn Halpenny

"Let me explain the house rules.  Follow the rules, we'll get along
 like a house on fire."
                                            - "From Dusk Till Dawn"


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

Date: Tue, 22 Jul 1997 15:56:11 GMT
From: Steve_Kilbane@cegelecproj.co.uk
To: Brian@dkonline.com
Subject: Re: Req help: Any easy way to CRC a file?
Message-Id: <7167cd$f38b.2cd@news.cegelecproj.co.uk>

[ Copy mailed ]

In article <33d4b1ee.4384805@pub.news.uk.psi.net>, Brian@dkonline.com (Brian - DKOnline) writes:
>There's probably a module
> out there that will generate a Cyclic Redundancy Check number or
> signature for a file if only I can find it.

Perl's unpack has this built in. See the "%number" conversion.
-- 
<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: 24 Jul 1997 09:07:16 GMT
From: vkd0871@omega.uta.edu (Vasudev Dalal)
Subject: Re: rlogin with Perl
Message-Id: <5r7604$jot@news.uta.edu>

Beth Azzi (bethazzi@ncsa.uiuc.edu) wrote:
Hello :

: I need to write a script to log into 30 different accounts and do
: something to all of them.  The password for all 30 accounts is the
: same.  At the beginning of the script, the password will be entered by
: STDIN.
: 

Looks like a job for Expect.
Also might want to check out 
http://www,dejanews.com
And search for what you want.

Vasu


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

Date: Mon, 21 Jul 1997 22:47:57 -0400
From: silvern@vetrol.com
Subject: The Most Dangerous Script on the NET
Message-Id: <33D41F5D.57C3@vetrol.com>

Please let me know where to find 
"The most dangerous script on the net"


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

Date: 24 Jul 1997 17:55:40 GMT
From: gt5146c@acmez.gatech.edu (+jeff)
Subject: turning off "<variable name> used only once" warning
Message-Id: <5r84us$955@catapult.gatech.edu>

	I've looked every I can think of but can't seem to figure out
how to do this, any ideas?

+jeff


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

Date: Mon, 21 Jul 1997 22:18:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: silvern@vetrol.com
Subject: Re: Unix
Message-Id: <Pine.GSO.3.96.970721220404.24293I-100000@kelly.teleport.com>

On Mon, 21 Jul 1997 silvern@vetrol.com wrote:

> Subject: Unix

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> Im looking for a script to run unix commands from a form input.

Which commands do you want to run? 'rm -rf * /' or '/bin/cat
>>/etc/passwd'? This is like going into a pharmacy and saying you want
something which you could swallow. Please consider this message a free
sample of Syrup of Ipecac. :-)

> PLEASE if you know where to find "The most dangerous script on the NET",
> PLEASE(I stress) let me know where to find it

I don't know. You sound dangerous enough already. If your system
administrator or webmaster can't (or, more likely, won't) help you find
the script you want, you could look for it with one of the umpteen search
engines out there. But for your own sake, as well as the sake of anyone
who shares your machinery and net connection, at least make sure you
understand the web and CGI security FAQs before you go installing any
scripts.

    http://www.genome.wi.mit.edu/WWW/faqs/www-security-faq.html
    http://hoohoo.ncsa.uiuc.edu/cgi/security.html
    http://www.yahoo.com/text/Computers_and_Internet/Internet/
	World_Wide_Web/Security/

I wish you good luck.

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

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

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