[18897] in Perl-Users-Digest
Perl-Users Digest, Issue: 1065 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 5 18:06:04 2001
Date: Tue, 5 Jun 2001 15:05:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <991778718-v10-i1065@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 5 Jun 2001 Volume: 10 Number: 1065
Today's topics:
Re: 2 questions about flock (Eric Bohlman)
Re: 2 questions about flock <flavell@mail.cern.ch>
Re: Any Emacs/Perl Gurus <skpurcell@hotmail.com>
Re: cerificate viewer <elijah@workspot.net>
CGI_Lite upload problem with Opera 5.x <drewhead.nospam@drewhead.org>
Re: DBD::ODBC and recursive functions... <cpryce@pryce.net>
Re: Deleting old files <godzilla@stomp.stomp.tokyo>
Re: Deleting old files (Randal L. Schwartz)
Re: Deleting old files <godzilla@stomp.stomp.tokyo>
Re: dos commands <shino_korah@yahoo.com>
Re: format/write with alternate linefeeds ? (Eric Bohlman)
Re: frustration with cgi.pm and setting cookies. (Gerd Busker)
HTML MAIL <david@datajo.no>
Re: HTML Output from .pl? <graham@letsgouk.com>
irc <todd@designsouth.net>
Re: locking files before writing data (?) nobull@mail.com
Re: mailing from perl <shino_korah@yahoo.com>
Net::RawIP anybody can help? <frank.castle@marvelknights.net>
Re: Newbie Question (Jon Bell)
Re: Newbie Question (Craig Berry)
Re: Newbie Question <godzilla@stomp.stomp.tokyo>
Re: Newbie Question (Craig Berry)
Re: Newbie Question <godzilla@stomp.stomp.tokyo>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Jun 2001 19:59:59 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: 2 questions about flock
Message-Id: <9fjdnv$16k$4@bob.news.rcn.net>
Steve <steve@zeropps.uklinux.net> wrote:
> Can I open a file read it's contents and rewrite the
> enitre file before soemone else gets to write to it?
Yep. You need to open it in read/write mode, get an exclusive lock on it,
read it, truncate it, rewrite it, and close it. The point is that you
have to keep the lock on it throughout the process: a common beginner's
mistake is opening the file in read mode, locking it, reading it, closing
it, opening it in write mode, locking it, rewriting it, and then closing
it. In between the first close and the second open, the file is unlocked
and another process can get at it.
------------------------------
Date: Tue, 5 Jun 2001 22:30:53 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: 2 questions about flock
Message-Id: <Pine.LNX.4.30.0106052219150.3227-100000@lxplus003.cern.ch>
On 5 Jun 2001, Eric Bohlman wrote:
> Yep. You need to open it in read/write mode, get an exclusive lock on it,
> read it, truncate it, rewrite it, and close it. The point is that you
> have to keep the lock on it throughout the process: a common beginner's
> mistake is opening the file in read mode, locking it, reading it, closing
> it, opening it in write mode, locking it, rewriting it, and then closing
> it.
Indeed.
But suppose that the action of reading it and doing whatever
processing was needed, was something that took a significant amount of
time, during which you wanted other processes (using suitable locking,
of course) to be able to read it. It seems as if there's no really
feasible way to leave the file shareable until the update is ready,
and then somehow upgrade the lock for writing the new contents to the
file.
At least that was my best understanding... I'd be glad to learn if I
was mistaken. Naturally, you can't close and re-open the file, as you
pointed out; but one might have hoped that if it was held open for
read-write, there might have been some way to upgrade the lock later,
when ready to rewrite the file.
------------------------------
Date: Tue, 5 Jun 2001 13:14:01 -0500
From: "spurcell" <skpurcell@hotmail.com>
Subject: Re: Any Emacs/Perl Gurus
Message-Id: <3b1d21d3$0$171@wodc7nh6.news.uu.net>
Thanks guys,
I appreciate the input, I will follow all instructions and hopefull have
this all done.
Have a nice day,
Sincerely
Scott
"Nico F Zigouras" <zigouras@mail.med.upenn.edu> wrote in message
news:Pine.OSF.4.10.10106051326170.16478-100000@dolphin.upenn.edu...
>
> You need to have global font lock turned on. On my windows
> version of emacs I go to Help -> Options -> and check Global Font Lock.
> You can set it to always be turned on in your .emacs file with the lines:
>
> (setq font-lock-maximum-decoration t) ; you might hate this
> (global-font-lock-mode 1 t);
>
> I would also suggest that you use the CPerl mode instead of the default
> Perl mode, put this line in your .emacs to do that:
>
> (autoload 'cperl-mode "cperl-mode"
> "alternate mode for editing Perl programs" t)
>
> (setq auto-mode-alist
> (append '(("\\.\\([pP][Llm]\\|al\\)$" . cperl-mode))
auto-mode-alist))
>
> That should do it.
>
>
> On Tue, 5 Jun 2001, spurcell wrote:
>
> >Hello,
> >I am using Emacs, and heard that it can color code my code, eg.
subroutines,
> >variables, etc.
> >
> >My NT install of Emacs is evidently not configured and was wondering how
> >this is done? I have surged the emacs sites, but it gets rather
confusing,
> >and appears that emacs could be a full time job for some.
> >
> >Anyway, I want to color code .pl files for my perl and .plex PerlEx
files.
> >
> >Could someone please assist?
> >
> >Thanks
> >Scott
> >
> >
> >
> >
>
------------------------------
Date: 5 Jun 2001 18:08:41 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: cerificate viewer
Message-Id: <eli$0106051358@qz.little-neck.ny.us>
In comp.lang.perl.misc, Chris Stith <mischief@velma.motion.net> wrote:
> In comp.lang.perl.modules Ian <kerrzer@hotmail.com> wrote:
> > How can I decode a base64 encoded x509 certificate so I can get the
> > information out of it (issuer, valid dates, etc)? Is there a module?
> http://search.cpan.org/search?mode=module&query=base64
It still is a binary file, though. The dataConvert function of
OpenCA::OpenSSL might do more.
Or for quick and easy, if you have openssl installed:
#!/usr/bin/perl -w
use strict;
use Shell;
my $certfile = "cert.cer";
my $textcert = openssl('x509', '-in', $certfile, '-text');
print $textcert;
__END__
Elijah
------
thinks Larry's old hack is under used
------------------------------
Date: Tue, 05 Jun 2001 15:17:04 -0400
From: Drew Dowling <drewhead.nospam@drewhead.org>
Subject: CGI_Lite upload problem with Opera 5.x
Message-Id: <3B1D3030.1D0DDABA@drewhead.org>
I've got a cgi handling a POST http request with a file upload.
--
use CGI_Lite;
my $cgi = new CGI_Lite;
my $rv = $cgi->set_directory("/tmp");
$cgi->set_file_type("File");
my %form = $cgi->parse_form_data();
--
Almost straight out of the documentation. :) I'm getting the
/tmp/<epoch>__<filename> as I expect. Works great wth various flavors
of IE and NS. However I've recentaly had a user that used Opera. I've
tested and verified that this method doesn't handle Opera. No file name
is created, all the data including content headers can be derefed in
$form{<element_name>}. Anyone know what the deal is here, or can
suggest another method? Parsing the data outside this method it *looks*
the same from browser to browser to me. Not sure what Opera is doing to
me here.
------------------------------
Date: Tue, 05 Jun 2001 15:18:17 -0500
From: Chris <cpryce@pryce.net>
Subject: Re: DBD::ODBC and recursive functions...
Message-Id: <B742A8B9.63B1%cpryce@pryce.net>
in article 9fiq0r$3om$1@horsefly.nf.net, Phil Glanville at phil@zeddcomm.com
wrote on 06/05/2001 9:24 AM:
> I'm using a recursive function to pull out sections and subsections from the
> database, the guts of which look basically like this:
>
> sub getSection
> {
> # get the parent to use
> my $parentID= shift;
>
> my ($db_ID, $db_Title, $sth);
>
> # loop through the database getting child sections of this parent
> $sth= $dbh->prepare($dbms{getSection_sectionID});
> $sth->execute($parentID);
> while(($db_ID, $db_Title)= $sth->fetchrow)
> {
> # print this section title
> print qq{<p>$db_Title</p>};
>
> # get children of this section
> &getSection($db_ID);
> }
> $sth->finish;
> }
>
> &getSection(0);
>
> (The %dbms hash lives in a separate module and defines dbms-specific SQL
> depending on whether the script's running under MySQL or SQL Server. But
> that's another story!)
>
> When I run this on my W2K / SQL Server machine, I get the error
>
> DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Connection
> is busy with results for another hstmt (SQL-S1000)
From "Programming the Perl DBI": "Some ODBC drivers and databases, most
notably Sybase and SQL Server, do not let you prepare and execute a new
statement handle while still fetching data from another statement handle
associated with the same database handle."[1]
Can you use the fetchall_arrayref()[2] function of the DBI and and finish
your $sth before looping?
# untested code for illustration purposes
my $sth = $dbh->prepare($dbms{getSection_sectionID});
$sth->execute($parentID);
my $array_ref = $sth->fetchall_arrayref();
$sth->finish();
foreach my $row (@$array_ref) {
my ($db_ID, $db_Title) = @$row;
print qq{<p>$db_Title</p>}'
&getSection($db_ID);
}
cp
[1] Programming the Perl DBI; Tim Bunce & Alligator Descartes; O'Reilly &
Associates; p. 133
[2] pp 131-134
------------------------------
Date: Tue, 05 Jun 2001 12:13:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Deleting old files
Message-Id: <3B1D2F4E.1027D7A1@stomp.stomp.tokyo>
Craig Berry wrote:
> Steve wrote:
> : @FILES = grep -M > .5, <9*.gif>;
> :
> : foreach $FILES (@FILES) {
> : unlink $FILES;
> : }
> By convention, ordinary perl variables are mixed or lower-case. Following
> this convention will make you code more readable by others and cleaner
> looking when mixing your own names with those imported from modules.
> Also, it's a useful habit to give simple scalars singular rather than
> plural names.
> Given that unlink takes a list of files, you can express your approach
> more compactly as
> unlink grep -M > .5, <9*.gif>;
> : Seems to work fine. As September 8th approaches I guess I'll need to
> : change my time based naming system away from Unix Epoch.
> Or continue using the epoch time, but stop counting on its starting with
> 9.
Mr. Berry, don't think me to be picking on you. For whatever
reason, Suckernews isn't displaying Steve's article to which
you are responding. I can click reference it but cannot view
his article directly for response.
**
There are times when dealing with math Perl code, if you will
first write out your problem as a typical math word problem,
an answer comes quickly and easily.
You want to delete files older than or equal to twelve hours in age.
"Is the difference between current time and the time of
a file, greater than or equal to twelve hours."
"Is current time minus file time greater than or equal to 43200 seconds?"
"Is time() minus file time >= 43200?"
"if (time() - substr ($file, 0, index ($file, ".")) >= 43200)"
I have left out a lot of low level steps for conversion from
a word problem to a coded problem.
Get the idea? Easy logical approach based on what you
learned many years back, in school.
Incidently, you don't need to worry about this rollover
coming up in September with this method; it is simple
arithmetic independent of externalities.
Godzilla!
--
#!perl
@Files = qw (991679373.gif 991766362.gif, 1000000001.gif);
foreach $file (@Files)
{
if (time() - substr ($file, 0, index ($file, ".")) >= 43200)
{ print "$file : this file would be deleted\n\n"; }
else
{ print "$file : this file would not be deleted\n\n"; }
}
exit;
PRINTED RESULTS:
________________
991679373.gif : this file would be deleted
991766362.gif, : this file would not be deleted
1000000001.gif : this file would not be deleted
------------------------------
Date: 05 Jun 2001 13:52:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Deleting old files
Message-Id: <m1pucid4zc.fsf@halfdome.holdit.com>
>>>>> "Godzilla!" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
Godzilla!> Mr. Berry, don't think me to be picking on you. For whatever
Godzilla!> reason, Suckernews isn't displaying Steve's article to which
Godzilla!> you are responding. I can click reference it but cannot view
Godzilla!> his article directly for response.
Next time you'll hopefully remember that when someone follows up to an
article of yours when really they're commenting on the code you've
included from another poster. I've seen you say at least a few times
"don't reply to me... I didn't say that... follow up to the original".
And this is likely what happened... they couldn't get access to the
original post, even though you did, and quoted it. It's the nature of
news.
OK, so no more of those postings, OK? Makes you look a bit naive
about how news works.
--
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: Tue, 05 Jun 2001 14:46:49 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Deleting old files
Message-Id: <3B1D5349.174F9AFE@stomp.stomp.tokyo>
Randal L. Schwartz wrote:
> >>>>> Godzilla! wrote:
> Godzilla!> Mr. Berry, don't think me to be picking on you. For whatever
> Godzilla!> reason, Suckernews isn't displaying Steve's article to which
> Godzilla!> you are responding. I can click reference it but cannot view
> Godzilla!> his article directly for response.
> Next time you'll hopefully remember that when someone follows up to an
> article of yours when really they're commenting on the code you've
> included from another poster. I've seen you say at least a few times
> "don't reply to me... I didn't say that... follow up to the original".
> And this is likely what happened... they couldn't get access to the
> original post, even though you did, and quoted it. It's the nature of
> news.
GAK! This is not what is happening. When I refer someone to
the original poster, this person being referred is definitely
addressing me rather than the original poster and, this person's
topic or comments are unrelated to my comments.
In all cases when I refer a person back to the originating
author, an article or articles are available for response.
In this case, which is common for Suckernews, an article
can be read by reference click but it does not show up
in my newsreader window because of Suckernews screwing up.
I can verify and read these missing articles within my
other news servers but will not post from elsewhere, to
this group. The boys here totally wig-out when I do and,
cause as many problems as possible for me with my other
news servers, although I am a legitimate customer.
Get the hint?
Brass tacks Randal, there are selected boys here whom make it
a habit of trying to engage me in this weenie wagging contest
so many of the boys play. I am not interested. I have no weenie
and if I did, I certainly know better what to do with it than
do these boys; I am estrogen enhanced rather than suffering
terminal testosterone poisoning.
> OK, so no more of those postings, OK? Makes you look a bit naive
> about how news works.
You are comparing apples and alligators. This is a good
way to suffer a serious bite.
However, perhaps I will respond to these boys, in my
own typical fashion and style. I would actually enjoy
doing this. They need a periodic thrashing.
Godzilla! Queen of the Tragically Naive Hip.
------------------------------
Date: Tue, 5 Jun 2001 11:20:43 -0700
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Re: dos commands
Message-Id: <9fj7ts$ptf@news.or.intel.com>
I'm assuming u r using windows OS
so for eg..use my @tmp = `dir`;
print "@tmp..\n";..
"AtnNn" <atnnn@hotmail.com> wrote in message
news:3b1bbd17.9129518@news.aei.ca...
> How can I use dos commands in perl, and control the input and output?
>
> AtnNn
------------------------------
Date: 5 Jun 2001 19:48:37 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: format/write with alternate linefeeds ?
Message-Id: <9fjd2l$16k$3@bob.news.rcn.net>
Scott R. Godin <webmaster@webdragon.unmunge.net> wrote:
> Well, the thing is, the two output files (one .html and one .txt) are
> dumped into a .tgz archive to make downloading them both simpler and
> easiler, so any 'conversion' would need to be done beforehand.
Yep.
> Since it's a write and not a print, there are no "\n"'s in the output
> statements, so I'm not exactly certain how to change the default \n to a
> \015\012 instead for a write operation.
You'll need to do your formatted writing by calling formline()
directly and then doing a substitution on $^A (see "Accessing Formatting
Internals" in perlform; you'll probably want something similar to the
swrite() described there).
------------------------------
Date: Tue, 5 Jun 2001 22:02:40 +0100
From: gbusker@nospam-postmaster.co.uk (Gerd Busker)
Subject: Re: frustration with cgi.pm and setting cookies.
Message-Id: <slrn9hqi7g.3qv.gbusker@ether.home>
On Thu, 31 May 2001 13:12:53 +0200,
kenneth johansen <kennethj@student.uit.no> wrote:
>i set the cookie and redirect with:
>-------------------------------
>my $cookie = $q->cookie( -name => "somehing",
> -path => "/somewhere",
> -value => "something",
> -expires=> "somedate");
>print $q->redirect (-url =>"http://somewhere/path/to/cookie_test.cgi",
>-cookie => $cookie);
There are some issues with Location: and Set-Cookie headers in
some webservers.
Which server are you using?
Apache did this fine for me, but WN server insisted on removing the
Cookies if a Location: header was in the HTTP header....
Gerd.
------------------------------
Date: Tue, 5 Jun 2001 20:48:04 +0200
From: "David Tandberg-Johansen" <david@datajo.no>
Subject: HTML MAIL
Message-Id: <GM9T6.6730$lM3.130965@news1.oke.nextra.no>
Hello!
How can I remove html headers from mail messages, and only have the raw text
back?
I WANT THIS FROM THE MAIL BODY:
THIS IS THE TEXT
BUT I GET THIS FROM THE MAIL BODY:
This is a multi-part message in MIME format.
------=_NextPart_000_00AA_01C0EDFF.FD8EA000
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
THIS IS THE TEXT
------=_NextPart_000_00AA_01C0EDFF.FD8EA000
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>
<FONT face=3DArial size=3D2>THIS IS THE TEXT</FONT>
</DIV>
</BODY>
</HTML>
------=_NextPart_000_00AA_01C0EDFF.FD8EA000--
David
------------------------------
Date: Tue, 5 Jun 2001 21:27:18 +0100
From: Graham Stow <graham@letsgouk.com>
Subject: Re: HTML Output from .pl?
Message-Id: <ZaxAHVAmCUH7Ewvt@letsgouk.com>
htmlsub worked fine when I ran it, but as written it is not intended to
print to a file but to carry out the substitution and print the results
to STDOUT. The html file remains intact.
Do you really want to rewrite the html file every time htmlsub is run?
If you do, amending htmlsub to do this is beyond my knowledge of perl,
let alone a newbie's.
However, I think it more likely that you may want to keep the html file
intact but have the substitution carried out on the fly in response to
information submitted via an html form. If that's the case, it shouldn't
be too difficult. Let us know and I'll have a go.
--
Graham Stow
------------------------------
Date: Tue, 05 Jun 2001 19:50:01 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: irc
Message-Id: <JJaT6.114667$I5.26675595@news1.rdc1.tn.home.com>
Which IRC server and room is the most packed with perl people all day?
------------------------------
Date: 05 Jun 2001 18:51:58 +0100
From: nobull@mail.com
Subject: Re: locking files before writing data (?)
Message-Id: <u966ea24sh.fsf@wcl-l.bham.ac.uk>
"Muddy Cat" <muddycat@hotmail.com> writes:
> flock(FH, LOCK_EX)
> or die "can't lock filename: $!";
> But am not sure about the die() function. Am I right in thinking that this
> will cause the script to effectively 'quit' and present the user with the
> error message?
Yes.
> Is it possible/a good idea to just have the script re-attempt
> file access (maybe for a finite number of tries) until it succeeds?
Yes it is possible. No it is not a good idea.
> Am I missing the point?
Yes. flock() called without the LOCK_NB (nonblocking) flag will wait
for the lock to become available. If flock() fails it means there's
some more drastic reason why you can't get the lock, like for example
the file is on a filesystem that doesn't support locking.
> Also... am I right in thinking that *all* calls to a
> particular file *must* use the same locking 'mechanism' in order for it to
> be successful.
If by "be successful" you mean "prevent simultaneous updates" then yes.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 5 Jun 2001 11:08:33 -0700
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Re: mailing from perl
Message-Id: <9fj774$pda@news.or.intel.com>
For emails..rather than using system calls
u should use Mail::Send module
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3B1ACE04.4ED28129@earthlink.net...
> Anonymous wrote:
> >
> > I'm working on a script that looks essentially like so, but doesn't
> > work:
> >
> > open(FH,"mailing.list");
> >
> > while(<FH>) {
> > system("mail $_ < a_file_to_mail");
> > }
> >
> > close FH;
> >
> > any ideas?
>
> Yes, don't invoke "mail" once per address, but have a single call to
> "mail" which goes to all the addresses in the list...
>
> chomp my @userlist = grep { !/^\s*#/ && /\S/ } do {
> open( my $fh, "mailing.list" ) or die "mailing.list: $!";
> <$fh>; }; # $fh closes when it goes out of scope
> if( @userlist == 0 ) { die "No users!\n"; }
> my $wait_gave = system("mail @userlist < a_file_to_mail");
> if( $wait_gave == -1 ) {
> die "System call (mail) failed: $!";
> } elsif( $wait_gave != 0 ) {
> my $exit_value = $? >> 8;
> my $signal_num = $? & 127;
> my $dumped_core = $? & 128;
> if( $dumped_core ) {
> die "Mail dumped core!";
> } elsif( $signal_num ) {
> use Config;
> my @names = split ' ', $Config{sig_name};
> my @nums = split ' ', $Config{sig_num};
> my %names; @names{@nums} = @names;
> $signal_num = $names{$signal_num} or $signal_num;
> die "Mail aborted due to signal $signal_num";
> } elsif( $exit_value ) {
> die "Mail exited with return code $exit_value";
> } else {
> die "Shouldn't get here";
> }
> } else {
> print "Mail sent ok\n";
> }
>
> *Any* time you call open, you should *always* check it's return value.
> *Any* time you call system, you should *always* check it's return value.
> If the call succeeded, system returns 0. If not, handle it. I handle
> it be examining $? and printing an appropriate error message. You could
> handle it by simply saying something like
> die "system() failed: it returned $foo, and \$?==$?, \$!==$!";
> but this kind of error message is rather cryptic looking and unhelpful.
> Core dumps are usually bugs, of course, but the other things *can* be
> understood. If a program dies from a signal, it's because *something*
> sent the signal to the program. If a program exits with some return
> value, you can look up in the manual page (use the "man" command from
> the shell) to see what it means.
>
> Another thing... you've probably got about a bazillion addresses in the
> file mailing.list; perhaps you should use a special bulk mailer instead
> of the "mail" program?
>
> Oh, and instead of passing all those addresses on the commandline, you
> should find a way to write the addresses to the mailer's stdin
> instead... putting stuff from files onto the commandline is *so* unsafe.
>
> For example:
>
> { my $sm;
> open( $sm, "|sendmail -t" ) or die "can't fork/exec $!";
> print $sm, "To: ex@amp.le";
> { my $ml;
> open( $ml, "mailing.list" ) or die "mailing.list: $!";
> # no \n here, it's already included.
> print $sm, "Bcc: $_" while <$ml>;
> # $ml closes at end of scope
> }
> print $sm, "\n"; # end of mail headers
> { my ($thefile, $buf, $bufsize);
> open( $thefile, "a_file_to_mail" )
> or die "a_file_to_mail;
> $bufsize = (stat($thefile))[11] or 1024;
> while( read( $thefile, $buf, $bufsize ) ) {
> print $sm, $buf;
> }
> # $thefile closes at end of scope
> }
> if( !close( $sm ) ) {
> # check $? here
> }
> # yes, $sm would close at end of scope, but since it's a pipe,
> # we *should* be checking the return value of close, and the
> # contents of $?, if the close failed.
> }
>
> --
> The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Tue, 5 Jun 2001 21:14:39 +0200
From: "Alex Randol" <frank.castle@marvelknights.net>
Subject: Net::RawIP anybody can help?
Message-Id: <9fjb9l$gps$04$1@news.t-online.com>
I set source source to an adress (in ip => {...}) to some others host adress
to fake a ip (udp) package to look like from another host. But send told me
that it could not send this package ("sendto(): Cannot assign requested
adress") because it could n't be assigned. Is it possible to fake an IP
package with Net::RawIP and how does it work? I think it should be possible
because this package is intended to manipulate IP packages.
Note: I am using Irix 5.3, Net::RawIP compiled fine
------------------------------
Date: Tue, 5 Jun 2001 18:09:28 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Newbie Question
Message-Id: <GEGyFs.AHy@presby.edu>
In article <slrn9hq10s.qe4.trammell@bayazid.hypersloth.net>,
John Joseph Trammell <trammell@bayazid.hypersloth.invalid> wrote:
>On Tue, 5 Jun 2001 17:30:16 +0100, <nick_deller@hotmail.com> wrote:
>>
>> 1. What is better perl/cgi
>> 2. If they are both the same how does each one differ
>
>This is like asking "which is better: bricks or houses?". Perl
>is something you can use to build a CGI program; you can use it
>to build other things too.
And to complete the analogy, you can use other languages besides Perl for
building CGI programs.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: Tue, 05 Jun 2001 18:13:57 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Newbie Question
Message-Id: <thq8b5eqka317d@corp.supernews.com>
John Joseph Trammell (trammell@bayazid.hypersloth.invalid) wrote:
: On Tue, 5 Jun 2001 17:30:16 +0100, <nick_deller@hotmail.com> wrote:
: > 1. What is better perl/cgi
: > 2. If they are both the same how does each one differ
:
: This is like asking "which is better: bricks or houses?". Perl
: is something you can use to build a CGI program; you can use it
: to build other things too.
To clarify further, CGI (the "Common Gateway Interface") is simply a set
of standard ways for a web server to 'talk' to an external application,
sending request data to it and receiving generated web content from it.
CGI doesn't 'exist' except in the sense that (e.g.) laws 'exist'. CGI is
implemented by a web server and the applications on which it calls to
process requests using the CGI protocols.
: > 3. Which perl/cgi program do you recommend for a beginner. I
: > am not willing to spend any money at this stage
:
: I think your time would be better spent learning what CGI and
: Perl are; perhaps you should take a trip to the library?
Note that perl is free (in both senses) and available for nearly every
known platform in the universe. :) In particular, you can get a binary
Windows version at activestate.com, and source to build it under Unix at
www.perl.com. Get a copy for your machine of choice so you can experiment
with simple programs as you learn.
The topic of "Best Newbie Book" has been discussed here quite frequently.
See the archives (now available again at groups.google.com) for more
opinions than you had previously imagined existed.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "God becomes as we are that we may be as he is."
| - William Blake
------------------------------
Date: Tue, 05 Jun 2001 12:22:27 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Newbie Question
Message-Id: <3B1D3173.6FBC5CFA@stomp.stomp.tokyo>
Craig Berry wrote:
> John Joseph Trammell wrote:
> : nick_deller wrote:
(some snippage)
> : > 1. What is better perl/cgi
> : > 2. If they are both the same how does each one differ
> : This is like asking "which is better: bricks or houses?". Perl
> : is something you can use to build a CGI program; you can use it
> : to build other things too.
> To clarify further, CGI (the "Common Gateway Interface") is simply a set
> Note that perl is free (in both senses) and available for nearly every
> known platform in the universe. :) In particular, you can get a binary
> Windows version at activestate.com, and source to build it under Unix at
> www.perl.com. Get a copy for your machine of choice so you can experiment
> with simple programs as you learn.
This is not a critique, Mr. Berry. Under these circumstances,
a "newbie" asking about both Perl and CGI, he probably would
do better or have an easier time of it, to download Indigo Perl
and have both a webserver and Perl installed with no need for
any user configuration. In light of his situation, I am not
so sure he could handle setting up Active State to meet his
needs for Perl and CGI applications. Indigo Perl might be
a bit of challenge, in itself, for someone so new to this.
Most of us forget about Indigo Perl and never mention it!
It sure is an easy installation for all needs.
Godzilla!
------------------------------
Date: Tue, 05 Jun 2001 20:34:48 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Newbie Question
Message-Id: <thqgj8klb0s4fa@corp.supernews.com>
Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
: > Note that perl is free (in both senses) and available for nearly every
: > known platform in the universe. :) In particular, you can get a binary
: > Windows version at activestate.com, and source to build it under Unix at
: > www.perl.com. Get a copy for your machine of choice so you can experiment
: > with simple programs as you learn.
:
: This is not a critique, Mr. Berry. Under these circumstances,
: a "newbie" asking about both Perl and CGI, he probably would
: do better or have an easier time of it, to download Indigo Perl
: and have both a webserver and Perl installed with no need for
: any user configuration.
I actually made this recommendation intentionally. Attempting to write
CGI apps in Perl without first knowing 'baby talk' Perl as taught in
(e.g.) the Llama book is a recipe for disaster. Understanding how to
write and debug simple, straightforward, command-line microapps prepares
you for the tighter constraints and drastically reduced visibility of the
CGI world.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "God becomes as we are that we may be as he is."
| - William Blake
------------------------------
Date: Tue, 05 Jun 2001 13:45:51 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Newbie Question
Message-Id: <3B1D44FF.49635063@stomp.stomp.tokyo>
Craig Berry wrote:
> Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
> : > Note that perl is free (in both senses) and available for nearly every
> : > known platform in the universe. :) In particular, you can get a binary
> : > Windows version at activestate.com, and source to build it under Unix at
> : > www.perl.com. Get a copy for your machine of choice so you can experiment
> : > with simple programs as you learn.
> : This is not a critique, Mr. Berry. Under these circumstances,
> : a "newbie" asking about both Perl and CGI, he probably would
> : do better or have an easier time of it, to download Indigo Perl
> : and have both a webserver and Perl installed with no need for
> : any user configuration.
> I actually made this recommendation intentionally. Attempting to write
> CGI apps in Perl without first knowing 'baby talk' Perl as taught in
> (e.g.) the Llama book is a recipe for disaster. Understanding how to
> write and debug simple, straightforward, command-line microapps prepares
> you for the tighter constraints and drastically reduced visibility of the
> CGI world.
This is very true and cannot be debated.
However! However, Indigo Perl also includes ActiveState Perl,
already configured and ready to go, requiring nothing more
than a click of a virtual button and reboot. After this, just
a matter of switching to the Indigo Perl directory and off you go!
Perl, Apache and CGI, are all right there under your keyboard.
You see? Best of everything installed in a snap.
* snaps her fingers *
That easy.
Godzilla!
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 1065
***************************************