[18670] in Perl-Users-Digest
Perl-Users Digest, Issue: 838 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 5 11:05:54 2001
Date: Sat, 5 May 2001 08: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: <989075119-v10-i838@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 5 May 2001 Volume: 10 Number: 838
Today's topics:
Re: calling subroutine problem <goldbb2@earthlink.net>
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Re: foreach in a deep hash <goldbb2@earthlink.net>
Re: Hacker Challenge. Can you break this script for me? <jfreeman@tassie.net.au>
Re: HELP - Please <jfreeman@tassie.net.au>
How to execute a perl script from a perl script? - near <admin@nospam.m2n.co.uk>
Re: leftover Close Wait sockets (Spork Boy)
Re: re-sizing GIF images on the fly <bart.lateur@skynet.be>
Re: Recursing a directory tree <bart.lateur@skynet.be>
Re: Recursing a directory tree <jfreeman@tassie.net.au>
Re: Recursing a directory tree <bart.lateur@skynet.be>
redirect to a url & avoiding hacks <gasper@cis.ohio-state.edu>
Re: redirect to a url & avoiding hacks <godzilla@stomp.stomp.tokyo>
Re: redirect to a url & avoiding hacks <tony_curtis32@yahoo.com>
Re: Simple question <andras@mortgagestats.com>
Re: UPPERCASE to "Sentence Case" (Damian Conway)
Re: UPPERCASE to "Sentence Case" <bart.lateur@skynet.be>
Re: UPPERCASE to "Sentence Case" <andras@mortgagestats.com>
Re: Using Modem::Vgetty <dj@syntaxerror.crazydj.de>
Re: warnings from MIME-Lite <jfreeman@tassie.net.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 05 May 2001 07:06:34 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: calling subroutine problem
Message-Id: <3AF3A7C0.4D8DB3BC@earthlink.net>
Jay Tilton wrote:
>
[snip]
> For the sub to receive an array and a scalar, pass the scalar first,
> e.g.
>
> sub display_results ($@) {
> my $number = shift;
> my @sorted = @_;
> ...
> }
There's no reason the parameters can't be in the order the OP wants
them.
sub display_results (@$) {
my $number = pop;
my @sorted = @_;
...
}
--
Shift to the left, shift to the right, mask in, mask out, BYTE, BYTE,
BYTE !!!
------------------------------
Date: 05 May 2001 10:27:33 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_989058283@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs/XEmacs
o Unix:
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
o Windows
http://www.gnu.org/software/emacs/windows/ntemacs.html
ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe
o More Emacs resources at
http://tiny-tools.sourceforge.net/emacs-elisp.html
Emacs Perl Modules
Cperl -- Perl programming mode
.ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
.<olson@mcs.anl.gov> Bob Olson (started 1991)
.<ilya@math.ohio-state.edu> Ilya Zakharevich
Major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
standard in newest Emacs.
TinyPerl -- Perl related utilities
.http://tiny-tools.sourceforge.net/
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Load source code into Emacs, like Devel::DProf.pm
o Grep through all Perl manpages (.pod)
o Follow POD manpage references to next pod page with TinyUrl
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o TinyUrl is used to jump to URLs (other pod pages, man pages etc)
mentioned in POD pages. (It's a general URL minor mode)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in the Kit]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
how to set up datatbases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to run the find for you, You can adjust
recursive grep options, ignored case, add user grep options.
You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
Check also ftp://ftp.ihs.com/pub/kevinr/
TinyCompile -- Browsing grep results in Emacs *compile* buffer
TinyCompile is minor mode for *compile* buffer from where
you can collapse unwanted lines, shorten the file URLs
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Sat, 05 May 2001 08:14:51 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: foreach in a deep hash
Message-Id: <3AF3B7BD.C0758B84@earthlink.net>
kb wrote:
>
> hi
> sorry for this, i am a new to perl.
>
> i cannot figure out how to use the foreach function when i have a hash
> with more then 2 dimensions.
>
> here is my hash
> every Person has a name, any number of cars, and any number of bikes.
>
> $Name, $CarBrand and $BikeBrand are set dynamically.
> each car holds the values of its color and type.
> each bike holds its name and number of gears and the type
>
> this is the structure:
> $Person{$Name}
> $Person{$Name}{$CarBrand}{Color}
> $Person{$Name}{$CarBrand}{Type}
> $Person{$Name}{$BikeBrand}{NoOfGears}
> $Person{$Name}{$BikeBrand}{Type}
As another has said, this is a bad type of structure, for a variety of
reasons (one of which being that you can't easily differentiate between
cars and bikes).
A much better structure might be:
$Person{$Name}{Cars}[$CarNum]{Brand}
$Person{$Name}{Cars}[$CarNum]{Color}
$Person{$Name}{Cars}[$CarNum]{Type}
$Person{$Name}{Bikes}[$BikeNum]{Brand}
$Person{$Name}{Bikes}[$BikeNum]{NoOfGears}
$Person{$Name}{Bikes}[$BikeNum]{Type}
> lets say we end up like this.
>
> $Person{Mike Mikeson} = Mike Mikeson
You don't have to have the name on the right, since you have it to
access the structure (ie, you already have it). The only time you might
not would be if you do keys %Person, to which I respond don't *do* that.
If you insist on having the name be part of the structure, in addition
to being the index to find it, then you should assign it to
$Perons{$Name}{Name}.
> $Person{Mike Mikeson}{GMC}{Color} = "Blue"
> $Person{Mike Mikeson}{GMC}{Type} = "Van"
> $Person{Mike Mikeson}{Volvo}{Color} = "Black"
> $Person{Mike Mikeson}{Volvo}{Type} = "Station vagon"
> $Person{Mike Mikeson}{Scott}{NoOfGears} = 21
> $Person{Mike Mikeson}{Scott}{Type} = Mountain bike
> $Person{Mike Mikeson}{Wheeler}{NoOfGears} = 18
> $Person{Mike Mikeson}{Wheeler}{Type} = Mountain bike
With your data structure, you have a problem if someone has two Blue GMC
Vans, etc. Also, you assign in a way that's not exactly consise.
With my data strucure, this would be:
$Person{Mike Mikeson} = {
Cars => [
{Brand=>"GMC",Color=>"Blue",Type=>"Van"},
{Brand=>"Volvo",Color=>"Black",Type=>"Station Wagon"},
], Bikes => [
{Brand=>"Scott",Gears=>21,Type=>"Mountain Bike"},
{Brand=>"Wheeler",Gears=>18,Type=>"Mountain Bike"},
], };
>
> $Person{Anna Anderson} = Anna Anderson
> $Person{Anna Anderson}{BMW}{Color} = "Blue"
> $Person{Anna Anderson}{BMW}{Type} = "Station vagon"
> $Person{Anna Anderson}{BMW}{Color} = "White"
> $Person{Anna Anderson}{BMW}{Type} = "Convertible"
You *do* realize that this first creates a blue station wagon, and then
gets rid of it, replacing it with a white covertible? Your data
structure doesn't allow for more than one car of a particular brand.
> $Person{Anna Anderson}{Peugeot}{NoOfGears} = 12
> $Person{Anna Anderson}{Peugeot}{Type} = Road bike
$Person{Anna Anderson} = {
Cars => [
{Brand=>"BMW",Color=>"Blue",Type=>"Station Wagon"},
{Brand=>"BMW",Color=>"White",Type=>"Convertible"},
], Bikes => [
{Brand=>"Peugeot",Gears=>12,Type=>"Road Bike"},
], };
To add a bike or car, something like this might be used:
push @$Person{Anna Anderson}{Cars},
{Brand=>"Buick",Color=>"White",Type="Station Wagon"};
> to print out every person prom the hash i use
> foreach $each_person (%Person)
> {
> print STDOUT $Person{$each_person};
> }
foreach doesn't work on hashes, it works on arrays. It converts %Person
to an array, and then $each_person is alternately a key then a value of
it. Also, the values are hashrefs.
I won't how you would do it with your data structure, but with mine, I
would do something like the following:
for( my ($Name,$Possessions) = each %Person ) {
print "$Name owns the following cars:\n";
foreach my $Car (@$Possessions{Cars}) {
print "A $Car->{Color} $Car->{Brand} $Car->{Type}\n";
}
print "and the following bikes:\n";
foreach my $Bike (@$Possessions{Bikes}) {
print "A $Bike->{Gear} gear $Bike->{Brand}";
print " $Bike->{Type}\n";
}
}
Actually, since you would have *A* 18 gear Wheeler Mountain Bike, where
you actually want *An* 18 gear etc, it's not quite right, but you would
have to do some fancy (probably ugly looking) stuff to get it right.
Does anyone know if there are packages which will select "A" or "An" for
you, depending on if a particular string is pronounced starting with a
vowel? It would have to expand numbers, too, so 18 becomes "eightteen"
for the purposes of testing for vowel-ness.
--
Shift to the left, shift to the right, mask in, mask out, BYTE, BYTE,
BYTE !!!
------------------------------
Date: Sat, 05 May 2001 22:28:20 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Hacker Challenge. Can you break this script for me?
Message-Id: <3AF3F1E4.5739F2DD@tassie.net.au>
David Coppit wrote:
> Sorry for being a late-comer...
>
> After all this discussion, I'm still left wondering... WHY?
>
> Is there a documented (and necessary) performance increase in
> stripping comments? Has anyone put forth a reasoned argument that
> removing comments helps hide IP? Or is there some other reason I'm
> missing?
>
> Far be it for me to tell someone else how to spend their time, but I
> find this less exciting than spending a man-year trying to get a CPU
> cache to be 1% more efficient. (Which plenty of people do, by the
> way.) It seems to me that this solution solves none of the real
> problems with developing software.
>
> On the other hand, I guess it's a great way to learn Perl. :)
Damn the secret's out!
James
>
>
> --
> David
------------------------------
Date: Sat, 05 May 2001 23:48:57 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: HELP - Please
Message-Id: <3AF404C9.96C49A52@tassie.net.au>
"Methods, Verification [SKY:1G20:EXCH]" wrote:
> Hello Perl wizards...
> I'm writting a Perl script, which is supposed to search through a text
> file for a specific line, cut it out, and paste it into a new text file.
> However, I'm stuck. :( and I was wondering if any of you Perl gurus out
> there could lend me a hand with my pathetic problem (by your standards).
> Thank you very much.
>
> P.S. How would I stirp out 2 distinct lines and paste them into another
> text file (for future reference).
>
> Thank's a lot, and here's what I have so far, and I don't know where to
> go from here.
>
> #! /usr/bin/perl
>
> $srcdir = "/home/vbook/perl";
>
> $src = "updates" # Source file, one to be
> manipulated
syntax error, no ;
>
> $dst = "destination" # Destination file, one to be
> written to
ditto as above
>
>
> open(DESTFILE, ">$srcdir/$dst.txt"); # Open destination file
The FILE is extra typing for no extra info. Why use three steps to define
fiename?
>
>
> open(SRCFILE, "$srcdir/$src.txt"); # Open source file
forgotten <
>
> @contents = <SRCFILE>;
> close(SRCFILE);
don't need ( )
>
>
> $updnum = 1;
>
> while ($contents[$linenum]) { # Identify the
> starting
> if (($contents[$linenum] =~ /^UPD: \S+$/)) # line, to be
> cut, "UPD: "
> &StartLine($updnum);
> $updnum++;
> } else {
> $linenum++;
> }
> }
No idea what you are trying to do here really
This should do what you want:
#!/usr/bin/perl -w
use strict;
my $srcdir = "/home/vbook/perl";
my $src = "$srcdir/updates.txt"; # Source file, one to be manipulated
my $dst = "$srcdir/destination.txt"; # Destination file, one to be written to
open(DEST, ">>$dst") || die "Unable to open $dst : $!\n";
open(SRC, "<$src") || die "Unable to open $src : $!\n";
my @contents = <SRC>;
close SRC;
open (SRC, ">$src") || die "Unable to open $src : $!\n";
foreach (@contents) {
chomp $_;
if (m/your condition here/) {
print DEST "$_\n";
print "Found $_ and printed it to $dst\n";
} else {
print SRC "$_\n";
}
}
close SRC;
close DEST;
At the moment this script will:
Read in src
Look for the text 'your condition here' on each line via the regex
/your condition here/
If found it will print that line to dest, appending to the end of the file, if
not it rewrites the line to the src file.
Thus if the line is not found nothing is added to dest and all lines are
rewritten to src.
Note open FOO "<foo.txt" opens foo.txt for input via FOO filehandle
open FOO ">foo.txt" opens foo.txt for output via FOO filehandle AND
OVERWRITES THE OLD FILE!!!!
open FOO ">>foo.txt" opens foo.txt for output via FOO filehandle BUT unlike
the example above it does not erase the existing file, it simply adds (appends)
to the end of it.
When you foreach (@foo) then each elemet of the array @foo goes into the magical
variable $_
These three expressions are equivalent:
$_ =~ m/foo/
m/foo/
/foo/
because the default arggument for a regex is $_
If you know which line number you want, substitute
for my $line (0..$#contents) {
chomp $contents[$line];
if ($line == 10) { # stick line 10 in DEST
print DEST "$_\n";
print "Found $contents[$line] and printed it to $dst\n";
} else {
print SRC "$contents[$line] \n";
}
}
Script compiles but I havent bothered running it.
James
------------------------------
Date: Sat, 05 May 2001 15:55:43 +0100
From: HCCO admin <admin@nospam.m2n.co.uk>
Subject: How to execute a perl script from a perl script? - nearly got it right !
Message-Id: <fb48ft4t03i6ffl1q8lqh0gap4v8mquatr@4ax.com>
Hello folks,
I tried really hard to get it right, but have to resort to bothering
you. Sorry !
I'm running a bulletin voard and I want to run a function within the
BB from a page on the same server, but different website.
So <!--#include
virtual="/cgi-bin/ultimatebb.cgi?ubb=whos_online_ssi'"-->
which works on the same site, won't work from the required site.
The only thing I could think of was calling the BB script from an
intermediate perl script.
<!--#include virtual="/cgi-bin/show_whosonline.pl"-->
then show_whosonline.pl looks like this :
#!/usr/bin/perl
exec '/home/sites/site2/web/cgi-bin/ultimatebb.cgi',
'ubb=whos_online_ssi';
yep I was happy to find the exec function, and the above script does
run ultimatebb.pl, but the parameter is not being passed correctly.
It's being ignored.
Any ideas very much appreciated.
Thanks.
------------------------------
Date: Sat, 05 May 2001 07:30:29 GMT
From: sporkboy@Spork.na (Spork Boy)
Subject: Re: leftover Close Wait sockets
Message-Id: <slrn9f7b0i.sro.sporkboy@Spork.na>
In article <9cv67g$fuvpn$1@ID-13368.news.dfncis.de>, Samuel Kilchenmann wrote:
> "Spork Boy" <sporkboy@Spork.na> wrote in:
> news:slrn9f5pvn.rst.sporkboy@Spork.na...
>> I'm using perl to access a WinampRC running on a windows machine from my
>> Linux machine. It works great, with the exception that it's leaving
>> "Close Wait" sockets open on the windows machine. The original windows
>> client for the server doesn't send any kind of a goodbye command to
>> disconnect as far as I can tell, nor does it leave the Close Wait
>> sockets open. Anybody know what could be causing this?
>>
> But sockets in CLOSE_WAIT state is exactly what you should expect when you
> close a socket without sending the goodbye command expected by the peer.
> The sockets on the Linux machine are most likely in FIN_WAIT_2 state,
> right?
> You need to find out, what goodbye command the WinampRC expects.
>
The linux end shows FIN_WAIT2, but those don't take long to go away. The
Close Wait sockets on the windows machine linger and cause problems.
Connecting to sock on the linux machine using the original windows client
only shows "sock: socket read: Connection reset by peer" on disconnect.. Is
this just something I'll have to deal with?
Any help is greatly appreciated.
--
+---------------+
| Spork Boy | It was recently discovered that research
| AIM: Sporkite | causes cancer in rats.
| ICQ: 859886 |
+---------------+
------------------------------
Date: Sat, 05 May 2001 07:35:54 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <d7b7ft8ght79gjb1h5q78r5k824betr46f@4ax.com>
George Bailey wrote:
>I keep wanting to say "you know what's a good program for resizing
>images? Photoshop, that's what."
>Apologies, but it will be a much much better tool for the job than
>anything a Perl script can do.
I doubt it.
Both ImageMagick, and the stuff included with the JPEG source code from
the IJG, are as good as Photoshop for resizing images. And honestly, I
think that the IJG's code for reducing the number of colours (e.g. for
converting JPEG to GIF), the IJG does a *better* job than Photoshop. at
least, *I* feel that the result looks better.
--
Bart.
------------------------------
Date: Sat, 05 May 2001 10:01:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Recursing a directory tree
Message-Id: <47j7ft0645cuc790ukl5668asrvur3fp40@4ax.com>
Arun Horne wrote:
>Does anyone have some simple code to recurse a directory tree please??
File::Find can do whatever you want. It is in the standard distribution.
Now, getting started might be a bit tricky for a newbie. So here is some
sample code. It lists all files and directories in the current directory
and any subdirectories.
#! perl -w
use File::Find;
use Cwd;
$\ = "\n"; $, = "\t";
find sub {
my $type = -d $_? 'D': -f _ ? 'F' : 'L';
print $_, $type, $File::Find::name;
}, cwd();
For a variation, replace "find" with "finddepth". This one reverses the
order, in that if will process all files and sub directories before it
processes the directory itself.
Also notes that for each file, where $_ is the file's basename, the
current directory is where the file is in at the time of the callback,
so simple file tests like -f or -f $_ do work. Also note that I do
-d $_ and not -d because of the question mark that follows it.
--
Bart.
------------------------------
Date: Sat, 05 May 2001 22:22:07 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: Recursing a directory tree
Message-Id: <3AF3F06F.F78889D3@tassie.net.au>
"Randal L. Schwartz" wrote:
> >>>>> "Jfreeman" == Jfreeman <jfreeman@tassie.net.au> writes:
>
> >> next if m/^\.{1,2}$/; # skip the dot files
>
> Jfreeman> So that you only skip the . and .. files fine.
>
> Actually, that's wrong because it matches "..\n" and ".\n", perfectly
> legal names, and a great way to skip by this code if it would be an
> advantage to do so.
Correct as always! I should apologize twice, for posting imperfect code and an
imperfect correction! I must admit given that there is a /m modifier to make $
match an embedded \n I am surprised that Perl classes '..\n' as not an embedded
\n whereas '..\nfoo' of course is. I find it somewhat inconsistent that '\n..'
will not match that regex without a /m modifier too, as to my eye this is no more
embedded than '..\n'
I will be looking through some of my CGIs to see if they are potentially
compromised by my earlier incorrect assumption about the behavior of regexes.
Fortunately as a big fan of chomp....
The code is what I use for a directory logger and as i don't name dirs .foo has
not caused any problem, although as pointed out it could in other circumstances.
There are two big lessons:
First when giving advice make sure it is accurate although in this forum any
errors tend to be mercilessly thrown back at you!
Second never use a regex when simple equality will do. It is easier to reliably
predict everything that will match using equality!
next if $_ eq '.' or $_ eq '..'; # skip the dot files (only . and .. !!!!)
Thanks for the heads up
James
>
>
> --
> 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: Sat, 05 May 2001 13:12:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Recursing a directory tree
Message-Id: <l1v7ftcfirdj5a4s152pe5djbjbuu7htfp@4ax.com>
Jfreeman wrote:
>"Randal L. Schwartz" wrote:
>
>> >>>>> "Jfreeman" == Jfreeman <jfreeman@tassie.net.au> writes:
>>
>> >> next if m/^\.{1,2}$/; # skip the dot files
>>
>> Jfreeman> So that you only skip the . and .. files fine.
>>
>> Actually, that's wrong because it matches "..\n" and ".\n", perfectly
>> legal names, and a great way to skip by this code if it would be an
>> advantage to do so.
>
>Correct as always!
> next if $_ eq '.' or $_ eq '..'; # skip the dot files (only . and .. !!!!)
Have you ever heard of the \z zero-width assertion?
next if /^\.\.?\z/;
--
Bart.
------------------------------
Date: Sat, 5 May 2001 09:12:51 -0400
From: "Keith G" <gasper@cis.ohio-state.edu>
Subject: redirect to a url & avoiding hacks
Message-Id: <9d0u5j$6j3$1@news.cis.ohio-state.edu>
Hi -
I'm trying to do some moving and shaking in a script before
redirecting the user to a different web page. is this the best way
to do this:
......
print $query->redirect('http://www.mypage.com/thepage.htm');
die;
Am I using this appropriately? it doesn't seem to be working.
any suggestions?
Here's my second question. I'm running win2000 advanced server
and I've got a cgi directory set up where I have all my scripts placed.
I need to be able to write in the directory so I can create files
using perl scripts out on the web. However, the other day I noticed
someone had placed default.htm, default.asp, index.htm, and index.asp
files in my cgi directory that were the obvious work of a hacker. How
do I protect my machine against hackers writing to my cgi directory
without giving up the ability to write to files from my perl scripts?
This is frustrating! thanks for the help!!
Keith
------------------------------
Date: Sat, 05 May 2001 07:01:34 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: redirect to a url & avoiding hacks
Message-Id: <3AF407BE.77C211CE@stomp.stomp.tokyo>
Keith G wrote:
(snipped)
> is this the best way to do this:
> print $query->redirect('http://www.mypage.com/thepage.htm');
This is your worst possible choice. You are using quarter of
a megabyte of coding, well over six-thousand lines of code
to accomplish what can be done in one line of code:
print "Location: url/path/to/new/page";
> any suggestions?
Use of CGI.pm in almost all cases is massive overkill.
Learn to how program rather than learn how to copy
and paste module syntax. Doing this will teach you
how to write fast, efficient scripts which are
relatively bug free.
> I need to be able to write in the directory so I can create files
> using perl scripts out on the web.
As you know, a script directory which is writable is
considered a major security risk, unless you well know
how to manage this type of methodology.
> someone had placed default.htm, default.asp, index.htm, and index.asp
> files in my cgi directory that were the obvious work of a hacker.
You also know a hacker would not install these types of files.
Godzilla!
------------------------------
Date: 05 May 2001 09:25:30 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: redirect to a url & avoiding hacks
Message-Id: <878zkban51.fsf@limey.hpcc.uh.edu>
>> On Sat, 5 May 2001 09:12:51 -0400,
>> "Keith G" <gasper@cis.ohio-state.edu> said:
> Hi - I'm trying to do some moving and shaking in a
> script before redirecting the user to a different web
> page. is this the best way to do this:
> ...... print
> $query->redirect('http://www.mypage.com/thepage.htm');
> die;
> Am I using this appropriately? it doesn't seem to be
> working.
"it doesn't seem to be working". We can't read your mind!
What does it actually do? What is it supposed to do?
What is is actually doing is outputting the redirection
and then dying. That doesn't sound right to me. Why are
you redirecting the client elsewhere then exiting in some
kind of error state? "exit" sounds more useful here, but
without more context it is impossible to say.
> obvious work of a hacker. How do I protect my machine
> against hackers writing to my cgi directory without
> giving up the ability to write to files from my perl
> scripts? This is frustrating! thanks for the help!!
Off-topic for this newsgroup. Try a
web-server/W2K-security group.
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: Sat, 05 May 2001 10:43:49 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Simple question
Message-Id: <3AF411A5.717D1EFA@mortgagestats.com>
Bart Lateur wrote:
> Waarddebon wrote:
>
> >I want to check if a variable is ok by comparing them with 2 values.
> >
> >if ($x=10)
> >or
> >if ($x=23){print"ok";}
> >
> >How do I replace the or command ?
>
> First of all, you want either "==" or "cmp", not "=".
>
> Second, loose the second "if", and roll the two conditions into one:
>
> if($x==10 or ^$x==23) { print"ok"; }
The hat (^) in front of the second dollar sign is a typo, right?
------------------------------
Date: 5 May 2001 08:04:39 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: UPPERCASE to "Sentence Case"
Message-Id: <9d0c6n$ig6$1@towncrier.cc.monash.edu.au>
Dan <nospam@newsranger.com> writes:
>If someone could direct me to a resource with information on this
>topic, I would greatly appreciate it.
Give Text::Autoformat a try.
Damian
------------------------------
Date: Sat, 05 May 2001 12:11:30 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: UPPERCASE to "Sentence Case"
Message-Id: <4gr7ftk6a2bq8ftflmejttp0rpk6s29uaj@4ax.com>
Craig Berry wrote:
>If you're willing to accept the rule
>that any character other than one following start-of-file or a period (and
>whitespace) should be lowercase
And question marks, and exclamation marks.
Plus: if there's more than just one dot, this does not imply the start
of a new sentence.
--
Bart.
------------------------------
Date: Sat, 05 May 2001 09:55:55 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: UPPERCASE to "Sentence Case"
Message-Id: <3AF4066B.4CD64D06@mortgagestats.com>
Anno Siegel wrote:
> According to Abigail <abigail@foad.org>:
> > Dan (nospam@newsranger.com) wrote on MMDCCCIII September MCMXCIII in
> > <URL:news:zGFI6.1700$vg1.142294@www.newsranger.com>:
> > ?? Can someone point me to a resource that has information on converting text t
> > ?? is all uppercase into "sentence case". All uppercase will need to be conver
> > ?? to lowercase except for the first word of a sentence will need to remain
> > ?? uppercase. The text I need to convert often contains ellipses, so the word
> > ?? after an ellipsis will need to be capitalized, also.
> > ??
> > ?? Also, certain words not at the beginning of the sentence will need to be
> > ?? capitalized and I would assume that will require some sort of list of words
> > ?? the code will have to check for those words.
> > ??
> > ?? If someone could direct me to a resource with information on this topic, I w
> > ?? greatly appreciate it.
> >
> >
> > The only non-trivial part is deciding what a sentence is. Once you do that,
> > you just apply 'ucfirst lc' on it.
> >
> > How you can parse sentences out of a text is a different matter, and
> > beyond the scope of this group. Try alt.usage.english.
>
> ...who will be delighted to explain that there is no way to do that.
>
> Anno
Actually, alt.usage.english is quite inappropriate for the "how do I recognize a
sentence?" question because it has nothing to do with usage and very little to do with
English. You may have more luck in sci.lang.
I guess as a rudimentary approach, you could do this:
1. Draw up a list of symbols that are likely to end a sentence, such as !, ?, ., ...,
!), ?), .). You can assume that these symbols, followed by whitespace and a letter
are an indicator of a sentence boundary.
2. Draw up a list of often-used abbreviations, such as Mr, Mrs, Dr, pt, lb, kg. When
these -- or a number -- precede a period, you can assume that you didn't find a
sentence boundary after all.
3. You will also need to put together a list of words, (I, the names of months and
days, proper names if your text is English; all nouns if your text is German) which
you will capitalize no matter what.
4. You will have to live with the fact that your program will make some mistakes. (I
doubt, for example, that even Abigail can write a snappy little one-liner that will
distinguish between 'August' and 'august' based on context.) If this is unacceptable,
you might want to have a live person post-edit your text.
This is an interesting problem and perl is a good tool to solve it. If you are not
good at regular expressions, this is the time to read up on them.
------------------------------
Date: Sat, 05 May 2001 13:00:43 +0200
From: "Perl Lover" <dj@syntaxerror.crazydj.de>
Subject: Re: Using Modem::Vgetty
Message-Id: <20010505.130043.1626276121.1249@Syntaxerror.crazydj.de>
Im Artikel <9cvrhr$66d2$1@newssvr05-en0.news.prodigy.com> schrieb "Jimi
Thompson" <JIMIT@prodigy.net>:
> Have you tried www.freshmeat.net, www.sourceforge.com, and
> http://www.cpan.org
>
Yes I have. But the only tool I found was opentel and I dont know how to
use it...
------------------------------
Date: Sat, 05 May 2001 23:06:28 +1000
From: Jfreeman <jfreeman@tassie.net.au>
Subject: Re: warnings from MIME-Lite
Message-Id: <3AF3FAD3.F084E326@tassie.net.au>
Mike Solomon wrote:
> When I run a script that uses MIME-Lite to send E-mail I get the following
> warnings :
>
> Use of uninitialized value in substitution (s///) at
> D:/Perl/site/lib/MIME/Lite.pm line 998 (#1)
>
> (W uninitialized) An undefined value was used as if it were already
> defined.
> It was
> interpreted as a "" or a 0, but maybe it was a mistake. To suppress
> this
> warning assign a defined value to your variables.
>
> Use of uninitialized value in scalar assignment at
> D:/Perl/site/lib/Net/Domain.pm line 193 (#1)
> Use of uninitialized value in pattern match (m//) at
> D:/Perl/site/lib/Net/Domain.pm line 217 (#1)
> Use of uninitialized value in split at D:/Perl/site/lib/Net/Domain.pm line
> 221 (
> #1)
> Use of uninitialized value in concatenation (.) at
> D:/Perl/site/lib/MIME/Lite.pm line 1889 (#1)
>
> Without disabling diagnostics or editing Lite.pm and Domain.pm, is there any
> way to disable these messages ?
So you don't want to change the code that is causing the warnings OR switch off
the warnings that this code is generating. I'd say that question almost answers
itself!
Unless there is a bug in the script or you added warnings, I suspect you are
calling subs without sending them all the required arguments but as you have not
sent any code.... If you fail to send args then variables may not be initialised
and may cause errors such as you are seeing.
If you are calling these subs from multiple locations then to find out what part
of your program is calling these subs you can use the caller function.
($package, $filename, $line) = caller;
If the package and filename come back as the modules then the offending sub was
called from there. To find out where the caller of that call came from use =
caller (1). To find the caller of the caller of the caller use = caller (2).....
Slip this in near the problematic lines in the *.pm and print the result
somewhere to tell you exactly what part of your script is making the call that
results in the error. Add a few more prints in there to dump the variable values
and the problem should become instantly evident, along with a solution.
James
>
>
> Regards
>
> Mike Solomon
------------------------------
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 838
**************************************