[18041] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 201 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 2 14:05:42 2001

Date: Fri, 2 Feb 2001 11:05:12 -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: <981140712-v10-i201@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 2 Feb 2001     Volume: 10 Number: 201

Today's topics:
    Re: ActiveState Perl Threads <djberg96@my-deja.com>
    Re: add 20 minutes to local time an d put into .txt (Craig Berry)
    Re: Calling all DB_File Gurus. <Jodyman@usa.net>
    Re: Calling all DB_File Gurus. <Jodyman@usa.net>
    Re: Calling all DB_File Gurus. <Jodyman@usa.net>
        Can't read entire file into string. (LK)
    Re: Can't read entire file into string. <aqumsieh@hyperchip.com>
    Re: Can't read entire file into string. (LK)
    Re: Can't read entire file into string. (Craig Berry)
    Re: Can't read entire file into string. brianr@liffe.com
    Re: Can't read entire file into string. (LK)
    Re: CGI: flushing Perl output to browser (Jens)
    Re: first real PERL script . . . <uri@sysarch.com>
        flexible scripts <motiNOvus@hotSPAMmail.com>
        Ftp problem with perl jce2000@my-deja.com
    Re: Help: Script only runs if ' -w' is on line 1 (Villy Kruse)
    Re: Help: Script only runs if ' -w' is on line 1 (Abigail)
        mod_perl opinion needed <charleswarner@bigfoot.com>
    Re: mod_perl opinion needed <joe+usenet@sunstarsys.com>
        Newbie question: Creating L/Ps in a DBM <jonny.nystroem@telia.com>
        Regex - make more than one change on a line <dpmurphy@emc.com>
    Re: Regex - make more than one change on a line <vmurphy@Cisco.Com>
    Re: Regex - make more than one change on a line nobull@mail.com
        saving the name and value for a variable tanase_costin@my-deja.com
        Strange behaviour of "Error.pm" <s.willert@media-net.de>
        To Format or not to Format (was Re: perl report generat <nospam@nospam.com>
        Using CPAN.pm without upgrading to Perl 5.6 bluearchtop@my-deja.com
    Re: Using CPAN.pm without upgrading to Perl 5.6 <nospam@nospam.com>
        weekly calendar <choate@spot.colorado.edu>
        What is the context for grep's EXPR ? (Andre Majorel)
    Re: What is the context for grep's EXPR ? nobull@mail.com
        Win32::API <kosc@online.de>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 02 Feb 2001 16:25:36 GMT
From: Daniel Berger <djberg96@my-deja.com>
Subject: Re: ActiveState Perl Threads
Message-Id: <95en1j$5g7$1@nnrp1.deja.com>

With a non-activestate install of perl, you would be asked if you want
your distro to include perl threads during installation.  The
ActiveState distro never asks that AFAIK, so you won't be able to
use threads.

You're right, though, their "title" suggests that threading is
automatically enabled.  I've already sent them one email about this
but got no response.

Dan

In article <u3ddxce52.fsf@allgeier.net>,
  Rainer Keuchel <rkeuc@allgeier.net> wrote:
> Yes, seems it does not work... I tried it myself some time ago.
> --
> Rainer Keuchel
>

--
In the immortal words of Socrates, "I drank what?"


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


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

Date: Fri, 02 Feb 2001 17:59:28 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: add 20 minutes to local time an d put into .txt
Message-Id: <t7ltc07l91oo89@corp.supernews.com>

bert van Geffen (bert.van.geffen@philips.com) wrote:
: Does somebody how I can add 20 minutes to the local time

  my $future = time + 20 * 60;

The time() function returns the current time measure in seconds since the
epoch (Jan 1 1970 on most systems).  'perldoc -f time' for details.  Note
that this is just a large integer; you can use functions like localtime
and POSIX::strftime to generate human-readable date/time strings from it.

: and put the result into a .txt files

See the doc on the open and print functions.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Fri, 2 Feb 2001 11:44:17 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Calling all DB_File Gurus.
Message-Id: <95eo4t$hea$1@plonk.apk.net>


Anno Siegel wrote in message <95e4ku$iko$1@mamenchi.zrz.TU-Berlin.DE>...
>Your problem didn't come from a lack in the DB_File docs, but from
>a lack of understanding of the tie() process on your part.  Reading
>a bit more about tie() might have helped more than the guesswork
>your code was based on.  But you'd probably claim that those docs
>aren't "that good" either.  Oh well...


Once again, I stand humble, and ashamed.  I do, and did lack understanding
of tie.  With time, and under such great tutilage as yours and others, I
too, may
someday be a DB_File Guru.

Thank you, Thank you, Thank you..... grovel, grovel, grovel,
licking the dust.


Jody




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

Date: Fri, 2 Feb 2001 11:50:12 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Calling all DB_File Gurus.
Message-Id: <95eog1$htc$1@plonk.apk.net>


Garry Williams wrote in message ...
>The second example in the RECNO section clearly used the tied
>reference when opening the database.  Indeed the SYNOPSIS section
>clearly shows how to call tie, taking the tied reference for all three
>types of files.  I may not even have looked at the RECNO section
>because the SYNOPSIS seems very clear to me.  There is a section that
>discusses creating extra instances of the "type/openinfo" data
>structure used as the last parameter to tie().  The DB_File::RECNOINFO
>constructor can be used, if you want to set bval before calling tie().
>But that section makes it clear the once you have done that, it's to
>be used for the last parameter to tie().
>
>I wonder what part of the "docs aren't that good"?


Sure enough at the top of page 5 of the documents (which i missed) it
says:

$a = new DB_File::HASHINFO ;
$a->{'cachesize'} = 12345 ;
tie %y, 'DB_File', "filename", $flags, 0777, $a;

My humble apology to the creator of such awesome, extensive and
glorious documentation.  I lacked the understanding to perceive the
words I perused.

Jody





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

Date: Fri, 2 Feb 2001 11:59:50 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Calling all DB_File Gurus.
Message-Id: <95ep23$ie0$1@plonk.apk.net>


Garry Williams wrote in message ...
>Or why construct a new instance of the type/openinfo data structure at
>all?  Just do as the manual says: assign to the one that already
>exists before calling tie:
>
> $DB_RECNO->{reclen} = 512;
>
>This is well-documented in the DB_File manual page.  See the "Opening
>a Berkeley DB Database File" section in the manual.


Garry,

        Is this DB_File manual available on-line?  I only had the DB_File
documentation from www.perl.com which was 25 pages long.  These
weren't so clear to me.  Are there more extensive documentation online?
If so, where might they be found.

Thanks,

Jody

PS - Or is there a good book?  Programming the Perl DBI from O'Reilly
didn't have the information I was looking for either.

PSS - Am I also understanding the documentation that I have correctly that
DB_File actually reads the entire DB into memory, manipulates it there and
then restores it to the drive?  I'm a good GWBASIC Programmer with
Random Access files but there doesn't seem to be anything like this in
Perl or Unix for that matter without getting into Database programs to do
the
actual file manipulation.  I kind of enjoy the hands on, knowing that the
computer is only doing what I tell it to do thing.




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

Date: Fri, 02 Feb 2001 17:42:21 GMT
From: lkenny@fisheries.org (LK)
Subject: Can't read entire file into string.
Message-Id: <3a7af127.15418309@wingate>

This is probably just a little thing I am overlooking, butI want to
read a file into a string.  so far I have set up:

	open(FILE,"$file") || die("Cannot open file $file: $!"); 
 	$data = <FILE>;
	close (FILE);
	open (FIEL, ">>$dats");
	print FIEL "$data";

But the print only prints the first line of the file.
I can't figure out how to get it to print the entire file.

LK


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

Date: Fri, 02 Feb 2001 17:47:02 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Can't read entire file into string.
Message-Id: <7ad7d1ugdk.fsf@merlin.hyperchip.com>


lkenny@fisheries.org (LK) writes:

> This is probably just a little thing I am overlooking, butI want to
> read a file into a string.  so far I have set up:
> 
> 	open(FILE,"$file") || die("Cannot open file $file: $!"); 
>  	$data = <FILE>;
> 	close (FILE);
> 	open (FIEL, ">>$dats");
> 	print FIEL "$data";
> 
> But the print only prints the first line of the file.
> I can't figure out how to get it to print the entire file.

Checkout perlfaq3: How can I read in an entire file all at once?

and checkout perlvar ... look for $/ ..

--Ala



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

Date: Fri, 02 Feb 2001 17:58:31 GMT
From: lkenny@fisheries.org (LK)
Subject: Re: Can't read entire file into string.
Message-Id: <3a7af51b.16431259@wingate>

On Fri, 02 Feb 2001 17:47:02 GMT, Ala Qumsieh <aqumsieh@hyperchip.com>
wrote:

>
>lkenny@fisheries.org (LK) writes:
>
>> This is probably just a little thing I am overlooking, butI want to
>> read a file into a string.  so far I have set up:
>> 
>> 	open(FILE,"$file") || die("Cannot open file $file: $!"); 
>>  	$data = <FILE>;
>> 	close (FILE);
>> 	open (FIEL, ">>$dats");
>> 	print FIEL "$data";
>> 
>> But the print only prints the first line of the file.
>> I can't figure out how to get it to print the entire file.
>
>Checkout perlfaq3: How can I read in an entire file all at once?
>
>and checkout perlvar ... look for $/ ..
>
>--Ala
>

I went several different pl;aces looking for this faq, but I couldn't
find it.  perhaps I am looking in the wrong places.  Would you be able
to point me in the right direction?

Thanks,
LK


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

Date: Fri, 02 Feb 2001 18:05:04 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Can't read entire file into string.
Message-Id: <t7ltmg918fts04@corp.supernews.com>

LK (lkenny@fisheries.org) wrote:
: This is probably just a little thing I am overlooking, butI want to
: read a file into a string.  so far I have set up:
: 
: 	open(FILE,"$file") || die("Cannot open file $file: $!"); 
:  	$data = <FILE>;

  $data = do { local $/; <FILE>; };

Setting $/ to undef (which happens when you localize it) invokes "slurp
mode", where the <> read pulls in the entire remaining contents of the
file.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: 02 Feb 2001 18:06:53 +0000
From: brianr@liffe.com
Subject: Re: Can't read entire file into string.
Message-Id: <vtg0hxj6wy.fsf@liffe.com>

lkenny@fisheries.org (LK) writes:

> This is probably just a little thing I am overlooking, butI want to
> read a file into a string.  so far I have set up:
> 
> 	open(FILE,"$file") || die("Cannot open file $file: $!"); 
>  	$data = <FILE>;
> 	close (FILE);
> 	open (FIEL, ">>$dats");
> 	print FIEL "$data";
> 
> But the print only prints the first line of the file.
> I can't figure out how to get it to print the entire file.
> 
> LK

'perldoc perlvar' look for 'input record separator', or $/

-- 
Brian Raven
It would be possible to optimize some forms of goto, but I haven't
bothered.
             -- Larry Wall in <199709041935.MAA27136@wall.org>


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

Date: Fri, 02 Feb 2001 18:09:56 GMT
From: lkenny@fisheries.org (LK)
Subject: Re: Can't read entire file into string.
Message-Id: <3a7af7e8.17148101@wingate>

On Fri, 02 Feb 2001 18:05:04 -0000, cberry@cinenet.net (Craig Berry)
wrote:

>LK (lkenny@fisheries.org) wrote:
>: This is probably just a little thing I am overlooking, butI want to
>: read a file into a string.  so far I have set up:
>: 
>: 	open(FILE,"$file") || die("Cannot open file $file: $!"); 
>:  	$data = <FILE>;
>
>  $data = do { local $/; <FILE>; };
>
>Setting $/ to undef (which happens when you localize it) invokes "slurp
>mode", where the <> read pulls in the entire remaining contents of the
>file.
>
>-- 
>   |   Craig Berry - http://www.cinenet.net/~cberry/
> --*--  "When the going gets weird, the weird turn pro."
>   |               - Hunter S. Thompson


Thanks for your help.
LK


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

Date: Fri, 02 Feb 2001 15:40:53 +0100
From: "Ellegiers, J. M. (Jens)" <jellegie@ford.com>
Subject: Re: CGI: flushing Perl output to browser
Message-Id: <3A7AC6F5.AD55B9D7@ford.com>

Simply put a $| = 1; somewhere near the top of your script and STDOUT is
flushed directly after printing to it. See perldoc perlvar for an
explanation.

Gregory Toomey wrote:
> 
> I am writing Perl CGI scripts that generate a page of HTML,
> then do some file manipulation/cleanup.
> The output appears only after the script exits.
> 
> Is there any way to flush standard output to the browser?
> 
> My thoughts are to close the standard output file handle,
> or even do a fork().
> I am new to Perl and hope there is a simple answer.
> 
> I am running Perl 5, Apache, Linux, with IE5 browser.
> 
> Thanks in advance,
> Gregory Toomey

-- 
Viele Gruesse, regards, saludos
Jens Ellegiers
---------------------------------------------------------------
FORD-Werke AG, Spessartstrasse, 50725 Koeln
Jens Ellegiers                         Email: jellegie@ford.com  /"\
Engineer (I-Engine CAE)                Phone: +49-221-90-31467   \ /
Mail Sym: D-ME/PN-S                    Fax  : +49-221-90-33025    X
ASCII Ribbon campaign against HTML E-mail & Usenet News >------> / \


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

Date: Fri, 02 Feb 2001 17:22:32 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: first real PERL script . . .
Message-Id: <x766itrodj.fsf@home.sysarch.com>

>>>>> "JWK" == John W Krahn <krahnj@acm.org> writes:


  >> #assigning "End of Record" to an array for later printing
  >> @EOR = (
  >> "\x0d"
  >> );
  JWK> my $EOR = 0x0D;

better make that "\x0D" as they are meant to be bytes and not
integers. same thing for EOF

  >> print FILE $EOR[0];
  JWK> # Changed this to scalar so:
  JWK> print FILE $EOR;

that would print 4 bytes (assuming a 32 bit perl) instead of the 1 byte
the OP wanted.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 2 Feb 2001 10:08:35 -0800
From: "B McDonald" <motiNOvus@hotSPAMmail.com>
Subject: flexible scripts
Message-Id: <NJCe6.30$gp6.24527@news.pacbell.net>


Although this question is probably fundamental to all that we do in perl, I
think that the question is probably off-topic. Still I don't know where to
get an answer. So, at the very least, I hope that someone can direct me to
the proper group or resource that will answer my question.

Basically, I've created one perl script that serves to parse a CSV file into
a specific XML format, and another that takes the XML and injects the data
into SQL 7.

The issue is how to make these tools flexible in their invokation and in the
generation of their output, be it XML files or statistical reports. In other
words, I would like the intended users of the scripts to be able to invoke
them in whatever directory they may be working, on load files whereever they
may be located, and the output placed in directories wherever the user
decides to create them.

I'm not exactly certain how to frame the question, or what this is called --
but I figure there are perl experts and novices out there who have mastered
making their tools flexible within the OS environment. I am on a Win NT
machine.

Thanks,

Brian






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

Date: Fri, 02 Feb 2001 17:14:15 GMT
From: jce2000@my-deja.com
Subject: Ftp problem with perl
Message-Id: <95epsr$8f3$1@nnrp1.deja.com>

Hi all,


 I write a little perl program using Net::FTP and I receive this
message:

   Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be
16 at /usr/lib/perl5/5.00503/i386-linux/Socket.pm line 295.

   I need send over 400 files with this program, sometimes send 50
files, other times 75, other 25,....

   I'm using Redhat 6.2 and I tried to update some modules but the
results is the same.

   Perl Version: 5.005_03 built for i386-linux.
   IO:Socket: 1.25
   Net::FTP: 2.56 (libnet-1.0703)
   Socket: 1.7

   With RedHat 7.0 with Perl 5.6 I haven't this problem. I DON't want to
update Perl 5.005_03 to 5.6. Any suggestion?

That's the program:

 #!/usr/bin/perl

 use Net::FTP;

 # Settings
 $host = "ftp.domain.com";
 $login = "login";
 $passwd = "password";
 $source_dir = "/home/jce";
 $dest_dir = "/";
 # Program
 my $log_text,$text,$error=0;

 if  ($ftp = Net::FTP->new("$host"))
 {
   if ($ftp->login("$login","$passwd"))
   {
     if ($ftp->cwd("$dest_dir"))
     {
 @local_files= `ls $source_dir/*.txt`;
 for($a=0;$a<=$#local_files;$a++)
 {
   chomp($local_files[$a]);
   if ($ftp->put("$local_files[$a]"))
   {
     $text = "Uploaded: \"$local_files[$a]\"\n";   }
   else
   {
     $text = "ERROR Uploading\n";
     $error=1;
   }
 }
     }
     $ftp->quit;
     }
     else
     {
 $text = "Bad Login or password\n";
 $error=1;
     }
 }
 else
 {
 $text = "Error connecting to the host\n";
 $error=1;
 }
 print $text;


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


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

Date: 2 Feb 2001 17:40:20 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Help: Script only runs if ' -w' is on line 1
Message-Id: <slrn97ls80.su1.vek@pharmnl.ohout.pharmapartners.nl>

On 2 Feb 2001 15:01:31 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:

>In article <7Mue6.1029$%3.33689@ozemail.com.au>, Ron Savage wrote:
>>
>>vim says it's a Unix file format, not DOS.
>
>Are you sure about that?
>
>  perl -0777 -ne 'print $ARGV.(/\cM/ ? " DOES":" does not")." have CRs\n"'
>
>
o


If vim says unix file format, then any CRs will become visible as ^M
in the display, just like it always is in plain old vi.  


Didn't think perl was so picky about CRs as some other unix programs are.



Villy


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

Date: 2 Feb 2001 18:10:39 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Help: Script only runs if ' -w' is on line 1
Message-Id: <slrn97lu0v.udn.abigail@tsathoggua.rlyeh.net>

Villy Kruse (vek@pharmnl.ohout.pharmapartners.nl) wrote on MMDCCXII
September MCMXCIII in <URL:news:slrn97ls80.su1.vek@pharmnl.ohout.pharmapartners.nl>:
~~ On 2 Feb 2001 15:01:31 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
~~ 
~~ >In article <7Mue6.1029$%3.33689@ozemail.com.au>, Ron Savage wrote:
~~ >>
~~ >>vim says it's a Unix file format, not DOS.
~~ >
~~ >Are you sure about that?
~~ >
~~ >  perl -0777 -ne 'print $ARGV.(/\cM/ ? " DOES":" does not")." have CRs\n"'
~~ >
~~ >
~~ o
~~ 
~~ 
~~ If vim says unix file format, then any CRs will become visible as ^M
~~ in the display, just like it always is in plain old vi.  
~~ 
~~ 
~~ Didn't think perl was so picky about CRs as some other unix programs are.


It's not perl that's picky, it's the kernel. If your first line is

    #!/usr/local/bin/perl^M

the kernel will try to execute '/usr/local/bin/perl^M', and fail.

If your first line is:

    #!/usr/local/bin/perl -w^M

the kernel will execute '/usr/local/bin/perl' with argument '-w^M'.
*Then*, and only then gets perl a change to ignore a ^M.



Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


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

Date: Fri, 02 Feb 2001 18:43:27 GMT
From: "Charles Warner" <charleswarner@bigfoot.com>
Subject: mod_perl opinion needed
Message-Id: <jdDe6.1488$0E.213282@newsread1.prod.itd.earthlink.net>

Hello,

I've been writing simple perl scripts for some time now and am about to take
on a project that is basically a whole web site run by one perl script
called on all pages with different query strings to tell the script what to
output.

All pages will be stored in an SQL database in two tables. One for the
formatting of the page (title, colors, what images to place, etc...) and the
other containing the page's content.

I plan on using mod_perl and Apache::DBI to maintain a constant connection
to the database. My questions is: do you forsee any problems in doing a site
in this manner? Also, I read the man pages on Apache::DBI and am I to
understand that I don't change any code in my scripts? What I understood is
that when I call use DBI and then open my connection to a handle that it
just checks to see if it is still connected and if it is moves on.

Thanks for your help!

Charles Warner




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

Date: 02 Feb 2001 14:00:10 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: mod_perl opinion needed
Message-Id: <m3g0hw6hc5.fsf@mumonkan.sunstarsys.com>

"Charles Warner" <charleswarner@bigfoot.com> writes:

> Hello,
> 
> I've been writing simple perl scripts for some time now and am about 
> to take on a project that is basically a whole web site run by one perl 
> script called on all pages with different query strings to tell the 
> script what to output.
> 
> All pages will be stored in an SQL database in two tables. One for the
> formatting of the page (title, colors, what images to place, etc...) and 
> the other containing the page's content.
> 
> I plan on using mod_perl and Apache::DBI to maintain a constant connection
> to the database. My questions is: do you forsee any problems in doing a 
> site in this manner? 

Actually, it should really fly under mod_perl, since your codebase 
is common to all the pages.  Be sure you preload everything you need 
at server startup, and watch your memory usage very carefully.

> Also, I read the man pages on Apache::DBI and am I to understand that I 
> don't change any code in my scripts? 

Yes; also you should call prepare_cached vs prepare whenever possible 
(not sure that this is really necessary with Apache::DBI, but with 
plain old DBI it speeds things up a little).

> What I understood is that when I call use DBI and then open my connection 
> to a handle that it just checks to see if it is still connected and if it 
> is moves on.

Yup.  Overloading + memoization at it's very finest.

Be sure to read the mod_perl documentation carefully, and get to

http://perl.apache.org/guide

to tweak things once you're up and running.

Best.
-- 
Joe Schaefer



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

Date: Fri, 02 Feb 2001 16:25:51 GMT
From: Jonny Nystroem <jonny.nystroem@telia.com>
Subject: Newbie question: Creating L/Ps in a DBM
Message-Id: <3A7B5D2C.E2D94FD4@telia.com>

Hello. I have a problem.
I wanīt to create a script(CGI) for a web-based form where you input
some values(in this case answers, but other than that a username of
their choice and a password of their choice). The script then checks the
answers and if they are correct it continues by adding the the selected
username/password to the database which contains the different
usernames/passwords for the protected area. After the script processed
all this it continues onward to a login-page where you can type in your
username/password and then get access to the protected area.

I know the basics(the really, REALLY basics) of doing this, I can create
the HTML and submit the whole thing into an CGI but I do not know how to
get the script to check if the answers supplied is correct and
then(based on that) proceed with putting the username/password into the
database and then by that give access to the restricted parts of the
site.
About the answer part, I guess Iīm supposed to use "if" to check if the
answers are correct and if they are not then stop the processing of the
script and let the user try again. The problem here is that I donīt know
how to compare and check names/words, only digits and numerical values.
Next step:
If the answers are correct I thought that a proper solution would be to
transfer the supplied username/password into a string and then write
them into the database to give that u/p proper access. What do you think
of this?

Could someone please try to help me with this? I donīt have the
knowledge to properly use the bits and pieces of code that people use to
help other solve their problems, so if you are so kind and try to help
me, please consider my newbie-status.
Iīm sorry if I didnīt browse through all the 13636 posts trying to find
a solution to my problem, but Iīve just browsed through more than 1500
posts in another thread so Iīm kinda sore in the brain. : )
The script is supposed to run on a Unix/Apache rig, just so you know.
Once again: Could someone please help me with this?



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

Date: Fri, 2 Feb 2001 11:53:19 -0500
From: "News" <dpmurphy@emc.com>
Subject: Regex - make more than one change on a line
Message-Id: <95eojr$37i2@emcnews1.lss.emc.com>

I would like to make more than one character substitution on a line.
I now have two separate commands, such as:

$VAR =~ s/old1/new1/g;
$VAR =~ s/old2/new2/g;

Can I make both (or more) substitutions with one command?

Thanks.





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

Date: 02 Feb 2001 12:31:03 -0500
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: Regex - make more than one change on a line
Message-Id: <m33ddx9elk.fsf@vpnrel.cisco.com>

"News" <dpmurphy@emc.com> writes:

> I would like to make more than one character substitution on a line.
> I now have two separate commands, such as:
> 
> $VAR =~ s/old1/new1/g;
> $VAR =~ s/old2/new2/g;
> 
> Can I make both (or more) substitutions with one command?
> 
$VAR =~ s/\bold(\d+)\b/new$1/g;

-- 
vjm


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

Date: 02 Feb 2001 17:50:37 +0000
From: nobull@mail.com
Subject: Re: Regex - make more than one change on a line
Message-Id: <u94rydezyq.fsf@wcl-l.bham.ac.uk>

"News" <dpmurphy@emc.com> writes:

> I would like to make more than one character substitution on a line.
> I now have two separate commands, such as:
> 
> $VAR =~ s/old1/new1/g;
> $VAR =~ s/old2/new2/g;
> 
> Can I make both (or more) substitutions with one command?

Yes, but you may find it is less efficient.

You could do something like:

s/(old1)|(old2)/("new1","new2")[$#- - 1]/eg;

Note: @- is new in 5.6.  $#- is the index of the last capturing
subexpression to have matched.  Capturing subexpressions index from 1.

Oh, hang on, you said _character_ substitutions!  Don't use s///g use
tr///

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


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

Date: Fri, 02 Feb 2001 17:26:39 GMT
From: tanase_costin@my-deja.com
Subject: saving the name and value for a variable
Message-Id: <95eqk0$960$1@nnrp1.deja.com>

 Hi everybody,

 Does anybody have a hint how to find out the name of a variable, as it
is used in the Perl script? What I mean is:

 I use the following syntax

  $avar = 1;
  print HANDLE "\$avar = ".$avar."\n";

 As I repeat this kind of lines over and over in my script I would like
 to define a function, "nameofvar" in such a way that

 nameofvar($avar) to return the name used in my program for it.


 This would help me in doing

 sub savevar{
  my( $handl_, $var_) = @_;
  my $name_ = &nameofvar($var_);
  print $handl_ $name." = ".$var_."\n";
 }





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


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

Date: Fri, 02 Feb 2001 17:42:22 +0000
From: Sebastian Willert <s.willert@media-net.de>
Subject: Strange behaviour of "Error.pm"
Message-Id: <3A7AF17E.5070501@media-net.de>

Hi,

i think I've found a serious bug in the Error.pm module (perhaps I'm just
terrible stupid but i've tryed to solf this problem for 4 hours now and
still got no idea whats going on!).

I've been using Error.pm for some while now and it works fine when used
within one package or outside subs. When within subs of non-main packages
it shows some very strange behaviour although. When your lucky, your
catch clauses simply are ignored but I've also seen Error.pm to iterate
through _all_ clauses available or just croak that no 'with' is associated
with the exception... after executing the respective clause.


And now to the gory details:
I am using
   Error.pm      Version 0.13
   Perl          Version 5.005_03
   on RedHat Linux 6.1 - i386

Here an example script that failed to do what I expect:

---cut---

use Error qw(:try);


#------------------------------------------------------------------------------

@Thrower::Exception::ISA =  qw(Error);

package Thrower;
sub new() { bless {}, $_[0]; }
sub throw_exception { throw Thrower::Exception; }


#------------------------------------------------------------------------------

@Catcher::Exception::ISA =  qw(Error);

package Catcher;
sub throw_exception { throw Catcher::Exception; }
sub own {
    try { &throw_exception(); }
    catch Exception with { warn "Neither this exception is caught" }
}
sub foreign {
    try { Thrower->throw_exception(); }
    catch Thrower::Exception with { warn "nor this" }
    otherwise { warn "even this is ignored" };
}

#------------------------------------------------------------------------------

package main;

sub catch_exception {

   try{ Catcher->own(); }
   catch Catcher::Exception with {warn "But this is caught ..." };
};

&catch_exception();

try{ Catcher->foreign(); }
catch Thrower::Exception with {warn "and this also" };

#------------------------------------------------------------------------------

---cut---

If you need to see some of the other scripts causing even stranger things
just drop me a line... but they are a lot more complex (and partly
protected by a non-disclosure-agreement i've signed).

Thanks in advance,
   Sebastian



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

Date: 2 Feb 2001 17:46:58 GMT
From: The WebDragon <nospam@nospam.com>
Subject: To Format or not to Format (was Re: perl report generation)
Message-Id: <95erqi$gfc$0@216.155.33.77>

In article <3A795E38.9700B7BC@transarc.ibm.com>, jbroz@transarc.ibm.com 
wrote:

 | I have used it and still do so but most of the scripts I write have 
 | no need for reports. I suspect this is one of the least used bits of 
 | perl, but this is just a guess. Still, that's no reason not to learn 
 | it.

Speaking of format.. I've glanced at it in the past and thought it 
interesting, but haven't studied it in depth yet.. 

I have a short script I've been working on to generate a report based on 
what modules you have installed and print out the version #'s vs the 
CPAN current version.

My question is, is what I have adequate or should I try playing with 
format? I've marked the relevant section with (*) in a comment

#!/usr/bin/perl -w
# visualized and created by Scott R. Godin, 12/30/2000 
# last update Jan 31, 2001
# print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# http://www.webdragon.net/
######

  use strict;
# current macperl port of Storable; 
#http://www.perl.com/CPAN/authors/id/CNANDOR/Storable-0.6@4-bin-1-Mac.tgz
  use Storable 0.604; 
  use File::Spec 0.82; 
# current version 1.59. cpan> install CPAN ... 
# do NOT install Bundle::CPAN!!! (breaks things on 5.004 MacPerl)
  use CPAN 1.59; 
# set to 0 if you don't want the output redirected to a file 
# (under MacOS). 
  use constant MACOS_SAVEFILE => 1; 

my $savefile  = 
  File::Spec->catfile( File::Spec->curdir(), 'ModuleCheck.txt' );
my $storefile = 
  File::Spec->catfile( File::Spec->curdir(), 'installed_modules.stor' );

sub checkmodule () {
    my %installed_modules = ();
    print "Checking Modules...Please stand by.. the cursor will spin for 
a minute or so.\n";
    print "GO get some coffee! You Deserve it! :-D\n";
    for my $mod (CPAN::Shell->expand("Module","/./")){
        next unless $mod->inst_file;
        # MakeMaker convention for undefined $VERSION:
        $installed_modules{ $mod->id } = 
         [(($mod->inst_version eq "undef") ? '' : $mod->inst_version), 
          (($mod->cpan_version eq "undef") ? '' : $mod->cpan_version),];
    }
    store \%installed_modules, $storefile; #storable
    print "Done and stored.\n\n";
}
sub readstored () {
    my $ref = retrieve($storefile) or die "$!"; # storable again
    my $last = '';
    # did this because not enough buffer space to display entire list in 
    # MacPerl. bleh. include for MacOS as there's no way to redirect
    # buffer output to a file, otherwise send to buffer and let user 
    # direct it to a file if they so choose, via a unix convention like 
    # ./moduletest.plx > outputfile.txt
    if ( $^O eq 'MacOS' && MACOS_SAVEFILE) {
        print "Now retrieving Module data; output sent to $savefile\n";
        open STDOUT, ">$savefile" or die "$!";
    }
    print "Listing all Installed Modules and Versions where 
available...\n\n";

    # (*) this part is what I'm inquiring about
    foreach  (sort {uc($a) cmp uc($b)} keys %{$ref}) {
         /^(\w+)\:{0,2}.*$/;
        my $this = $1;
        print  "-" x 87, "\n" if ($last ne $this);
        printf "Installed Module: %-35s", $_, ","; 
        printf " Version: %-9s", $ref->{$_}[0], ",";
        printf " CPAN: %-10s", $ref->{$_}[1];
        print  "\n";
        $last = $this;
    }
}

# if the storefile already exists, use it to save time. 
# delete it to re-run the check. 
if (-e $storefile) {
    print "Using existing .stor file for brevity.\nDelete '$storefile' 
and re-run the script to if you wish to update.\n\n";
    readstored;
} else {
    checkmodule;
    readstored;
}

exit 0;

-- 
unmunge e-mail here:
 print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 

       ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Fri, 02 Feb 2001 16:26:30 GMT
From: bluearchtop@my-deja.com
Subject: Using CPAN.pm without upgrading to Perl 5.6
Message-Id: <95en39$5h0$1@nnrp1.deja.com>

I love the CPAN.pm module. Makes installations easy. However, I can not
upgrade to Perl 5.6. Some modules, when installing, automatically try
to update to Perl 5.6.  How can I turn this off?

Gracias.


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


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

Date: 2 Feb 2001 18:24:07 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Using CPAN.pm without upgrading to Perl 5.6
Message-Id: <95eu07$gfc$1@216.155.33.77>

In article <95en39$5h0$1@nnrp1.deja.com>, bluearchtop@my-deja.com 
wrote:

 | I love the CPAN.pm module. Makes installations easy. However, I can not
 | upgrade to Perl 5.6. Some modules, when installing, automatically try
 | to update to Perl 5.6.  How can I turn this off?


Some module updates are part and parcel of the 5.006 release of Perl, 
and thus cannot be updated beyond what you have already unless you can 
also update to 5.006 .. this may in some instances be because they are 
part of a standard distribution, or because they now use such constructs 
that have been introduced since 5.004 or 5.005. 

it's always a good idea to 

cpan> i Some::Module 

or 

cpan> i /Some::Module/ 

before trying to download and install, to see whether it is or not. 

Might I also suggest that you get the Storable module.. CPAN can use 
this to cache the Metadata and make reloading CPAN somewhat faster.

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Fri, 2 Feb 2001 11:31:02 -0700
From: "Phyllis Choate" <choate@spot.colorado.edu>
Subject: weekly calendar
Message-Id: <95euhh$rnf$1@peabody.colorado.edu>

I have a monthly calendar, but would like to look at just one week...in the
calendar format....in otherwords not just text but a calendar week, with
event listing for each day of the week.

I can't figure out the correct code....any help out there?


thanks in advance





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

Date: Fri, 2 Feb 2001 17:00:00 +0000 (UTC)
From: aym@aym4.domicile.fr (Andre Majorel)
Subject: What is the context for grep's EXPR ?
Message-Id: <slrn97ltj6.pc.aym@aym4.domicile.fr>

What context is grep's EXPR evaluated in ?

-- 
André Majorel <amajorel@teezer.fr> (it's really "teaser")
http://www.teaser.fr/~amajorel/
Canada's Latest Weapon: SNOW!! -- Brendan Dillon


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

Date: 02 Feb 2001 17:55:04 +0000
From: nobull@mail.com
Subject: Re: What is the context for grep's EXPR ?
Message-Id: <u91ythezrb.fsf@wcl-l.bham.ac.uk>

aym@aym4.domicile.fr (Andre Majorel) writes:

> What context is grep's EXPR evaluated in ?

$ perl -e 'grep { sub{ print wantarray ? "list\n" : "scalar\n" }->() } $_'
scalar

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


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

Date: Fri, 02 Feb 2001 17:03:31 +0100
From: "Schmid Konrad" <kosc@online.de>
Subject: Win32::API
Message-Id: <01c08d30$95550ea0$6300a8c0@computername>

Hello,
I'am new with Win32::API.

Does somebody know how I can load win-DLL's, which have no parameters. In
the documention there are only parameters like 

I: value is an integer
N: value is a number (long)
P: value is a pointer (to a string, structure, etc...)

But there is no void-argument. If i miss the parameter (     $tst = new
Win32::API("tst", "tst", [], I); ), my windows begins filling up my memory
and the function in the DLL isn't called.

Thanks.

Regards
Konrad





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

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


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