[18343] in Perl-Users-Digest
Perl-Users Digest, Issue: 511 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 17 06:06:34 2001
Date: Sat, 17 Mar 2001 03:05:10 -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: <984827109-v10-i511@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 17 Mar 2001 Volume: 10 Number: 511
Today's topics:
Re: `pwd` doesn't work on all servers? nobull@mail.com
Re: binary files <bart.lateur@skynet.be>
Re: binary files <uri@sysarch.com>
DBI <tfiedler@zen.moldsandwich.com>
Re: dbmopen-Error <SiStie@nuclear-network.com>
Re: dbmopen-Error <SiStie@nuclear-network.com>
Re: Didn't work. <mjcarman@home.com>
directory and moving files on unix <milliwave@rfengineering.freeserve.co.uk>
Re: Firewall in Perl (Miguel Cruz)
Re: many "used only once, possible typo" warnings in CG nobull@mail.com
Re: Memory Usage (Miguel Cruz)
Re: need a sub print_with_newline(), but what to do wit <mjcarman@home.com>
Re: Perl FAQ? <kellyboy@nospanner>
Re: smtp (Miguel Cruz)
Re: Spaces in path to perl script (NT) <paul@indigoproductions.be>
Re: Spaces in path to perl script (NT) <paul@indigoproductions.be>
Status: 403 Forbidden <pbm@NOSPAMiotp.demon.co.uk>
Re: Subroutine in separate files <uri@sysarch.com>
Re: Subroutine in separate files <wuerz@yahoo.com>
Re: Subroutine in separate files <wuerz@yahoo.com>
The printout works, but how do i prevent blank inputs? <kalle@tvettsvamp.a.se>
Re: The printout works, but how do i prevent blank inpu <uri@sysarch.com>
Re: Username/password from an HTML form nobull@mail.com
using variable content as constant name <rheydenr@htwm.de>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Mar 2001 09:55:59 +0000
From: nobull@mail.com
Subject: Re: `pwd` doesn't work on all servers?
Message-Id: <u9pufg4t3k.fsf@wcl-l.bham.ac.uk>
Benjamin Sugars <bsugars@canoe.ca> writes:
> On Fri, 16 Mar 2001, Chris Stith wrote:
>
> > Benjamin Sugars <bsugars@canoe.ca> wrote:
> >
> > > On Thu, 15 Mar 2001, John W. Krahn wrote:
> > >
> > >> use Cwd;
> > >> $dir = cwd;
> >
> > > I think Cwd::cwd actually uses `pwd` internally on Unix systems.
> >
> > It does, but that's not as portable. If you know your program
> > will never run anywhere else, then that could work.
>
> The point was that the OP was having problems with `pwd` so switching to
> Cwd::cwd won't help.
But switching to Cwd::getcwd will. Of course if your system
adminstrator has decided that you are not allowed to know your PWD
and set directory permissions accordingly then nothing you can do short
of asking her to change her mind is going to help.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 17 Mar 2001 10:33:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: binary files
Message-Id: <cdf6bt84a6k44b52o5mes03kbvh9dv4700@4ax.com>
Uri Guttman wrote:
>so .3 + .7 would work as expected with no problems,
>unlike in binary.
But 1/3 + 2/3 still doesn't work.
--
Bart.
------------------------------
Date: Sat, 17 Mar 2001 10:48:42 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: binary files
Message-Id: <x7pufg6585.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> Uri Guttman wrote:
>> so .3 + .7 would work as expected with no problems,
>> unlike in binary.
BL> But 1/3 + 2/3 still doesn't work.
so use one of the russian trinary machines. :)
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: Sat, 17 Mar 2001 06:34:21 GMT
From: Ted Fiedler <tfiedler@zen.moldsandwich.com>
Subject: DBI
Message-Id: <Pine.LNX.4.33.0103170134570.1748-100000@zen.moldsandwich.com>
why wont this work? I just want to update this database using DBI. There
is also a timestamp field, But I left it out - I can see it helping or
hurting since its ok as NULL.
use DBI();
my
$dbh=DBI->connect("DBI:mysql:database=JOURNALDATA;host=localhost","username","password",{'RaiseError'=>1});
$dbh->do("INSERT INTO JDATA values (1,".my
$jbh->id('auto_increment').")");
$dbh->do("INSERT INTO JDATA values (1,".$jbh->topic("now").")");
$dbh->do("INSERT INTO JDATA values (1,".$jbh->song("now song").")");
$dbh->do("INSERT INTO JDATA values (1,".$jbh->body("This is the ew
body!").")");
$dbh->disconnect();
~
When I run this:
[tfiedler@zen SQL-PERL]$ ./jinsert_DB.pl
I get this:
Can't call method "id" on an undefined value at ./jinsert_DB.pl line 6.
Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().
------------------------------
Date: Fri, 16 Mar 2001 20:45:44 +0100
From: Simon Stiefel <SiStie@nuclear-network.com>
Subject: Re: dbmopen-Error
Message-Id: <Pine.LNX.4.31.0103162038470.874-100000@server.stiefel.priv>
On Fri, 16 Mar 2001, John Hall wrote:
> I don't pretend this to be the definitive answer, but I have a few ideas,
>
> 1. Don't know what 'undef' is supposed to do in that context. Usually i'v=
e
> seen chmod like file attributes go there:
>
> dbmopen (%DB,"/var/pos/pos",644) || die "fehler: $!";
Sorry, that doesn't work too...
> 2. If you really can't figure out how to get a lock on the file, have you
> tried 'making a copy' of the file(s) and then opening those?
Yes, of course, but without success...
> 3. Newer versions of the dbmopen stuff by default use one file 'pos.db'
> instead of 2..
This version of DBM uses 2 files (dir & pag).
> 4. If something is periodically writing to those files, put a 'wait for
> lock' action in your code so that if it can't get a lock it tries again a
> few milliseconds later.
Yes, but now I'm still testing this script.
Or, can somebody show me, how to do that with "tie"?
Perhaps it will work with that...
Mit freundlichen Gr=FC=DFen, .~. Open Minds.
with best regards /V\ Open Sources.
// \\ Open Future!
Simon Stiefel /( )\_ I N U X
^ ~ ^
--=20
|Simon Stiefel | Zwerbachstrasse 17 | 72555 Metzingen-Glems | Germany |
|SimonStiefel@nuclear-network.com | http://www.nuclear-network.com |
|ICQ#: 20196644 | phone: +49(0)7123/379070 | fax: +49(0)179/335990106 |
|Tux#: 114751 | PingoS - Linux-User helfen Schulen | Powered by LiNUX |
------------------------------
Date: Fri, 16 Mar 2001 21:32:35 +0100
From: Simon Stiefel <SiStie@nuclear-network.com>
Subject: Re: dbmopen-Error
Message-Id: <Pine.LNX.4.31.0103162129001.1294-100000@server.stiefel.priv>
On Fri, 16 Mar 2001, Simon Stiefel wrote:
> Hi,
>
> yes, I know, I better should use "tie", but I don't know how to do that.
> ;-)
>
> I've written a CGI-Script. This CGI-Script has to open a DBM-File, which
> is in /var/pos.
> But everytimes when I it tries to open it, an error appears which says,
> that the ressource is currently not availible.
> The DBM-File(s) (pos.dir & pos.pag) exist of course.
>
> And even if I copy those files in the cgi-bin-directory it can't open it.
I got it. The script which creates those DBM-files was wrong...
Sorry, but this error-messages was a little bit silly...
Mit freundlichen Gr=FC=DFen, .~. Open Minds.
with best regards /V\ Open Sources.
// \\ Open Future!
Simon Stiefel /( )\_ I N U X
^ ~ ^
--=20
|Simon Stiefel | Zwerbachstrasse 17 | 72555 Metzingen-Glems | Germany |
|SimonStiefel@nuclear-network.com | http://www.nuclear-network.com |
|ICQ#: 20196644 | phone: +49(0)7123/379070 | fax: +49(0)179/335990106 |
|Tux#: 114751 | PingoS - Linux-User helfen Schulen | Powered by LiNUX |
------------------------------
Date: Sat, 17 Mar 2001 05:27:37 GMT
From: Michael Carman <mjcarman@home.com>
Subject: Re: Didn't work.
Message-Id: <3AB2F61C.563B5839@home.com>
Jim Kroger wrote:
>
> Hi Michael, it didn't work.
Hrm. Looking back at your original post, you gave "anna/cI" as one of
the example strings. I didn't look at it that closely at the time, but
now I noticed something. Did the debugger it print this:
"anna/cI"
or this?
"anna\cI"
[It may also be significant to know whether the debugger used double
quotes or single quotes to display the output.]
The second example (which is how I read your post) is a tab char. The
first is literally "forward-slash c capital-I" I've no idea why that
would be in your file, though. Could you cut and paste a few lines from
your SubNames file into a post? Maybe (with a little luck) we can figure
out what's going on then.
> I changed [...] to
>
> chomp(@subjects = `cat subNames`);
> foreach (@subjects) {
> s/^\s+//;
> s/\s+$//;
> }
>
> But the tab character at the end of each subject item is still there.
> Sorry if I'm misunderstanding.
No, that will clear out any leading and trailing blanks, so we must have
a different problem.
> I only have "Learning Perl" and it doesn't explain how to
> change $/.
It's a builtin variable. You just set it to whatever you want. e.g.
$/ = "\n\n"; # 'Paragraph' read mode
> I'm afraid I have little luck with the man pages, they are
> pretty impenetrable to me.
Don't despair, there's just a learning curve to struggle through when
you first get started. If you check the docs and are still stumped, post
here. (But let people know that you've tried the docs or you may get
nothing more than "RTFM.")
-mjc
------------------------------
Date: Sat, 17 Mar 2001 10:53:45 -0000
From: "Milliwave" <milliwave@rfengineering.freeserve.co.uk>
Subject: directory and moving files on unix
Message-Id: <98vfl8$i4e$1@news8.svr.pol.co.uk>
I would like to know how to direct files by creating a directory in the
current working directory, and
moving the "files" into that directory?
open(File Handle1 "original.txt")
open(File handle2 ">text.txt")
1) Now how do I make a directory and move text.txt and original.txt into
that directory
2)Then I would like to delete the original.txt from the current working
directory.
Thanking You
Kev
------------------------------
Date: Sat, 17 Mar 2001 07:49:47 GMT
From: mnc@admin.u.nu (Miguel Cruz)
Subject: Re: Firewall in Perl
Message-Id: <vGEs6.7038$on6.2832767@typhoon2.ba-dsg.net>
In article <98uifq$jl0$0@206.230.71.63>, Josiah Bryan <jdb@wcoil.com> wrote:
> im curious - does anyone have any good pointers at writing firewalls in
> perl? or even how to do a software implementation of a firewall? ive looked
> up "firewall theory" as wall as many variations in various search engines,
> and none seem to have any help. Can anyone point me to a resource or give me
> a general clue as to how i might write a firewall in perl? why would i want
> to? because i can!!!! :-) because perl is so good at everything else, and
> because i LOVE perl - i want to try to do my firewalls in perl as well! any
> help on this would be greatly appreciated! thanks all!
Various unixes and unix-alikes provide mechanisms whereby you can have
packets sent to the program of your choice for inspection and judgment. I'm
most familiar with FreeBSD, whose "IP_DIVERT" option makes this very simple.
You can have each packet diverted to a Perl program listening on a specified
socket, and that program can rewrite the packet, drop it, pass it on
unchanged, or send something back.
For lots of musings on firewall design, read the flurries of white papers
and concordances that accompany each of Linux's biweekly firewall
infrastucture overhauls. For all my smarminess, there is actually some good
info and thought in there.
When all is said and done, however, I'm guessing that performance will not
be that thrilling. Firewall code is usually heavily optimized since it's
such a potential bottleneck for all network operations. With Perl you can
only optimize so far down before you run into the fundamental complexity of
the interpreter. But for a modem it may be fine. Good luck - let us know how
it goes.
miguel
------------------------------
Date: 17 Mar 2001 10:38:45 +0000
From: nobull@mail.com
Subject: Re: many "used only once, possible typo" warnings in CGI.pm using import_names("UT");
Message-Id: <u9k85o4r4a.fsf@wcl-l.bham.ac.uk>
"Scott R. Godin" <webmaster@webdragon.munge.net> writes:
> import_names('UT');
> # [Fri Mar 16 17:12:47 2001] Dev:Pseudo: # Name "UT::mod_type" used only
> once: possible typo.
> I've got a LOT of params, so this generates about a page of diagnostic
> output.
>
> OTHER than supressing warnings (which I'd rather not do), is there any
> other better, more sophisticated way to work around this in Perl?
In Perl 5.6.0 you can supress warnings selectively.
use warnings;
no warnings 'once';
> Basically once the form is submitted and validated, I import the names
> into the UT:: namespace and then use them to generate the output of the
> template file.
Of course what you really want ideally is to supporess the 'once'
warning for symbols in the UT:: namespace only. The only way I can
see to do this is for you to use the old pre-5.6 wanring filtering
mechanism through $SIG{__WARN__}:
sub ignore_warning ($) {
my $old_warn_handler = $SIG{__WARN__};
my ($pattern) = @_;
$SIG{__WARN__} = sub {
my ( $warning ) = @_;
return if $warning =~ /$pattern/;
return &$old_warn_handler if $old_warn_handler;
print STDERR "$warning\n";
};
}
BEGIN { ignore_warning qr/^Name "UT::.+" used only once/ }
A completely different approach is simply to declare the variables.
{
package UT;
use vars qw( $mod_type $mod_description ); # And so on...
}
Finally you could ditch import_names().
> currently I'm using CGI.pm 2.74 although I just noticed that he released
> a slight modification recently. (the change notes don't indicate a fix
> for this either, so I'm not concerned that I'm missing something with
> *this* particular issue by not updating immediately)
There is no way for CGI.pm to fix this as these are compile time
warnings and CGI.pm does not know what the fields in the submitted
form are (or indeed the namespace you'll be importing into) until
runtime.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 17 Mar 2001 07:43:39 GMT
From: mnc@admin.u.nu (Miguel Cruz)
Subject: Re: Memory Usage
Message-Id: <LAEs6.367$Fb.430978@typhoon2.ba-dsg.net>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Best diagnostics is a matter of using very basic logic. Simply replicate
> conditions which causes your script to use more memory. Therein lies
> whatever it is you seek.
Mind if I pass that tip on to my doctor? Next time I have a headache he can
go hit someone in the head with a hammer to figure out what's wrong with me.
miguel
------------------------------
Date: Sat, 17 Mar 2001 05:53:09 GMT
From: Michael Carman <mjcarman@home.com>
Subject: Re: need a sub print_with_newline(), but what to do with print_with_newline STDERR "blabla"; ???????
Message-Id: <3AB2FC17.AF60C04D@home.com>
Murat Uenalan wrote:
>
> I simply want to write a print function which automatically
> prints an appending \n character, and should be a alternativ
> to normal print ! It seems very simple, but it is not !
>
> sub println
> {
> my $out = shift."\n";
>
> return print $out, @_;
> }
First, you need to pass a reference to a filehandle to your funtion. Are
you doing this?
Second, you aren't appending a newline after the output, you're
concatenating one to the value of your filehandle!
Also, the return() is kind of spurious there...
I'd write it this way:
sub println {
local *FH = shift;
print FH @_, "\n";
}
That way your filehandle looks like a filehandle. Some people have an
aversion to globs, though, and it's rumored that they'll eventually be
going away completely, so here's another way:
sub println {
my $FH = shift;
print $FH @_, "\n";
}
-mjc
------------------------------
Date: Sat, 17 Mar 2001 02:09:43 -0600
From: "kellyboy" <kellyboy@nospanner>
Subject: Re: Perl FAQ?
Message-Id: <tb66p9ivt3ssba@corp.supernews.com>
I forgot what it was that im trying to do...I moved on to something else...
Right now, I'm trying to make mod_perl to work with apache/php. After "make
install" ...now my apache doesnt seems to spit out the file I wanted whether
its .html/.php/.pl...grrrrr...
kellyboy
--
"Michael Carman" <mjcarman@home.com> wrote in message
news:3AB103C6.F539D577@home.com...
> kellyboy wrote:
> >
> > [...] these faq that yahoo came up still doesn't have answer to my
> > question... :-)
>
> Well, then it probably isn't an FAQ. Maybe a less frequently asked one.
> If you've consulted the docs and can't find an answer, this is the place
> to ask. What is it you're trying to do?
>
> -mjc
------------------------------
Date: Sat, 17 Mar 2001 07:39:38 GMT
From: mnc@admin.u.nu (Miguel Cruz)
Subject: Re: smtp
Message-Id: <_wEs6.7037$on6.2827201@typhoon2.ba-dsg.net>
jtjohnston <jtjohnston@courrier.usherb.ca> wrote:
> Below is my script.
> Below is what my browser spits back at me.
> Why does it do that? I just want to print the html I specified. It used
> to work fine?
> $smtp = Net::SMTP->new('interlinx.qc.ca', Debug => 1);
^^^^^^
I can't imagine that's helping much.
miguel
------------------------------
Date: Sat, 17 Mar 2001 10:21:07 GMT
From: Paul Goris <paul@indigoproductions.be>
Subject: Re: Spaces in path to perl script (NT)
Message-Id: <B6D8F921.ADC4%paul@indigoproductions.be>
in article Tsss6.1$Fb.92@typhoon2.ba-dsg.net, Miguel Cruz at mnc@admin.u.nu
wrote on 16/3/01 18:56:
> Paul Goris <paul@indigoproductions.be> wrote:
>> Sure, the problem apparently lies with NT/IIS I suppose, but it's also true
>> that directory names with spaces are no problem when calling regular html of
>> image files, whereas they are when you try to access a Perl script.
>> So I suppose my question isn't really off topic and I'm still hoping other
>> posters here would be aware of this issue and be able to give a clue about
>> what to do...
>
> I've had to deal with this back in my very unhappy IIS days. It occurred
> with any application set up as a server-side handler for a particular file
> type.
> The only solution at the time seemed to be to make sure the path contained
> no spaces.
>
> With a static HTML page or image, it locates the file using its normal
> mechanism and handles it appropriately. With a file that's being handled
> externally, it has to take the file name and provide it as input to the
> handler (in your case, the Perl interpreter). And this is where it fails -
> it does not package the spaces properly. I would suggest using symlinks but
> I guess Windows still doesn't have those (does it?). IIS does not seem to
> follow shortcuts so that won't work.
Miguel, I think your analysis of what's going on here is definitely the
correct one. Shortcuts will not work and for the rest... my normal working
environment is on Apple Macintosh, we use Windows and NT for web serving
purposes that's all... so I'm afraid my own expertise in this matter is far
too limited to solve the problem myself.
Anyway, I've come to the point now where I realise that, as has been
suggested by other, smarter people than me, my problem/question is more
appropriate in a Win/IIS newsgroup.
So that's what I'll try and see what happens :-).
Thanks for your reaction!
Paul Goris
>
> miguel
------------------------------
Date: Sat, 17 Mar 2001 10:24:31 GMT
From: Paul Goris <paul@indigoproductions.be>
Subject: Re: Spaces in path to perl script (NT)
Message-Id: <B6D8F9ED.ADC5%paul@indigoproductions.be>
in article lrh4btgn24uchsakc24bhml327knn95o45@4ax.com, Lou Moran at
lmoran@wtsg.com wrote on 16/3/01 18:12:
> On Fri, 16 Mar 2001 13:30:45 GMT, Paul Goris
> <paul@indigoproductions.be> wrote wonderful things about sparkplugs:
>
>> The obvious solution would be to eliminate the spaces from the directory
>> names, but unfortunately that is not possible.
>
> This isn't exactly a Perl question but since I know the answer...
>
> Use the 8.3 name.
>
> For instance
>
> C:\Program Files 8.3s to C:\Progra~1
>
[...]
Well thanks, but unless I'm missing something here, what you suggest would
work if I was trying to reference a file from within a script - which I'm
not.
What happens is that IIS can't find the script when it's being called from a
browser, so there are no spaces in the script itself.
ciao,
Paul Goris
------------------------------
Date: Sat, 17 Mar 2001 09:48:14 +0000
From: In off the Post <pbm@NOSPAMiotp.demon.co.uk>
Subject: Status: 403 Forbidden
Message-Id: <gHVqFCAeLzs6Ewkx@iotp.demon.co.uk>
I need to send a 403 HTTP header, which will then be handled by an
Apache ErrorDocument (which works) which will re-direct the user to a
specified page.
Why doesn't this perl script work?
print "Status: 403 Forbidden\n\n";
Cheers,
Peter
--
In off the Post, PO Box 442, NOTTINGHAM, NG1 1PE. ENGLAND
Phone: +44 (0) 115 941 5132 Fax: +44 (0) 115 941 1634
e-mail: pbm@iotp.co.uk http://www.iotp.co.uk
------------------------------
Date: Sat, 17 Mar 2001 05:05:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Subroutine in separate files
Message-Id: <x7snkd56jh.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> The originating author did not ask how to use a module,
G> how to use a package name, how to use an object or whatever.
G> He asked how to mount his subroutines in a separate "file"
G> or files, whatever he means by this.
mount? he never said mount. file? you don't know whata file is? or what
a file of code is? haha!
G> So far, I have read no respondent to this thread who has
G> offered any help or advice worth diddly-squat. What I have
G> read is lame references to "use" and "require" with no
G> notes on how much work is involved in using those pragmas.
first off those are not pragmas, they are perl commands. secondly, is
this so complex:
require 'foo.pm' ;
use foo ;
if those are complex to you, i can understand.
G> I have offered advice which may or may not be applicable,
it was NOT applicable so why offer it.
G> lacking any clear parameters as I noted originally. My
G> comments are helpful, expanded and include a caution note.
you comments were not helpful. they went in a totally different
direction that the OP wanted. he wants to split a single script into
multiple files. this is accomplished with the use and require commands
which are trivial to learn about.
G> You geeks have offered nothing but a display of very
G> poor reading comprehesion skills, as is so common.
we love how you think we all have no comprehension skills and yet you
do. wonder what all our bosses must think. maybe you should go out and
get hired in a perl job already. let us know what company would dare
hire you. i will avoid buying any of their products or services.
G> Like I often say, DUH!
yes, you say that all the time. you just spell it in computer gibberish.
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: Sat, 17 Mar 2001 06:32:43 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: Subroutine in separate files
Message-Id: <170320010632438989%wuerz@yahoo.com>
In article <3AB2EF19.E6A71F03@stomp.stomp.tokyo>, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:
> Not only are both you and Uri displaying a lack of knowledge
> about LWP as commented by myself previously, you are both
> displaying a lack of prerequisite reading comprehension
> skills qualifying both of you as viable and valid
> participants of this newsgroup. It is clear you are not.
I will gladly admit that my understanding of the intricacies of the LWP
group of modules is sketchy at best, having never been particularly
compelled to use any of them. I do, however, recognize the context of
the original poster's question -- something that my background in
computer programming enables me to. Obviously you are lacking this
background, and are therefore far from qualified to give any advice to
people who clearly demonstrate more understanding of the subject matter
by merely asking the question.
> The originating author did not ask how to use a module,
> how to use a package name, how to use an object or whatever.
Oh, he certainly did not. Let's look at his question again, shall we?
| I have a rather large perl script that I have broken into several
| subroutines. For manageability, I would like to keep the subroutines
| in separate files.
This is something so common that virtually every programming language
(with the exception of perhaps befunge) provides a canonical mechanism
to achieve that goal. You don't know this, however, since you do not
have sufficient experience as a computer programmer. This is
exceptionally well demonstrated by your very own words:
> He asked how to mount his subroutines in a separate "file"
> or files, whatever he means by this.
^^^^^^^^^^^^^^^^^^^^^^^^^
(emphasis added by me.)
> So far, I have read no respondent to this thread who has
> offered any help or advice worth diddly-squat. What I have
> read is lame references to "use" and "require" with no
> notes on how much work is involved in using those pragmas.
Well, let's see how much work is involved exactly. Since require (at
the basic level) and use (at the more advanced level) are the
mechanisms provided by Perl to include separate source files in a
master script, they would be rather pointless if they required
extraneous manipulation of any kind. So let's keep it basic for now and
look at require. Let's assume that the parts of the script in question
is in a file called 'script.pl'. Then, we'd have to write:
require "script.pl";
-- and we'd have to add:
1;
to the end of the file script.pl -- as the only non-obvious
manipulation.
> I have offered advice which may or may not be applicable,
> lacking any clear parameters as I noted originally. My
> comments are helpful, expanded and include a caution note.
You have given a philosophical statement that bordered on advocacy. You
do, however, have a chance to redeem your credibility as a participant
in this conversation by demonstrating, just as I did in the previous
paragraph, how the original poster's goal might be achieved using any
module of your choice from the LWP group. Feel free to make any
assumptions that you feel you must make, but do state them.
I must confess in all honesty, that I do not expect you to actually do
that. Your grasp of the most basic concepts of programming is so weak
that you simply won't be able to. We all will have to live with it.
> Is this your twenty-eighth day? You seem to
> be a tad bit cranky today, Frank.
Oh, but I'm amusing myself spendidly, Shitting Bull.
TF
------------------------------
Date: Sat, 17 Mar 2001 06:36:39 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: Subroutine in separate files
Message-Id: <170320010636393165%wuerz@yahoo.com>
In article <170320010632438989%wuerz@yahoo.com>, Mona Wuerz
<wuerz@yahoo.com> wrote:
> TF
Oh just look, now the cat is out of the bag. What silliness. I guess I
just couldn't resist. Won't happen again.
Duh, indeed.
-mona
------------------------------
Date: Sat, 17 Mar 2001 10:19:07 GMT
From: "Kalle Anka" <kalle@tvettsvamp.a.se>
Subject: The printout works, but how do i prevent blank inputs?
Message-Id: <vSGs6.1153$4N4.92839@newsc.telia.net>
The printout works, but how do i prevent blank inputs?
If I submit an empty form I'l get "yes"
and
The script below doesn't consern about exact match.
If the "$filename" contains "someone@somewere.com<br>, and I submit
"someone", i'l get "OK".
open INFILE, $filename or die "Can't open '$filename': $!";
$line;
while (<INFILE>) {
chomp; # drops trailing newlines; can omit if undesirable
$line = $_, last if /^\Q$email/o; # substr match!
}
close INFILE;
print "Yes<br>\n\n" if defined $line;
print "No<br>\n\n" unless defined $line;
------------------------------
Date: Sat, 17 Mar 2001 10:59:28 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: The printout works, but how do i prevent blank inputs?
Message-Id: <x7n1ak64q7.fsf@home.sysarch.com>
>>>>> "KA" == Kalle Anka <kalle@tvettsvamp.a.se> writes:
KA> The printout works, but how do i prevent blank inputs?
KA> If I submit an empty form I'l get "yes"
you show reading from a file. i don't know what form you are talking
about. is the address $email coming from a form? just check it that is
is not all blank and don't do the file search if it is.
if ( $email =~ /^\s*$/ ) {
print "Enter an email address\n" ;
exit ;
}
KA> and The script below doesn't consern about exact match. If the
KA> "$filename" contains "someone@somewere.com<br>, and I submit
KA> "someone", i'l get "OK".
KA> open INFILE, $filename or die "Can't open '$filename': $!";
good, you check the result of open.
KA> $line;
what is that line for? it doesn't do anything. did you mean to declare
it with my?
KA> while (<INFILE>) {
KA> chomp; # drops trailing newlines; can omit if undesirable
that is safe to keep.
KA> $line = $_, last if /^\Q$email/o; # substr match!
you can make the regex match the complete string with anchors. you have
the ^ anchor but are missing the $ to anchor to the end of th string.
and there is no need for the /o modifier in most cases anymore. perl
won't recompile a regex unless some variable in it has changed.
$line = $_, last if /^\Q$email$/ ;
KA> }
KA> close INFILE;
KA> print "Yes<br>\n\n" if defined $line;
KA> print "No<br>\n\n" unless defined $line;
you test $line twice. it is better to test once:
if ( $line ) {
print "Yes<br>\n\n" ;
}
else {
print "No<br>\n\n" ;
}
or another way:
print $line ? "Yes<br>\n\n" : "No<br>\n\n" ;
there are many other ways to do that as well.
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: 17 Mar 2001 10:11:41 +0000
From: nobull@mail.com
Subject: Re: Username/password from an HTML form
Message-Id: <u9n1ak4sde.fsf@wcl-l.bham.ac.uk>
Mark Thompson <mark-lists@webstylists.com> writes:
> I've set up a simple password protection system using basic
> authentication with an .htaccess file and password file that works.
> When someone requests a page that is protected, the browser brings up
> a dialog box that asks for the username and password and if they enter
> the correct information, it gives them what they're looking for.
>
> What I'd like to do is have username and password fields on an HTML
> form with a submit button instead of a popup window that has the same
> functionality.
>
> Is this something that is possible?
Yes.
> I've spent all evening looking at
> FAQs and Perl manuals but haven't been able to find anything that says
> this is possible to do (I also haven't seen anything that says it's
> not possible either.)
Of course not, because this has has nothing to do with Perl. The
basic approach (HTML form with two fields, one a password field, a
script to validate the username/password against a file and then a
session ID using hidden fields, URL or cookie) is the same regardless
of the language chosen.
You may want to take a look at CGI::Persistent
> I already posted this in the cgi newsgroup but decided after the fact
> to post it here too
Bad call.
> since if this is possible, it will end up having
> to be done in Perl by myself.
Once you know how to do it in language independant terms the Perl
coding is trivial. But if you do have any questions (other than ones
trivally answerd by RTFM) then feel free to post them here.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 17 Mar 2001 09:45:13 +0100
From: Ralf Heydenreich <rheydenr@htwm.de>
Subject: using variable content as constant name
Message-Id: <3AB32419.5939701F@htwm.de>
Hi,
I have to take the content of a string-variable for a constant
reference.
I want to do something like this:
use constant FOO => 2;
@data=qw/abc def efg hij/;
$bar="FOO";
print "The value is: ", $data[ $$bar ];
This should result to "The value is efg", but it don't do this! How can
I fix this problem?
Greetings,
Ralf
(rheydenr@addcom.de)
------------------------------
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 511
**************************************