[17873] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 33 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 10 18:07:29 2001

Date: Wed, 10 Jan 2001 15:05:26 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979167925-v10-i33@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 10 Jan 2001     Volume: 10 Number: 33

Today's topics:
    Re: ASCII to integer conversion <cliff@*MYLASTNAMEHERE*.nl>
    Re: CGI Form read? <diab.lito@usa.net>
    Re: counting lines in a file <ssomneb@my-deja.com>
    Re: data structure syntax (Greg Bacon)
    Re: data structure syntax <aqumsieh@hyperchip.com>
    Re: data structure syntax <crowj@aol.com>
        email attachments w/Sendmail using Perl? <kthomason@utsystem.edu>
    Re: email attachments w/Sendmail using Perl? <tony_curtis32@yahoo.com>
    Re: File gungeek@my-deja.com
    Re: Finding ranges in a list of integers <W.Hielscher@mssys.com>
    Re: HTML stripper <joe+usenet@sunstarsys.com>
        Licensing a program written perl? bababozorg@aol.com
    Re: Licensing a program written perl? gungeek@my-deja.com
    Re: Licensing a program written perl? bababozorg@aol.com
    Re: Licensing a program written perl? (Randal L. Schwartz)
    Re: Mac Databases and MacPerl gungeek@my-deja.com
    Re: Newbie needs help bababozorg@aol.com
        Outputting special DOS characters in Windows (Spiffy1two)
    Re: Outputting special DOS characters in Windows <sarbayo@telis.org>
        Perl guest book script <kevinriggs@mindspring.com>
        Perl on MS IIS 5.0 scorp_ajit@my-deja.com
    Re: Please Recommed Encryption Module <joe+usenet@sunstarsys.com>
    Re: Problem with inserting data (Damian James)
    Re: Problem with inserting data (Garry Williams)
    Re: Problem with inserting data grishaa@my-deja.com
        Recursive Directory Size (BUCK NAKED1)
    Re: RegEx question (Richard Zilavec)
        replacing spaces with %20 <newsgroups@jhorn.cjb.net>
        System() redirection failing in Win98, WinME (Duncan Murdoch)
        using motd to make Perl style comments <comdog@panix.com>
        Variable <Waarddebon@chello.nl>
        variable <Waarddebon@chello.nl>
    Re: Variable (Richard Zilavec)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 10 Jan 2001 23:32:44 +0100
From: Clifford Pennock <cliff@*MYLASTNAMEHERE*.nl>
Subject: Re: ASCII to integer conversion
Message-Id: <93ion1$5mp$1@news.news-service.com>

Martien Verbruggen wrote:
> 
> *plonk*

Thanks. Now at least you will stay away from this thread. Oh wait, you
won't read this... Oh well.


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

Date: Wed, 10 Jan 2001 19:03:32 GMT
From: Mario <diab.lito@usa.net>
Subject: Re: CGI Form read?
Message-Id: <93ibls$9iv$1@nnrp1.deja.com>

In article <93cea5$lol$1@news.kolumbus.fi>,
  "Wavetable" <wavetable@birdmail.com> wrote:
> If someone could just post an example of a script used with a form
doing
> nothing but printing out the contents of one text field I would be
very
> grateful =)
>
>

You have a form field as <input type="text" name="my_email">

You can retrieve the content of that field in this way:

#/usr/bin/perl
use CGI qw(param);
$my_email=param('my_email');
print "Content-type:text/html\n\n";
print "The email is $my_email\n";

--
Mario


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 22:19:28 GMT
From: John Galt <ssomneb@my-deja.com>
Subject: Re: counting lines in a file
Message-Id: <93in54$kr7$1@nnrp1.deja.com>

As a newbie to Perl, I'm always welcome to suggestions and improvements
to my
(simple and often error prone) programs.  Please take my questions
seriously.


> >  $file="filename.txt";
>
> my $file = 'filename.txt';
>
> >  open FILENAME, $file or die "Cannot open $file for read: $!";
>
> The file name is in "$file" and the file handle is in "FILENAME"?

Why not?  Are you trying to say that they should be the same name, like
$file
and "FILE"?


> >  $count=0            #so that it will return "0" if there are no
> >                       #relevant lines
>
> my $count = 0;

I know that the "my" part makes it a local variable, but what's the
consequence
if you don't use it?  Does making it a local variable confine it to
just the
subroutine, or the program, or what?  I've done a bit of research about
this one
after your comment, but I haven't been able to figure that out.  Yes, I
did
forget a semicolon, sorry about the typos.  I did add the little
disclaimer that
said it wasn't perfect.

> >  for ( <FILENAME> ) {
>
> You probably meant 'while ( <FILENAME> ) {'
>
> >       chomp;
> >       if ($_) {
>
Why? Won't it have the same result?


> What it the line has the digit 0 on a line by itself or only contains
>
whitespace?
>
> >           if (!/#/){
>
> This will skip lines like:
> print "This is an example of the # character";

Well, this one's debatable.  I'm not sure what the OP meant... did he
want to
*not* count lines that only had comments (which is logical) or not
count lines
that had any comment (I don't see the purpose)?  His posting seemed to
reflect
the latter, but the former makes more sense.  I should have specified
(this
isn't an excuse... I did test for that possibility).  Good point about
the "0"
though.


> >  Enjoy!
> Counting errors.

No - learning.

John



Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 19:29:14 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: data structure syntax
Message-Id: <t5pe0aj2lvvb75@corp.supernews.com>

In article <93i9g4$7a2$1@nnrp1.deja.com>,
     <robr@sitera.com> wrote:

: If I have:
: 
: my $ref = {
:              "foo"    =>  [ "0", "1" ]
:           };
: 
: what would be the syntax to push "2" onto the anonymous array?

push @{ $ref{foo} }, 2;

See the perldsc and perllol manpages.

Greg
-- 
What George Washington did for us was to throw out the British, so that we
wouldn't have a fat, insensitive government running our country.  Nice try
anyway, George.
    -- D.J. on KSFO/KYA


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

Date: Wed, 10 Jan 2001 20:25:55 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: data structure syntax
Message-Id: <7ag0iri27e.fsf@merlin.hyperchip.com>


robr@sitera.com writes:

> HI Folks,
> 
> If I have:
> 
> my $ref = {
>              "foo"    =>  [ "0", "1" ]
>           };
> 
> what would be the syntax to push "2" onto the anonymous array?

	push @{$ref{foo}} => 2;

Read 'perldsc' for more info.

--Ala


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

Date: Wed, 10 Jan 2001 16:23:11 -0500
From: John Crowley <crowj@aol.com>
Subject: Re: data structure syntax
Message-Id: <3A5CD2BF.77EFBD88@aol.com>

robr@sitera.com wrote:
> 
> HI Folks,
> 
> If I have:
> 
> my $ref = {
>              "foo"    =>  [ "0", "1" ]
>           };
> 
> what would be the syntax to push "2" onto the anonymous array?
> 
> Thanks,
> 
> Rob Root
> 
> Sent via Deja.com
> http://www.deja.com/

Take a look at Chapter 4 of "Programming Perl"

#!/usr/sbin/perl5.00404 -w

# using an anonymous hash
my $ref = {
  foo => ["0", "1"]
};

print "@{$ref->{foo}}\n";

push (@{$ref->{foo}}, "2");

print "@{$ref->{foo}}\n";

#using a regular hash

my %ref = (
  foo => ["0", "1"]
);

print "@{$ref{foo}}\n";

push (@{$ref{foo}}, "2");

print "@{$ref{foo}}\n";


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

Date: Wed, 10 Jan 2001 13:17:26 -0600
From: "kevin thomason" <kthomason@utsystem.edu>
Subject: email attachments w/Sendmail using Perl?
Message-Id: <93icg0$nkf$1@geraldo.cc.utexas.edu>

I'm looking for a MIME-capable perl module that will allow me to send emails
w/attachments using Sendmail. Any ideas on where to find such a thing (if it
exists)?  Thanks :)




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

Date: 10 Jan 2001 14:23:07 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: email attachments w/Sendmail using Perl?
Message-Id: <87lmsj2m38.fsf@limey.hpcc.uh.edu>

>> On Wed, 10 Jan 2001 13:17:26 -0600,
>> "kevin thomason" <kthomason@utsystem.edu> said:

> I'm looking for a MIME-capable perl module that will
> allow me to send emails w/attachments using
> Sendmail. Any ideas on where to find such a thing (if it
> exists)?

http://search.cpan.org/

it's not restricted to sendmail though (that's a bit of a
red herring actually).

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Wed, 10 Jan 2001 21:15:17 GMT
From: gungeek@my-deja.com
Subject: Re: File
Message-Id: <93ijct$h1n$1@nnrp1.deja.com>

In article <93hqp5$aad$1@news.polbox.pl>,
  "Marcin Pytlik" <mp@softex.com.pl> wrote:
> Hi !
> I want to create script to move files
> I want one disk (d:\) on this disk I have directories and files. I
wan to
> choose automiatically files with date (e.g. 2001.01.05). These files
I have
> to move to disk E:
> please help me
> MArcin

We are not your personal slaves.  Make an attempt yourself, and then,
if you have problems, post your code and a description of the problem
you are having.


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 20:59:51 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: Finding ranges in a list of integers
Message-Id: <3A5CBF37.47EF7B3@mssys.com>

Ala Qumsieh wrote:
> 
> rgarciasuarez@free.fr (Rafael Garcia-Suarez) writes:
> > I've a list of integers, sorted in ascending numerical order, like this:
> >   qw/1 3 4 5 6 7 9 11 12 13 15 16 18 19 20 21 23 24/
> > and I want to turn it into a string representation : a list of integers
> > separated by commas, but where ranges of three or more consecutive
> > integers are written like '1-3'. E.g. the solution for the above list
> > would be :
> >   1,3-7,9,11-13,15,16,18-21,23,24
> > or, alternatively :
> >   1,3-7,9,11-13,15-16,18-21,23-24
> > if we allow two consecutive integers to be considered as a range.
> >
> > I'm looking for smart, short, efficient or funny solutions.
> >
> > I came up with this one :
[snip, see sub rgs below]
>
> Hmmm, what about:
[snip, see sub ala below]
> 
> Without any benchmarking, I would assume it's rather fast.

But I think you're wrong. While benchmarking my "not so smart" solution
(see sub woh below, it performs _bad_) I get the following results:

C:\TEMP>perl -w bench.pl
Benchmark: timing 10000 iterations of ala, rgs, woh...
       ala: 12 wallclock secs (11.94 usr +  0.00 sys = 11.94 CPU) @
837.73/s (n=10000)
       rgs:  5 wallclock secs ( 4.55 usr +  0.00 sys =  4.55 CPU) @
2199.25/s (n=10000)
       woh: 12 wallclock secs (11.67 usr +  0.00 sys = 11.67 CPU) @
857.12/s (n=10000)
1,3-7,9,11-13,15-16,18-21,23-24
1,3-7,9,11-13,15,16,18-21,23,24
1,3-7,9,11-13,15-16,18-21,23-24


C:\TEMP>type bench.pl
#!/usr/local/bin/perl -w
use strict;

use Benchmark;

my @list = qw/1 3 4 5 6 7 9 11 12 13 15 16 18 19 20 21 23 24/;


sub ala {
   my %hash;

   $hash{$_} = exists $hash{$_ - 1} ? 
        delete $hash{$_ - 1} : $_ for @list;

   my $result = join ',' => map { $_ == $hash{$_} ? $_ : "$hash{$_}-$_"
} 
        sort {$a <=> $b} keys %hash;

}


sub rgs {
   my @r = @list;

   for my $i (2..$#list) {
     $r[$i-1] = ($list[$i-2] == $list[$i]-2) ? '-' : $list[$i-1];
   }
   
   my $result = join ',', @r;
   $result =~ s/,-(,-)*,/-/g;
   
   $result
}

sub woh {
   my $result = join '_', @list;

   $result =~ s/(\d+)_(\d+)/($2 == $1+1 ? "$1-$2" : "$1,$2")/eg for
(1,2);

   $result =~ s/-(?:\d+-)+(\d+)/-$1/g;

   $result;
}

timethese( 10000, {
   'ala' => \&ala,
   'rgs' => \&rgs,
   'woh' => \&woh,
});


print ala(), "\n";
print rgs(), "\n";
print woh(), "\n";


Cheers
   Wolfgang


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

Date: 10 Jan 2001 16:45:36 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: HTML stripper
Message-Id: <m3lmsjw073.fsf@mumonkan.sunstarsys.com>

eggie@REMOVE_TO_REPLYsunlink.net (James Kufrovich) writes:

> Hrmm, maybe sticking the /s outside of
> the entire regex would be better in this case?  Maybe
> m!<(\w+)>(.*?)</\1>!si would work?  Are there any valid HTML tags that
> don't match (\w+)?

Why guess? See 

% perldoc -q HTML

and *know*.

(I think we're in the teens already for Jan 2001 postings 
related to this FAQ.)
-- 
Joe Schaefer


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

Date: Wed, 10 Jan 2001 19:43:36 GMT
From: bababozorg@aol.com
Subject: Licensing a program written perl?
Message-Id: <93ie16$brj$1@nnrp1.deja.com>

Hi

I was wondering if there is a way to actually implement licencing in a
perl program... what i mean is simply... if a customer buys this
program written in perl, under one user license... is there anyway to
stop him if he gives a copy of the program to his friend to use or
something?

i was thinking to insert an image like 1x1 pixle in the admin page of
the program... somewhere hidden, so that would send a request to a
program in our server... so users can be traced down... BUT thats not
such a good idea since the code can always be removed...

do u guys have any ideas to implement this under perl? have you came
across a same problem before? or...

thanks
hamed


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 21:34:24 GMT
From: gungeek@my-deja.com
Subject: Re: Licensing a program written perl?
Message-Id: <93ikgv$i3d$1@nnrp1.deja.com>

In article <93ie16$brj$1@nnrp1.deja.com>,
  bababozorg@aol.com wrote:
> Hi
>
> I was wondering if there is a way to actually implement licencing in a
> perl program... what i mean is simply... if a customer buys this
> program written in perl, under one user license... is there anyway to
> stop him if he gives a copy of the program to his friend to use or
> something?

So I get it.  You want to use Perl, _Free_ software, and get our _free_
advice on how to restrict people from re-using the code _you_ write?
Free the code.



Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 21:58:32 GMT
From: bababozorg@aol.com
Subject: Re: Licensing a program written perl?
Message-Id: <93ilu1$jee$1@nnrp1.deja.com>

In article <93ikgv$i3d$1@nnrp1.deja.com>,
  gungeek@my-deja.com wrote:
> In article <93ie16$brj$1@nnrp1.deja.com>,
>   bababozorg@aol.com wrote:
> > Hi
> >
> > I was wondering if there is a way to actually implement licencing
in a
> > perl program... what i mean is simply... if a customer buys this
> > program written in perl, under one user license... is there anyway
to
> > stop him if he gives a copy of the program to his friend to use or
> > something?
>
> So I get it.  You want to use Perl, _Free_ software, and get our
_free_
> advice on how to restrict people from re-using the code _you_ write?
> Free the code.

So what you are simply saying is that ALL those comercial programs out
there which are written in perl MUST give their program for free...
only because PERL is a free distributed langauage??? and another
thing... if your advice is SO commercial... that you bother sharing
your experiences to people.. u better dont read this news group AT ALL.



> Sent via Deja.com
> http://www.deja.com/
>


Sent via Deja.com
http://www.deja.com/


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

Date: 10 Jan 2001 14:50:59 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Licensing a program written perl?
Message-Id: <m1hf3710oc.fsf@halfdome.holdit.com>

>>>>> "bababozorg" == bababozorg  <bababozorg@aol.com> writes:

bababozorg> So what you are simply saying is that ALL those comercial
bababozorg> programs out there which are written in perl MUST give
bababozorg> their program for free...

No, just that if you want to do that, you won't get much help from the
people who have helped bring Perl to *you* for free.  You're on
your own, kid.  You've ripped the safety tag from the mattress, so
the warranty is void.

print "Just another Perl hacker,"

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


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

Date: Wed, 10 Jan 2001 20:51:11 GMT
From: gungeek@my-deja.com
Subject: Re: Mac Databases and MacPerl
Message-Id: <93ihvr$fqn$1@nnrp1.deja.com>

In article <3A5C73E3.B4C99336@mail1.jpl.nasa.gov>,
  Marc Pestana <markp@mail1.jpl.nasa.gov> wrote:

> BD for a G3? Does anyone know of a MacPerl Newsgroup I could query? Is
> there an SQL database for the Mac that I could use instead of the BD?
>

If you're not too worried about performance, what about DBD-CSV?


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 20:57:01 GMT
From: bababozorg@aol.com
Subject: Re: Newbie needs help
Message-Id: <93iiao$g09$1@nnrp1.deja.com>


> Here's the script:
>
> #!/usr/bin/perl
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/\&/, $buffer);
> foreach $pair (@pairs) {
>
>         ($name, $value) = split(/=/, $pair);
>         $value =~ tr/+/ /;
>         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>         $FORM{$name} = $value;
> }
>

i would have my query string as:

"../cgibin/test.pl&page=page_two"

(just give the parameter a name... thatway it would be easier)

and then within my script... i would look for the value of $FORM{'page'}
 and based upon the value.. i tell the program to do whatever... or
what action to take...

> &page_one;
right now... with what you have above.. everytime you load this script,
subroutine "page_one" is gonna be loaded, regardless of any query
string you input to the program in your link....

change your code to:

if($FORM{'page'} eq "page_two"){
    &page_two;
}elsif($FORM{'page'} eq "page_one"){
    &page_one;
}

i dont know what your program gonna be... but if it is gonna output
only html pages... i would place that print "Content-type:
text/html\n\n"; some where top of my script... OUTSIDE any
subroutine... to avoid repeating code...

> sub page_one {
>
> print "Content-type: text/html\n\n";
> print qq~<html><head>
> <title>Test</title>
> </head><body>
> </form>
> <table width="25%">
> <tr>
> <td width="100%"><ol>
> <li><a href="../cgibin/test.pl&page_two">Show page two</a> </li>
> </ol>
> </td>
> </tr>
> </table>
> </form>
> </body>
> </html>~;
>
> }
>
> sub page_two {
>
> print "Content-type: text/html\n\n";
> print qq~<html><head>
> </head>
> <body>
> <h1>Page Two</h1>
> </body>
> </html>~;
>
> }
>
> Thanks in advance
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: 10 Jan 2001 19:53:20 GMT
From: spiffy1two@aol.com (Spiffy1two)
Subject: Outputting special DOS characters in Windows
Message-Id: <20010110145320.04296.00004832@ng-fi1.aol.com>

Greetings.

I am working on a cgi script that opens a text file, formats the contents,
prints those contents to a web page.  The problem is, the text files contain
special characters, such as ö, ä, Ö, and other German letters.  They don't come
out correctly into the browser.  Each of them gets converted to something else.
 I suspect this has to do with different character maps in Windows and DOS. 
Does PERL have some way of handling this, or am I out of luck?  HTML "&"
character codes will not work here, because it is not in the body of the web
page.

Many thanks.

Dan Rasmussen




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

Date: Wed, 10 Jan 2001 20:20:25 GMT
From: steve a <sarbayo@telis.org>
Subject: Re: Outputting special DOS characters in Windows
Message-Id: <3a5cc312.3932025@news.inreach.com>

I have not tried this, but, if you include some javascript in the
page, you should be able to specify font/style and *escape* special
characters.
I would try posting to:
    comp.lang.javascript

I'm sure somebody there can help.



On 10 Jan 2001 19:53:20 GMT, spiffy1two@aol.com (Spiffy1two) wrote:
:Greetings.
:
:I am working on a cgi script that opens a text file, formats the contents,
:prints those contents to a web page.  The problem is, the text files contain
:special characters, such as ö, ä, Ö, and other German letters.  They don't come
:out correctly into the browser.  Each of them gets converted to something else.
: I suspect this has to do with different character maps in Windows and DOS. 
:Does PERL have some way of handling this, or am I out of luck?  HTML "&"
:character codes will not work here, because it is not in the body of the web
:page.
:
:Many thanks.
:
:Dan Rasmussen
:
:



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

Date: Wed, 10 Jan 2001 15:57:43 -0500
From: "Kevin Riggs" <kevinriggs@mindspring.com>
Subject: Perl guest book script
Message-Id: <93iio3$4b9$1@nntp9.atl.mindspring.net>

I have the following script running at

http://www.fodac.org/gb/guest.htm

and it's getting an internal server error. Any ideas about what might be
causing the problem would be appreciated.

Thanks,
Kevin Riggs

#!/usr/bin/perl
require "cgi-lib.pl";
&ReadParse(*in);
print "Content-type: text/html\n\n";
$thismonth = (January, February, March,
April, May, June, July, August,
September, October, November, December)[(localtime)[4]];
$thisday = (localtime)[3];
$thisyear = (localtime)[5];
$name = $in{'name'};
$email = $in{'email'};
$address = $in{'address'};
$city = $in{'city'};
$state = $in{'state'};
$comments = $in{'comments'};
$outputfile = "/home/fodac490/fodac-www/gb/gbookbare.html";
$outputstore = "/home/fodac490/fodac-www/gb/gbooksave.html";
$redopage = "/home/fodac490/fodac-www/gb/redopage.html";
$thankyoupage = "/home/fodac490/fodac-www/gb/thankyoupage.html";
&redo;
&addbook;
&writefile;
sub redo {
if ($email eq "" || $comments eq "" || $name eq "") {
open (REDOPAGE,$redopage);
while (<REDOPAGE>) {
print $_;
}
close (REDOPAGE);
exit;
}
}
sub addbook {
open (THANKYOUPAGE,$thankyoupage);
while (<THANKYOUPAGE>) {
print $_;
}
close (THANKYOUPAGE);
}
sub writefile {
open (STOREFILE,">$outputstore");
open (OLDFILE,$outputfile);
$num = 0;
while (<OLDFILE>) {
if ($num <= 7) {
print STOREFILE $_;
}
close(OLDFILE);
close(STOREFILE);
open(NEWFILE,">$outputfile");
print NEWFILE<<stuff;
<html>
<head>
<title>Vehicle Trader</title>
</head>
<body bgcolor="#FFFFFF">
<h1>Vehicle Trader</h1>
<p>
<hr>
<b>Name: </b>$name</br>
<b>Address: </b>$address</br>
<b>City: </b>$city</br>
<b>State: </b>$state</br>
<b>E-mail: </b><a href=\"mailto:$email\">$email</a></br>
<b>Submitted: </b><i> $thismonth $thisday, 19$thisyear</i></br>
<b>Comments: </b>$comments
stuff

open (SAVEFILE,$outputstore);
$num = 0;
while (<SAVEFILE>) {
if ($num <= 7) {
print NEWFILE $_;
}
++$num;
}
close(SAVEFILE);
close(NEWFILE);
unlink ($outputstore);
}






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

Date: Wed, 10 Jan 2001 21:30:16 GMT
From: scorp_ajit@my-deja.com
Subject: Perl on MS IIS 5.0
Message-Id: <93ik99$i03$1@nnrp1.deja.com>

Hi,

  i am trying to make my perlscripts work on Windows server running MS
IIS 5.0. But the scripts are not working. Is there any way to make the
scripts work?
This is a script to send e-mails from the website using the mail form,
but its not working.
So please can anyone can tell me what i have to do to make it work?

thanks in advance


Ajit


Sent via Deja.com
http://www.deja.com/


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

Date: 10 Jan 2001 16:48:37 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Please Recommed Encryption Module
Message-Id: <m3hf37w022.fsf@mumonkan.sunstarsys.com>

"Gabe" <grichard@uci.edu> writes:

> I want to encrypt credit card data and store it in a MySQL data. Is there a
> de facto standard Perl module for this sort of thing?
> 
See the Crypt::* collection on CPAN.  There's a whole
bunch to choose from (DES, MD5, Blowfish, etc.).  Both
symmetric and (one-way) hashing algorithms are there.

-- 
Joe Schaefer



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

Date: 10 Jan 2001 22:53:55 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: Problem with inserting data
Message-Id: <slrn95pq22.1k.damian@puma.qimr.edu.au>

In article <3a5621e0@news-uk.onetel.net.uk>, Edd wrote:
>I am using the below section of a code to insert data into an MySQL table. I
>copied this from DBI documentation available at www.perldoc.com/DBI

Don't do this. Read it, look up anything you don't understand in the 
documentation, then write your own code to suit _your_ needs. If you
admit to just copying code from random sources in this newsgroup, 
people who might otherwise give you good advice will killfile you.

>
>------------CODE----------------------
>
>Shebank line, use DBI;, use strict etc...

It really would have been less trouble to copy and paste the actual code 
for these here. Also, it's "shebang".

#!/usr/bin/perl -w
use strict;
use DBI;

>...
>...
>my $coname = "tex";
>my $address = "tex";
>my $second = "30 Tosson terrace";
>my $town = "EW";my $country = "UK";
>my $code = "GHG";
>my $title = "Mr.";
>

You could just say:
my ($coname,$address,$second,$town,$country,$code,$title) =
   ("tex","tex","30 Tosson terrace","EW","UK","GHG","Mr.");

>
>my $sth = $dbh->prepare("INSERT INTO
>f1(coname,address,second,town,country,code,title) VALUES (?,?,?,?,?,?,?)");

You need to connect to the database before you can do this. As written, you'll
get a "Can't call method prepare on uninitialised value" error.
my $dbh = DBI->connect(Data_source_name, Username, Password);

>while(<>) {

Why on earth do you think you need a loop here? You'll find that this will 
work fine with just the $sth->execute statement below.

>chop;
>($coname,$address,$second,$town,$country,$code,$title) = split/,/;
>$sth->execute($coname,$address,$second,$town,$country,$code,$title);
>}
>
>... CODE continues....
>
>
>
>
>When the code runs, it gets into a loop and enters alot of 'NULL's into the
>fields concerned.
>I don't quite understand 'while (<>)' what does that do. Another version
>from perldoc is
>'while (<CVS>). What on earth is CVS. There is no explanation about it
>whatsoever. Can somebody enlighten me about this.
>

In this context, it is a filehandle. 

You need to read the documentation about filehandles, I/O operators
and the open() function:

perldoc -f open
perldoc perlop
perldoc perlopentut

>What is the easiest way of enetering data froma cgi-code into a remote
>server MySQL database.

DBI, as you have already guessed. You should also investigate the CGI
module, also from CPAN but now in the standard perl distribution.

My advice:
 
 - Read the documentation. Don't copy code - it's only there to help 
   you to understand. The manual pages are not recipe books (you should 
   buy _The Perl Cookbook_ if that's what you're after).
 - Limit your posts to <80-column width, otherwise your text will get very 
   ugly if people quote it.
 - If you will do a lot of DBI/SQL stuff, and in any case, you should 
   find out about the $dbh->quote method, and about Perl's quote-like
   operators (perldoc -f qw). This will save you from syntactic 
   attrocities when you need to issue SQL queries containing quotes.

I hope this is of some help,

Cheers,
Damian


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

Date: Wed, 10 Jan 2001 22:58:40 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Problem with inserting data
Message-Id: <AO576.1291$qi1.13017@eagle.america.net>

On Fri, 5 Jan 2001 19:44:33 -0000, Edd <edd@texscene.com> wrote:

>I am using the below section of a code to insert data into an MySQL
>table. I copied this from DBI documentation available at
>www.perldoc.com/DBI
>
>------------CODE----------------------
>
>Shebank line, use DBI;, use strict etc...
>...
>...

Well, that's part of the script and it's important to see it.  You
would be surprised at how many people post code here that does not
enable warnings and strictures.  Some here, for good reason, are quite
jaded on that subject.  

>my $coname = "tex";
>my $address = "tex";
>my $second = "30 Tosson terrace";
>my $town = "EW";my $country = "UK";
>my $code = "GHG";
>my $title = "Mr.";

This looks good.  You have assigned values to the variables you want
to contain the values you later want to insert into your table.  

>my $sth = $dbh->prepare("INSERT INTO
>f1(coname,address,second,town,country,code,title) VALUES (?,?,?,?,?,?,?)");

Hmm.  I guess you left out the connection to the database where you
get a value for $dbh.  I would recommend that you show us this part.
You might want to be using the RaiseError and/or PrintError options
since you don't check the result of your prepare() or your execute()
below.  

>while(<>) {

Okay, you are now reading from the STDIN file handle.  But wait!  What
data are you expecting to be there?  As a matter of fact, a program
designed for the CGI interface would not expect a comma-separated file
on its STDIN, would it?  Come to think of it, I didn't see where you
use the CGI module.  You are using the CGI module for a CGI script
aren't you?  

There's nothing there (on the STDIN file handle) that you really want.  

>chop;
>($coname,$address,$second,$town,$country,$code,$title) = split/,/;

I'm confused.  Above you carefully assign strings to all of these
variables.  Now you seem to be expecting other values from STDIN.  Why
did you assign the values above, if you are now assigning new values.
Did you cut some code out of your post?  

>$sth->execute($coname,$address,$second,$town,$country,$code,$title);
>}

Well, assuming that the execute() of your insert statement completed
successfully (hard to tell, since we cannot see your connect()), then
I bet a bunch of these variables are now undefined.  I bet this is
where your null values are coming from.  

>When the code runs, it gets into a loop and enters alot of 'NULL's
                        ^^^^^^^^^^^^^^^^
That's hard to believe.  How do you stop the program if it is looping?
Do you have to kill it from another process?  The code you show will
exit -- not loop.  

>into the fields concerned.  I don't quite understand 'while (<>)'
>what does that do. Another version from perldoc is 'while (<CVS>).
>What on earth is CVS. There is no explanation about it whatsoever.

Oh yes there is.  It's called a file handle.  You need to look at the
"I/O Operators" section of the perlop manual page.  

>Can somebody enlighten me about this.

The manual can.  

>What is the easiest way of enetering data froma cgi-code into a
>remote server MySQL database.

You seem to be onto a way: using the SQL INSERT statement.  You just
need to obtain the values for the columns that you want inserted.  The
code above doesn't do that.  

While you are learning about Perl, you should try to develop a habit
of indenting your code properly and using white space in your code.
It makes it much more maintainable and readable.  

-- 
Garry Williams


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

Date: Wed, 10 Jan 2001 22:54:18 GMT
From: grishaa@my-deja.com
Subject: Re: Problem with inserting data
Message-Id: <93ip6l$mo1$1@nnrp1.deja.com>

In article <3a5621e0@news-uk.onetel.net.uk>,
  "Edd" <edd@texscene.com> wrote:
> I am using the below section of a code to insert data into an MySQL
table. I
> copied this from DBI documentation available at www.perldoc.com/DBI
>
> ------------CODE----------------------
>
> Shebank line, use DBI;, use strict etc...
> ...
> ...
> my $coname = "tex";
> my $address = "tex";
> my $second = "30 Tosson terrace";
> my $town = "EW";my $country = "UK";
> my $code = "GHG";
> my $title = "Mr.";
>
> my $sth = $dbh->prepare("INSERT INTO
> f1(coname,address,second,town,country,code,title) VALUES
(?,?,?,?,?,?,?)");
> while(<>) {
> chop;
> ($coname,$address,$second,$town,$country,$code,$title) = split/,/;
> $sth->execute($coname,$address,$second,$town,$country,$code,$title);
> }
>
> ... CODE continues....
>
> When the code runs, it gets into a loop and enters alot of 'NULL's
into the
> fields concerned.
> I don't quite understand 'while (<>)' what does that do. Another
version
> from perldoc is
> 'while (<CVS>). What on earth is CVS. There is no explanation about it
> whatsoever.

  Oh, come on! There is plenty ... How about "Learning Perl" or any
other basic perl book for that matter.

> Can somebody enlighten me about this.
>
> What is the easiest way of enetering data froma cgi-code into a remote
> server MySQL database.
>
> Cheers.
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 12:45:26 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Recursive Directory Size
Message-Id: <5705-3A5CADC6-3@storefull-243.iap.bryant.webtv.net>

How do I get the size of a directory recursively? This code only gets
the first level...

while (glob "$dir*") {
$dirsize += -s $_ 
} ; 
print $dirsize;

I can't get `du -ck $dir` to get the size recursively either. I just
finished studying man glob, but didn't see anything in there to help
this.

--Dennis



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

Date: Wed, 10 Jan 2001 19:03:07 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: RegEx question
Message-Id: <3a65ae36.188385996@news.tcn.net>

On Wed, 10 Jan 2001 18:40:44 GMT, Uri Guttman <uri@sysarch.com> wrote:

>ever heard of Benchmark.pm?

Yes I have, I only used time for my personal tests, then decided to
post the results.  Next time I will use Benchmark.

>
>  RZ> $output =~ s/^\s*|\s*$//g; # 25.52
>
>  RZ> $output =~ s/^\s+|\s+$//g; # 14.75
>
>  RZ> $output =~ s/^\s+(.+?)\s+$/$1/; # 8.56
>
>try that last one on 'zzz  zzz  '. it fails. there, you need * instead
>of +.

Hah, the /^\s+ fails......  '  zzzz zz' also, I always do this in two
steps.

>so the FAQ is the fastest as it should be. so why don't you refer to it?

I always use it too... but the example was a single step, anyways
thanks for pointing above out.

--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Wed, 10 Jan 2001 22:08:41 GMT
From: ^Jerry <newsgroups@jhorn.cjb.net>
Subject: replacing spaces with %20
Message-Id: <93imh0$k1q$1@nnrp1.deja.com>

I'm using a perl script to show images from a folder, one at a time..
it works perfect in Internet Explorer, but in Netscape, if the images
have a space in their name, it won't work...

how can I replace the name of an image (in $image_name) to something
like this%20is%20me.jpg    ??

any help is greatly appreciated...

Jerry


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 14:18:00 -0500
From: murdoch@fisher.stats.uwo.ca (Duncan Murdoch)
Subject: System() redirection failing in Win98, WinME
Message-Id: <3a5db297.16255904@newshost.uwo.ca>

I'm using perl in Win98 and WinME.  A system call that has a file
redirection in it is failing every time.  If I take away the
redirection, I see the correct output on the screen.

It's something like this:

 system("echo Hello!");

works fine, and displays Hello!, but

 system("echo Hello! > c:\\temp.txt");
 system("echo Hello! > c:/temp.txt");

both fail, and don't create the temp.txt file.  I don't know if this
is relevant or not, but this particular perl script is being called
from another process, running in a DOS window.

Is this a known problem?  Is there a workaround?

Here's the version information:

>This is perl, v5.6.0 built for MSWin32-x86-multi-thread
>(with 1 registered patch, see perl -V for more detail)
>
>Copyright 1987-2000, Larry Wall
>
>Binary build 620 provided by ActiveState Tool Corp. http://www.ActiveState.com
>Built 18:31:05 Oct 31 2000

Duncan Murdoch


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

Date: Wed, 10 Jan 2001 17:43:01 -0500
From: brian d foy <comdog@panix.com>
Subject: using motd to make Perl style comments
Message-Id: <comdog-E427F6.17430110012001@news.panix.com>



here's the motd for a machine i'm using this week. some names
have been changed to protect the innocent. the coders here seem
to have actually read it too ;)




Welcome to XXXXXX!  Here are some Perl coding tips:

- always "use strict", it enforces good standards and makes tracking
bugs easier.

- always test your code before committing to CVS (or at least check
it, with "perl -c filename.pl" )

- always surround regexp matches in an "if" so that you can catch
cases when it fails to match: if ($myvar =~ m/blah(.*?)moo/ ) {}

- make sure your services always exit with 0 (or some other
XXXXXX exit code)!  Do not use "die" from services!  Do not let
code run to the end of the script file without explicitly exiting!

- using Emacs for editing Perl is great!  Auto-indenting and brace
pair matching speeds development by helping you catch mistakes earlier
and also improves the readability of your final code.

-- 
brian d foy - mod_perl hacker for hire <comdog@panix.com>


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

Date: Wed, 10 Jan 2001 21:19:59 GMT
From: "Waarddebon" <Waarddebon@chello.nl>
Subject: Variable
Message-Id: <3m476.569612$%C1.6998499@Flipper>

How can you make from all characters in a variable (from which are upercase
and some lowercase) all lowercase characters ?




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

Date: Wed, 10 Jan 2001 22:29:54 GMT
From: "Waarddebon" <Waarddebon@chello.nl>
Subject: variable
Message-Id: <Cn576.570261$%C1.7016808@Flipper>

I can I make all characters in a string lowercase ??

Thanks in advance.




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

Date: Wed, 10 Jan 2001 21:30:42 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: Variable
Message-Id: <3a5dd46c.3052675@news.tcn.net>

On Wed, 10 Jan 2001 21:19:59 GMT, "Waarddebon" <Waarddebon@chello.nl>
wrote:

>How can you make from all characters in a variable (from which are upercase
>and some lowercase) all lowercase characters ?
>

perldoc -f lc

--
 Richard Zilavec
 rzilavec@tcn.net


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

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 V10 Issue 33
*************************************


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