[17030] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4442 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 27 09:05:41 2000

Date: Wed, 27 Sep 2000 06:05:17 -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: <970059916-v9-i4442@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 27 Sep 2000     Volume: 9 Number: 4442

Today's topics:
        [Inform] Help me obfuscate this some more... (Jonadab the Unsightly One)
        [OT] Re: Salary Range for Perl Programmers <nico@monnet.to>
        [Q]Perl CGI on Netscape enterpirse server 3.0 failed <gokkog@yahoo.com>
        CGI C Program output ppvm@my-deja.com
    Re: CGI C Program output (Bernard El-Hagin)
    Re: CGI C Program output nobull@mail.com
        File::Find problem noodle42@my-deja.com
    Re: File::Find problem nobull@mail.com
    Re: foreach two elements at a time? <bart.lateur@skynet.be>
    Re: freeware perl script to binary... <bart.lateur@skynet.be>
    Re: How can I combine regular expressions? (Philip Lees)
    Re: How can I combine regular expressions? <ter@my-deja.com>
    Re: Install Problem with Win98 <anders@wall.alweb.dk>
    Re: Install Problem with Win98 <ter@my-deja.com>
        java/perl lingo <tguirado@iterra-team.com>
        looking for a  mail form handler script thats works wel <Master@sdswebspace.com>
    Re: looking for a  mail form handler script thats works <anders@wall.alweb.dk>
        mail-module <erik@bid2day.no>
    Re: mail-module <mari@civil.columbia.edu>
        Module load error <waqar.hafiz@ing-barings.com>
    Re: Module load error <anders@wall.alweb.dk>
    Re: MySQL vs. mSQL <bart.lateur@skynet.be>
    Re: MySQL vs. mSQL (Anthony Peacock)
        Newbie needs help with s/// script. (Neil Watson)
    Re: Newbie needs help with s/// script. (Bernard El-Hagin)
    Re: Newbie needs help with s/// script. <anders@wall.alweb.dk>
        Newbie windows perl question tayloremail@netscapeonline.co.uk
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 27 Sep 2000 08:52:23 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: [Inform] Help me obfuscate this some more...
Message-Id: <39d0ca41.23030161@news.bright.net>


Well, the 5th Annual Obfuscated Perl Competition doesn't seem to
have a category that's appropriate for this, so I have decided to
put forward what I have here and now, and perhaps some other,
equally demented people can help me improve it.  At this point
I can get a minimal introductory transcript in both languages,
but I haven't added any grammar lines yet.  At minimum I'd like 
to enable the player to "write entry" and get some kind of 
concluding game-over message.  (I put in FinishSub as a 
tenative verb for this...)

I can't figure out how to give the objects a hardware short
name without getting a syntax error in Perl.  I tried playing
with $" (concluding the HSN with $), but it doesn't appear to 
solve the matter.  A piece of genius is still missing here.
I also haven't figured out how to include an embedded routine,
and philosophically it would be a shame not to have at least
one before rule or somesuch.

Also, some of this code is entirely too obvious and needs 
some additional obscurity.  Particularly the Perl code;
I don't mind that the Inform code is straightforward,
but I'd like to hide the Perl code better.  In addition, 
Inform gives two (non-fatal) compiler warnings.  They don't 
impede any functionality, but on principle I'd like to find 
a way to clear them up anyway.  TIA for any assistance.

Anyway, here's what I have so far...  apologies if a few
lines get broken in the process of posting, but you should
be able to figure out where.  (Right before "your entry"
and right before s/\^/\n/g and right before "that compiles"
are the only extra line breaks I see at the moment and 
can't prevent...)

#ifdef Perl; "
"; !"; sub Constant ($) {}; sub Headline ($) { $x=$_[0]; $x =~
s/\^/\n/g; print $x; } sub Story ($) { print $_[0]; } #"
#endif;

Constant Story "Obfuscated Perl Competition";
Constant Headline "^An interactive adventure in source-code
obscurity.^";

#Include "Parser";  Constant Code  "Just Another Inform Hacker
";!"; sub with (@) { return @_; }  "who really, really ought
  !"; sub Object (@) { }           "to know better than
  !"; sub EmptyRoom {} sub Desk {} "this sort of outright
  !"; sub initial { print "\n$_[0]\n"; } "abuse of comments.
  !"; sub description { print "\n$_[1]\n$_[0]\n"; } "
  !"; sub short_name {} sub has($) {};

Object EmptyRoom 
  with
    description
         "The walls are white.",
    short_name "EMPTY ROOM",
  has light;

Object Desk
EmptyRoom
  with
    initial
         "This is the desk where you are supposed to be working on
your entry
for the Obfuscated Perl Competition.  But your mind keeps slipping
back to that text adventure you were working on before...",
    short_name "Desk",
  has static;


#Include "VerbLib"; [ Initialise; location = EmptyRoom; ];


#Include "Grammar"; [ FinishSub; deadflag=2; "You write an entry 
that compiles in both Perl and Inform.
      "; ];
end;

";


--

Forward all spam to uce@ftc.gov


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

Date: Wed, 27 Sep 2000 10:57:45 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: [OT] Re: Salary Range for Perl Programmers
Message-Id: <JKiA5.85$S3.2876@tengri.easynet.fr>

What the fuck was steveko@home.com trying to say:
> I have a performance review Thursday 9/28/00 and my supervisor asked me
> to come up with a suggested raise. I'm highly valued at my company and
> have been involved with many of the key projects here. He pretty much
> said something along the lines of he'll try to get me whatever I ask
> for, but of course I'd like to come up with a fair and realistic figure.
> 
> I'm located in San Diego. I started at 50,000 and have just completed my
> first year there. Any suggestions on how much I should ask for?
> 
> P.S. I'm also looking for someone who would be interested in helping me
> improve my Perl coding techniques. I'm completely self taught and
> probably do quite a few things sloppily. This should be a very easy task
> for advanced Perl programmers. If you have a PayPal account and might be
> interested, please send me email to steveko@home.com
> 
> Thanks,
> 
> Steve


Hey I have 5 years of experience in Perl! I have even have a JAPH
(or somesuch) in my .sig! (vvv there) 

Ok on the downside I waste my time making stupid posts on
Usenet instead of working; how much do you think I'm worth?


-- 
perl -e 'print `echo Just a Lame Perl Luser | gzip -9 | cat | gzip -cd`'



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

Date: Wed, 27 Sep 2000 17:49:22 +0800
From: "Wenjie Zhao" <gokkog@yahoo.com>
Subject: [Q]Perl CGI on Netscape enterpirse server 3.0 failed
Message-Id: <8qsfta$n59$1@bt02e2.god.bel.alcatel.be>

Hello,


We have an application with many cgi scripts written in Perl.
We have tested it under Apache web server.
Now the targeted platform changed to Netscape Enterprise
Server 3.0, Some strange thing happened:

Some cgi scripts work fine while others failed. the Logs
say that "cannot print a valid header". We thought it's related
to our own ParamConfig.pm used in the cgi scripts. After
renaming this module, some other disturbing words tell
redefined of New ...Exporter...

Does somebody have a clue for the problem?

P.S. I checked Netscape's web site, it says this (cannot print
a valid header) may be due to dependencies on external
libraries, I tried their solution(absolute lib path), but it won't work.


TIA,

Wenjie ZHAO





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

Date: Wed, 27 Sep 2000 10:23:16 GMT
From: ppvm@my-deja.com
Subject: CGI C Program output
Message-Id: <8qshqi$inq$1@nnrp1.deja.com>



Hi all !

	I am a computer science student. I´m trying to do a
cgi program in C language and i have a problem. I would thank you
a lot if you could help me.

	For example, I have this program:



#include <stdio.h>
int i,j;
main()
{
    int x;
    printf("Content-type: text/html\n\n");
    printf("<HTML><HEAD><TITLE>Title</TITLE></HEAD>\n");
    printf("<BODY>\n");
    printf("First Line\n");
    sleep(3);
    printf("Second Line\n");
    printf("</BODY></HTML>\n");
    exit(0);
}

If I execute this program from Unix shell (my server is a
Sparc Sun Solaris) it prints (besides the HTML tags),
"First Line", waits three seconds and then prints "Second Line".
Just what I want. But if I execute it like a cgi program, I mean,
calling it from a browser, it waits three seconds and then,
only when the program finishes, the browser shows both messages
at the same time, "First Line" and "Second Line". I would like
that it worked like from Unix shell.

How can I do this?


Thanks in advance.


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


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

Date: 27 Sep 2000 10:51:41 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: CGI C Program output
Message-Id: <slrn8t3k9s.41b.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 27 Sep 2000 10:23:16 GMT, ppvm@my-deja.com <ppvm@my-deja.com> wrote:
>
>
>Hi all !
>
>	I am a computer science student. I´m trying to do a
>cgi program in C language and i have a problem. I would thank you
>a lot if you could help me.

By no stretch of the imagination could anyone consider this a Perl
question.

Cheers,
Bernard
--
perl -le 'open JustAnotherPerlHacker,""or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: 27 Sep 2000 12:31:44 +0100
From: nobull@mail.com
Subject: Re: CGI C Program output
Message-Id: <u94s329ilb.fsf@wcl-l.bham.ac.uk>

ppvm@my-deja.com writes:

> I´m trying to do a cgi program in C language and i have a problem.

Would that be a problem with the spelling of 'C' or with the spelling
of 'CGI'?  You seem to think one of them is P-E-R-L.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 27 Sep 2000 10:23:54 GMT
From: noodle42@my-deja.com
Subject: File::Find problem
Message-Id: <8qshrm$inu$1@nnrp1.deja.com>

Hello,

I'm having a weird problem with File:Find (at least, I think it's
weird). I've written a small utility to catalog files in a directory
recursively.

This is the main part of that code :

:
:
:
find(\&getFileInfo, $dir);


sub getFileInfo
{
  my $file = $_;

  if(-d $file)
  {
    print ("Directory : $file\n");
  }
  else
  {
     # process file
	:
	:
	:
  }
}

Now, when I run this program on a regular ext2fs directory I get this :

Directory : MyDirectory
Adding File1
Adding File2
Adding File3
Directory : MyOtherDirectory
Adding File1
Adding File2

and so on..

However, the files I need to catalog is on a CD, so I change to my
mounted directory and run the program - now I get this :

Directory : MyDirectory
Directory : MyOtherDirectory

That is, suddenly I don't get any notification of the files in the
directories (or subdirectories for that matter).

I've tried running the program as root - same thing.

What gives?



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


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

Date: 27 Sep 2000 12:29:10 +0100
From: nobull@mail.com
Subject: Re: File::Find problem
Message-Id: <u966ni9ipl.fsf@wcl-l.bham.ac.uk>

noodle42@my-deja.com writes:

> However, the files I need to catalog is on a CD...

> That is, suddenly I don't get any notification of the files in the
> directories (or subdirectories for that matter).

Try setting $File::Find::dont_use_nlink

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 27 Sep 2000 11:49:35 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: foreach two elements at a time?
Message-Id: <uln3ts4uc4jctsjfspv6v0defa3bf4qbf8@4ax.com>

Uri Guttman wrote:

>  A> Huh? What's wrong with lexical $a and $b?
>
>  A> I fail to see a problem here.
>
>poor style. IMO.
>
>in general i eschew single letter var names.

In particular $a and $b. These seem to shout "sort sub!" at me.

-- 
	Bart.


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

Date: Wed, 27 Sep 2000 11:09:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: freeware perl script to binary...
Message-Id: <tbl3tso1cs0m6agtvnhvqssh350b42npfl@4ax.com>

Paul Spandler wrote:

>I find it difficult to justify spending $149 for a simple hack.

Are you talking about perl2exe, or about your script?

-- 
	Bart.


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

Date: Wed, 27 Sep 2000 09:17:14 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: How can I combine regular expressions?
Message-Id: <39d1b599.71634545@news.grnet.gr>

On 26 Sep 2000 12:26:17 -0500, Ren Maddox <ren.maddox@tivoli.com>
wrote:

>It might be a reasonable optimization to simply "not care" about what
>the two-letter combinations are:
>
>$line =~ s/\b([A-Z])([A-Z])(?=[a-z]|\W)/$1\l$2/g;
>
>Then you don't need the list of possibilities.

That's brilliant - I was in the proverbial wood of vision-obstructing
trees.

Thanks also to others who responded and helped me to develop my regex
skills.

Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


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

Date: Wed, 27 Sep 2000 12:40:41 GMT
From: Tim Richardson <ter@my-deja.com>
Subject: Re: How can I combine regular expressions?
Message-Id: <8qsps9$ohk$1@nnrp1.deja.com>



> By the way, I'm becoming increasingly impressed by the awesome power
> of Perl for these tasks. The above lines of code replace a whole
> string of nested IF blocks within a loop that were needed in the
> language the routine was originally written in.
>

You are impressed by the power of regular expressions.  Perl is a highly
convenient host to this power.

--
Tim Richardson (search string: qweeblebeast)


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


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

Date: Wed, 27 Sep 2000 12:35:19 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Install Problem with Win98
Message-Id: <O4kA5.2935$T3.155098@news000.worldonline.dk>

Ben Ben wrote:

> I installed PWS on Win98.
> I installed ActivePerl 5.18 on Win98.
> I also installed dcom98.exe and dcm95cfg.exe.
> And I modified
> 
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\Script
> 
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\Script
> Map\.pl into c:\perl\bin\perl.exe %s %s
> Somehow, it doesn't work. When I try to see test.pl, the brower just say
> that "waiting
> reply ..." I tryed "perl test.pl" in command line and it works.
> I installed perl on Win95 in this way and it works correctly.
> What's the problem?

Windows.

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Wed, 27 Sep 2000 12:36:49 GMT
From: Tim Richardson <ter@my-deja.com>
Subject: Re: Install Problem with Win98
Message-Id: <8qspl2$oe3$1@nnrp1.deja.com>

In article <hP6A5.2778$rr.47675@vixen.cso.uiuc.edu>,
  "Ben Ben" <idleisidle@usa.net> wrote:
> I installed PWS on Win98.
> I installed ActivePerl 5.18 on Win98.
> I also installed dcom98.exe and dcm95cfg.exe.
> And I modified
>
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\Sc
ript
> Map\.pl
> into c:\perl\bin\perl.exe %s %s
>

Try using quotes, eg
c:\perl\bin\perl.exe "%s" %s

or even
c:\perl\bin\perl.exe "%s" "%s"

--
Tim Richardson (search string: qweeblebeast)


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


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

Date: Wed, 27 Sep 2000 10:11:58 +0200
From: "T. GUIRADO" <tguirado@iterra-team.com>
Subject: java/perl lingo
Message-Id: <8qsab1$mk$1@s1.read.news.oleane.net>

Hy all !!!

Iam looking for informations about JPL Java/perl lingo.
If anyone used it already, i would be glad to know how todo it
Any documentation will ba appreciated ...
Tks in advance ...

T. GUIRADO
ITERRA TEAM
tguirado@iterra-team.com





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

Date: Wed, 27 Sep 2000 05:51:46 -0400
From: "MASTER" <Master@sdswebspace.com>
Subject: looking for a  mail form handler script thats works well with win2k?
Message-Id: <iojA5.30784$Z2.450721@nnrp1.uunet.ca>

I'm new to Perl, and having problems getting my feedback form page working
properly to send me the form by e-mail.  I've tried some scripts and non
seem to work, ?   Also for some reason  the .pl file that I have mapped to
c:/perl/bin/perl.exe    in my web properties, when a .pl script runs it
looks for it in c:/SITES  and I don't have it mapped there?

CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:


Can't open perl script "C:\SITES": No such file or directory

any help would be greatly appreciated  thanks.....

Shane Sauve
www.sdswebspace.com






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

Date: Wed, 27 Sep 2000 13:19:00 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: looking for a  mail form handler script thats works well with win2k?
Message-Id: <LJkA5.2774$Pf.165463@news010.worldonline.dk>

MASTER wrote:

> I'm new to Perl, and having problems getting my feedback form page working
> properly to send me the form by e-mail.  I've tried some scripts and non
> seem to work, ?   Also for some reason  the .pl file that I have mapped to
> c:/perl/bin/perl.exe    in my web properties, when a .pl script runs it
> looks for it in c:/SITES  and I don't have it mapped there?
> 
> CGI Error
> The specified CGI application misbehaved by not returning a complete set
> of HTTP headers. The headers it did return are:
> 
> 
> Can't open perl script "C:\SITES": No such file or directory
> 
> any help would be greatly appreciated  thanks.....
> 
> Shane Sauve
> www.sdswebspace.com
> 
> 
> 
> 

Is this a perl question? It seems that you should try a ng for your server 
coftware, or for CGI.

Recommendation: don't run webservers on windows systems...

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Wed, 27 Sep 2000 14:34:18 +0200
From: "Erik Pedersen" <erik@bid2day.no>
Subject: mail-module
Message-Id: <gPlA5.1039$o9.16293@news1.online.no>

Hi,

I wonder if anyone know where I can get a mail module so I can make a "tip a
friend of this site" function.

I'm sure that it excists a module for mailing in Perl.

Regards
Erik




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

Date: Wed, 27 Sep 2000 08:46:45 -0400
From: mari <mari@civil.columbia.edu>
Subject: Re: mail-module
Message-Id: <Pine.LNX.4.10.10009270844280.25416-100000@civil.columbia.edu>

On Wed, 27 Sep 2000, Erik Pedersen wrote:

> I wonder if anyone know where I can get a mail module so I can make a "tip a
> friend of this site" function.
> 
> I'm sure that it excists a module for mailing in Perl.

There are lots in the MAIL dir of the www.cpan.org module repository. 

I use MAIL::Sender which requires some other modules as well.. 
http://jenda.krynicky.cz/ 

But you will have to get additional modules from cpan.

m.



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

Date: Wed, 27 Sep 2000 10:23:03 +0100
From: Waqar Hafiz <waqar.hafiz@ing-barings.com>
Subject: Module load error
Message-Id: <39D1BC77.BDCAC2EA@ing-barings.com>

I'm trying to run a perl script and getting the following error:

Can't load module DBI, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the DBI module statically linked into it.)
 at /usr/local/lib/perl5/smg/DBI.pm line 158
BEGIN failed--compilation aborted at /usr/local/lib/perl5/smg/DBI.pm
line 158.
BEGIN failed--compilation aborted at
/users/u2/wahaf/perltest/CRMGridAPI.pm line 29.
BEGIN failed--compilation aborted at ./CRMGridInt.pp line 68.

Can some one please tell me how to overcome this problem without
recompiling perl.

Regards
Waqar



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

Date: Wed, 27 Sep 2000 13:09:37 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Module load error
Message-Id: <YAkA5.2772$Pf.165335@news010.worldonline.dk>

Waqar Hafiz wrote:

> I'm trying to run a perl script and getting the following error:
> 
> Can't load module DBI, dynamic loading not available in this perl.
>   (You may need to build a new perl executable which either supports
>   dynamic loading or has the DBI module statically linked into it.)
>  at /usr/local/lib/perl5/smg/DBI.pm line 158
> BEGIN failed--compilation aborted at /usr/local/lib/perl5/smg/DBI.pm
> line 158.
> BEGIN failed--compilation aborted at
> /users/u2/wahaf/perltest/CRMGridAPI.pm line 29.
> BEGIN failed--compilation aborted at ./CRMGridInt.pp line 68.
> 
> Can some one please tell me how to overcome this problem without
> recompiling perl.
> 
> Regards
> Waqar
> 

Install a binary distribution (almost all rpm based dists provide them)

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Wed, 27 Sep 2000 11:14:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: MySQL vs. mSQL
Message-Id: <vel3tss8mrnigj46lp8vcq8ob2asmklkem@4ax.com>

Michael Satkevich wrote:

>Is MySQL better than mSQL?  I see more books and references to MySQL, so I
>am beginning to think I should be using MySQL.
>
>So far I have used mSQL on 2 sites.  Should I switch to MySQL?

Wrong reason. But I vaguely remeber having read that MySQL at least
started out as an improved mSQL. So that could be a reason to switch,
yes.

>Is another free database even better?  PostGre??

PostGreSQL has transactions. MySQL does not. If it's important that your
data remains integer while being updated by more than just a few people
simultaniously, that probably will matter. MySQL is said to be faster.

   HTH,
   Bart.


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

Date: 27 Sep 2000 12:07:43 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: MySQL vs. mSQL
Message-Id: <8qsnuf$ir6$1@uns-a.ucl.ac.uk>

In article <vel3tss8mrnigj46lp8vcq8ob2asmklkem@4ax.com>, 
bart.lateur@skynet.be says...
>
>Michael Satkevich wrote:
>
>>Is MySQL better than mSQL?  I see more books and references to MySQL, so I
>>am beginning to think I should be using MySQL.
>>
>>So far I have used mSQL on 2 sites.  Should I switch to MySQL?
>
>Wrong reason. But I vaguely remeber having read that MySQL at least
>started out as an improved mSQL. So that could be a reason to switch,
>yes.

My understanding is that Monty, the original mySQL author, was using mSQL 
found problems and sent a fairly detailed report to the developer of mSQL.  
It was the complete lack of response from the mSQL developers that led him 
to write his own.

When I was using mSQL it was the complete lack of support that really got to 
me.  It may have improved now, but it is too late for me, I am very happy 
with mySQL for my work.  The response time from the mySQL mailing list is 
phenomenonal.



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

Date: Wed, 27 Sep 2000 12:36:58 GMT
From: neilwSPAMTHIS@idirect.com (Neil Watson)
Subject: Newbie needs help with s/// script.
Message-Id: <39d1e936.5255096@bigmomma.idirect.com>

I have an HTML file that contains much text and numbers.  I want to:

Search for	Replace with
-1500		-6
-1250		-5
-1000		-4
 ...
 ...
750		3
1000		4
etc...

My script is called points.  I run "./points talents.html".  an no
errors are returned but, no substitution has be performed.  My script
is below:

#!/usr/bin/perl -w     
                       
$new=-6;               
$old=-1500;            
                       
                       
while (<> && $new<6) { 
    $_=<>;             
    s/$old/$new/g;     
                       
    $new=$new+1;       
    $old=$old+250;     
                       
}

I'm sure it's something simple.  I've gone through alot of
documentation but, I'm missing something.

Please help.
Neil Watson
webhome.idirect.com/~neilw


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

Date: 27 Sep 2000 12:45:13 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Newbie needs help with s/// script.
Message-Id: <slrn8t3qun.41b.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 27 Sep 2000 12:36:58 GMT, Neil Watson
<neilwSPAMTHIS@idirect.com> wrote:
>I have an HTML file that contains much text and numbers.  I want to:
>
>Search for	Replace with
>-1500		-6
>-1250		-5
>-1000		-4
>...
>...
>750		3
>1000		4
>etc...
>
>My script is called points.  I run "./points talents.html".  an no
>errors are returned but, no substitution has be performed.  My script
>is below:
>
>#!/usr/bin/perl -w     
>                       
>$new=-6;               
>$old=-1500;            
>                       
>                       
>while (<> && $new<6) { 
>    $_=<>;             

This is wrong. You're actually reading every second line since you're
using the <> operator twice here (first time in the while, which
implicitly writes to the $_ variable, and the second time you explicitly
use it in the assignment). Just skip the '$_=<>;', $_ will hold each
line anyway.

>    s/$old/$new/g;     
>                       
>    $new=$new+1;       
>    $old=$old+250;     

You can write these faster using:

	$new++;
	$old += 250;

>                       
>}
>
>I'm sure it's something simple.  I've gone through alot of
>documentation but, I'm missing something.

You're not writing the results anywhere. If you want to change the file
you have to either use the -i switch or the special variable $^I (read
about them first, because they make it oh-so-easy to ruin your files)
and then 'print' the results after the substitution.

perldoc perlrun

or

perldoc perlvar

Cheers,
Bernard
--
perl -le 'open JustAnotherPerlHacker,""or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: Wed, 27 Sep 2000 14:53:11 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Newbie needs help with s/// script.
Message-Id: <26mA5.2972$T3.156623@news000.worldonline.dk>

Neil Watson wrote:

> I have an HTML file that contains much text and numbers.  I want to:
> 
> Search for    Replace with
> -1500         -6
> -1250         -5
> -1000         -4
> ...
> ...
> 750           3
> 1000          4
> etc...
> 
> My script is called points.  I run "./points talents.html".  an no
> errors are returned but, no substitution has be performed.  My script
> is below:
> 
> #!/usr/bin/perl -w
>                        
> $new=-6;
> $old=-1500;
>                        
>                        
> while (<> && $new<6) {
>     $_=<>;
>     s/$old/$new/g;
>                        
>     $new=$new+1;
>     $old=$old+250;
>                        
> }
> 
> I'm sure it's something simple.  I've gone through alot of
> documentation but, I'm missing something.
> 
> Please help.
> Neil Watson
> webhome.idirect.com/~neilw

the statement
$_ = <>;
should be removed. The while statement reads one line into $_ for each 
iteration, so you skip lines 0,3,5 etc, since you read in one more line.

You could try to change the while condition:
while <> {
    last unless $new < 6;
 ...

But, I guess that you actually want to change *all* numbers (-1500 -1250 .. 
1500)??

#You can leave out the labels, they are only there for clarity...
LINE: while (<>) {
    my $n = 1500;
    NUMBER: while ($n >= -1500) {
        s#$n#abs($n/250)#eg;
        $n -= 250;
    }
}


-anders
-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Wed, 27 Sep 2000 12:44:06 GMT
From: tayloremail@netscapeonline.co.uk
Subject: Newbie windows perl question
Message-Id: <8qsq2l$ojg$1@nnrp1.deja.com>

Hi all.
I am attempting to teach myself perl, and have found a simple form
tutorial that emails form data to a recipient specified on the form.
I am using a windows 98 box, with ActivePerl build 618 installed.
I have executed the test script which worked successfully.


The form HTML follows -

<form action="C:/Program files/perl/mystuff/mailform.pl" method=GET>
<input name="to" type="hidden" value="johnsonb">
<b>To:</b> <code>johnsonb@ncsa.uiuc.edu</code>
<br>
<b>Subject:</b> <input name="subject" size=40>
<br>
<b>Comments:</b>
<br>
<textarea name="comments" ROWS=8 COLS=60></textarea>
<br><input type="submit" value="Send">
</form>


The perl script is called "mailform.pl" and is below -

#! ./perl
# mailform - a simple CGI program to email the contents of an HTML
#  form to a specified user.
#
########################################################################
##
# Configuration parameters
########################################################################
##
# this program's name
$progname = "mailform";
# the sendmail binary.
$sendmail = "C:/windows/system/sendmail";

#base of your httpd installation.
$basedir = 'C:/';
#log file
$logfile = "$basedir/Program files/Perl/logs/$progname.log";

# today
$date = `date`;
chop($date);
# begin CGI output
print("Content-type: text/html\n\n");
########################################################################
##
# Process Query
########################################################################
##
@cgiPairs = split("&",$ENV{'QUERY_STRING'});
foreach $pair ( @cgiPairs ) {
($var,$val) = Split("=",$pair);
#trust me on this magic
$val =~ s/\+/ /g;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$cgiVals{"$var"} = "$val";
}
$recipient = $cgiVals{"to"};
#define an error routine:
sub error {
($message) = @_;
print("<b>ERROR:<b>",$message,"<p>Contact the author of the previous
page for assistance\n");
exit(0);
}
if ( ! $recipient ) {
# the form did not have a to field
# modify this text appropriately
&error("No Return Address");
}
########################################################################
##
# Check Security
########################################################################
##
# Users who wish to use this program must
# put the file ".allowmailform" in their home directory on the
# machine running this script.  We don't want people creating
# forms that are abused to send "ananymous" mail.
$homedir = (getpwnam($recipient))[7];
if (! -e "$homedir/.allowmailform") {
# this user does not permit the server to send mail to him.  Quit.
&error("The recipient of the form has not enabled access for this
form");
exit(0);
}
# get ready to send mail
if ( ! open(MAIL,"| $sendmail $recipient") ) {
&error("Could not start mail program");
}
########################################################################
##
# construct the headers
########################################################################
##
print(MAIL "To: recipient\n");
if ( ! $cgiVals{'subject'} ) {
$cgiVals{'subject'} = "(no subject)";
}
print(MAIL "Subject: $cgiVals{subject}\n");
if ( ! $cgiVals{'from'} ) {
$cgiVals{'from'} = "nobody";
}
print( MAIL "From: $cgiVals{from}\n");
#done with the headers.  Add the blank line.
print( MAIL "\n");
########################################################################
##
# construct the body.
########################################################################
##
foreach $key ( keys(%cgiVals) ) {
if ( $key eq "to" || $key eq "subject" || $key eq "from" ) {
next;
}
print( MAIL "$key: $cgiVals{$key}\n");
}
########################################################################
##
# All done.  Clean up.
########################################################################
##
close(MAIL);
# the response.
print("Form submitted successfully.  Thanks!");
exit(0);


I have a couple of questions.
1. I ran the form from within Dreamweaver, and when I hit the SUBMIT
   button, Internet Explorer asks if I want to save the program to
   disk, or open it from it's current location.  I open it, and a DOS
   window pops up with just a flashing cursor.  When I hit ENTER, an
   error is displayed, but the window closes again immediately.
   Is there any way to keep the window open?
   Can I test the program from within Dreamweaver this way, or am I
   being stupid?

2. How do I run the script from the DOS prompt?
   If I run it with 'perl mailform.pl', a flashing cursor appears until
   I hit ENTER, then it gives the error "No Return Address" - which
   means the script is working!
   How do I call it and pass a return address?

Thanks for any help you can give.
Damian.


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


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