[18669] in Perl-Users-Digest
Perl-Users Digest, Issue: 837 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 5 03:05:49 2001
Date: Sat, 5 May 2001 00:05:06 -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: <989046306-v10-i837@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 5 May 2001 Volume: 10 Number: 837
Today's topics:
Re: DNS Lookups (Michael Fuhr)
Re: Familiar with this perl fix permission script <mischief@velma.motion.net>
Re: File transfers (Anno Siegel)
Re: HELP - Please (Gwyn Judd)
Re: Peculiar output from 'top' command (Greg Andrews)
Re: Perl and MySQL problem <kellewic@yahoo.com>
Re: Perl and Mysql <kellewic@yahoo.com>
Re: pointer/reference question <goldbb2@earthlink.net>
Re: re-sizing GIF images on the fly <georgebailey@my-deja.com>
Re: Recursing a directory tree <mischief@velma.motion.net>
Re: Recursing a directory tree (Randal L. Schwartz)
Re: Removing attributes <JIMIT@prodigy.net>
reverse of perlcc <bop@mypad.com>
Re: sub z {return } print ((($x,$y)=z) ? "yes:$x,$y\n" (Anno Siegel)
Re: Uploading files through a web page <mondo@serv1.jump.net>
Re: UPPERCASE to "Sentence Case" (Abigail)
Re: UPPERCASE to "Sentence Case" (Anno Siegel)
Re: UPPERCASE to "Sentence Case" (Craig Berry)
Re: Using Modem::Vgetty <JIMIT@prodigy.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 May 2001 18:18:04 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: DNS Lookups
Message-Id: <9cvgrs$ht9@flatland.dimensional.com>
Mike Myers <mmyers1@home.com> writes:
> I have been using the following to perform DNS queries on large files:
>
> $name = gethostbyaddr(inet_aton("$nodes[$count]"), AF_INET) || "no DNS
> found";
>
> where @nodes is a list of IPs.
>
> This works well for most queries, but not when the server fails to
> respond. If the server fails, it takes approx 17s for gethostbyaddr to
> timeout and move to the next entry.
>
> Is there a method to implement a simple timeout feature to improve
> efficiency without resorting to NET::DNS?
One possibility would be to use alarm(), as Ron Hill implied when he
referred to a message he'd posted in a thread on connection timeouts.
This is probably the simplest solution.
Another possibility would be to write a small module with some C code
to tweak the settings of the _res structure. I've already done this
in case you're interested.
Net::DNS isn't appropriate for all DNS tasks, but it does have a
somewhat limited background query capability. The demo script
mresolv2 (included with Net::DNS) is a simple example of how to
make many DNS queries without having to wait for each one to
finish. It's not perfect, but some people have reported good
performance with it.
A non-Perl possibility is the GNU adns library. The adnslogres and
adnshost utilities that come with it are able to perform concurrent
queries, which can greatly speed up resolving large numbers of
addresses.
http://www.chiark.greenend.org.uk/~ian/adns/
Hope this helps.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
------------------------------
Date: Sat, 05 May 2001 00:59:59 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Familiar with this perl fix permission script
Message-Id: <tf6k4fao3e6o76@corp.supernews.com>
newuser <newuser@nospam.slip.net> wrote:
> Hello,
> Every once in awhile my shell account goes crazy and it never puts the
> correct permission as I ask for. The tech from my isp always has to do a
> ls -lag which he
'ls' only lists the directory contents.
> says that only techs can do. He mentioned that there is a work around to
If you can log in to your shell, you can do an 'ls -lag'.
> this if I know how to write a perl script that runs the following command
> "chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null
You can do this easily.
> Have anyone seen a script that can do this and if so can they post it
> here. I would also like if someone can explain to me how this works.
> thanks a lot for your help
Why this works to set your permissions back to what you consider
normal is because once you set your permissions to the 'norm'
of '777', everyone else on the box can change your permissions.
If you had sensible permissions on your files, you'd probably
not have so many problems. Try '750' on your executables and
'640' on your non-executables, then pick up a book on Unix.
Chris
--
For the pleasure of others, please adhere to the following
rules when visiting your park:
No swimming. No fishing. No flying kites. No frisbees.
No audio equipment. Stay off grass. No pets. No running.
------------------------------
Date: 4 May 2001 22:41:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: File transfers
Message-Id: <9cvb7i$4nm$1@mamenchi.zrz.TU-Berlin.DE>
According to Hans Kristian Eriksen <h.k.k.eriksen@astro.uio.no>:
> Hello.
>
> I'm writing a server/client program which sends information back and
> forth over a socket. Most of the information is just plain numbers or
> text strings, but sometimes I also have to transfer binary files. So
> the process looks something like this:
>
> send number/text
> send number/text
> send file
> send number/text
> send number(text
>
> The single numbers and text strings are sent like this:
>
> print Client $info;
> $info = <Server>;
Apparently you are sending newlines after each chunk. Then this
works because the newlines serve as separators and tell the receiver
how much to read on each go. Never mind that it's the <> operator
that separates the chunks, the effect it that of a mini-protocol.
> but the files are more difficult.
Yes, because they can contain anything. So a simple line protocol
won't do. You need a way to tell the receiver where exactly the
file ends.
> I'm trying to do something like:
>
> server:
>
> open(IN, "$filename");
> while (read(IN, $buf, 1024)) {
> print Client $buf;
> }
> close(IN);
>
> client:
>
> open(OUT, ">$filename");
> while ($buf = <Server>) {
You are reading binary data line-wise. That is a bad idea: there
may be random line feeds in the data or not, but you're essentially
reading chunks of random size. What's worse, you are almost
guaranteed to read past the end of the file.
> print OUT $buf;
> }
> close(OUT);
>
> And it works. If I dont send anything over the socket after the file
> transfer! And this is not acceptable for the rest of the program.
As mentioned, you need a way for the receiver to tell when the file
transfer is over. If you have the file size handy before you start,
you can simply transmit the length of the file (newline-terminated,
last time this works for a while). Then send the file in arbitrary
blocks, just like you do now. You can even send it all at once
and let the system do the buffering. The reader now knows how
many bytes to read and can take care not to read any more, whatever
scheme you use for reading.
If you don't know the file size beforehand, things get a little more
involved, but the basic principle remains: At each partial transfer
the reader needs to know how many bytes to expect. You will also
have to tell it which one is the last block.
Anno
------------------------------
Date: Fri, 04 May 2001 22:44:45 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: HELP - Please
Message-Id: <slrn9f6c6r.976.tjla@thislove.dyndns.org>
"mein Luftkissenfahrzeug ist voll von den Aalen"
said Methods, Verification [SKY:1G20:EXCH] (vbook@americasm01.nt.com) in
<3AF32468.7C6BBAE7@americasm01.nt.com>:
>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.
You should check the FAQ before you go any further. This question (or
one very similar) is answered:
perldoc -q 'How do I change one line in a file'
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I guess some people aren't allowed dreams...
-Mike Flynn
------------------------------
Date: 5 May 2001 04:58:15 GMT
From: gerg@panix.com (Greg Andrews)
Subject: Re: Peculiar output from 'top' command
Message-Id: <9d0197$jrn$1@news.panix.com>
"Mr. Sunray" <djberge@uswest.com> writes:
>
>I'm doing some system monitoring by sending the output of the 'top'
>command to a web page via CGI.pm. For now, I'm just trying to print the
>headers (PID, USER, etc) into an HTML table. When sent to the command
>line, the headers appear as expected. When sent to the web page, I'm
>getting two anomalies.
>
>The first result is showing up in the web page as "[7m" - I've no idea
>what that is
>The last result is showing up as "COMMAND[K[m" - The 'COMMAND' is
>correct, but what are those end characters?
>
Those are top's cursor movement sequences. It thinks it's sending
its output to a terminal screen, so it's sending the terminal's
screen formatting codes instead of plain text with space characters
to separate the different fields.
>...
>if($^O eq "solaris"){ @results = `top -n 10` }
>else{ @results = `top -n 1` }
>
I used a different approach. I used the pipeline form of the open()
function to read top's output via a file descriptor:
$topcommand = '/usr/bin/top -n all';
open(TOP, "$topcommand |") || die "Can't run top: $!\n";
while (<TOP>) {
# parsing of top's header and
# list of processes here
}
The fact that top's stdout was piped to my script rather than
going to a terminal (or being captured by backquotes) seemed to
convince top that it shouldn't use terminal escape sequences in
its display.
My particular script grabbed certain parts of top's header for
things like the load average and total number of processes.
It also parsed top's process list to count certain processes
that I wanted to track (number of sendmails, number of httpds,
stuff like that). That's why I told top to list all processes
instead of just the top ten.
Hope this helps,
-Greg
--
+++++ Greg Andrews +++ gerg@panix.com +++++
I have a map of the United States that's actual size
-- Steven Wright
------------------------------
Date: Sat, 05 May 2001 00:23:46 GMT
From: "Shay Harding" <kellewic@yahoo.com>
Subject: Re: Perl and MySQL problem
Message-Id: <mKHI6.76954$181.12030434@news1.rdc1.az.home.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9f5lla.4k6.tadmc@tadmc26.august.net...
> John Joseph Trammell <trammell@bayazid.hypersloth.invalid> wrote:
>
> >Looks like $name is empty at some point. How about a test like
> >
> > unless ($name) { die "name not defined..." }
>
>
> That does not test if name is empty. That tests if name is true,
> but the die reports defined instead..
>
> "true", "empty" and "defined" mean different things, and require
> different tests. Your's above tests if $name is "true", err "false"
> since you have inverted the "if" to an "unless".
>
>
> unless ( length $name ) ...
>
> _That_ tests if $name is "empty" (and also does not fail if $name should
> happen to have a value of "0".
>
>
> unless ( defined $name )
>
> That tests if $name is defined.
Ok, I already responded to this since I didn't see it was posted twice.
I just want to point out that you also do not want $name to contain a '%' or
'_' unless you specifically look for those and preceed them with a '\'.
MySQL will use those in the query so if I enter '%' (or any number of '%'s
for that matter), you will still update all records in the database.
By simply testing length, you may still end up updating everything.
Shay
------------------------------
Date: Sat, 05 May 2001 00:20:04 GMT
From: "Shay Harding" <kellewic@yahoo.com>
Subject: Re: Perl and Mysql
Message-Id: <UGHI6.76953$181.12028488@news1.rdc1.az.home.com>
"King Fu" <kingfu@blueyonder.co.uk> wrote in message
news:eAAI6.99$Sc.9091@news1.cableinet.net...
> Sorry if ive posted this twice but it didnt seem to work the last time as
> ive been having trouble with my newserver:
>
>
> hi ive got a strange problem i cant seem to work out, im trying to update
a
> field for a certain in a mysql database using the insert sql command, most
> of the time this works fine but on occastion i find that all the field for
> all the records in the table have been updated!!! Im not sure why this is
> occuring, its a cgi script so is obvously occuring under certain
> circumstances when a visitor does a certain thing but without knowing what
> they do im kinda screwed!
> heres the snippit of what appears to be the problem code
>
> $sth=$dbh->prepare("SELECT name from downloads WHERE name LIKE
'%$name%';")
> || die "Prepare failed: $DBI::errstr\n";
> $sth->execute() || die "Coultdnt execute query: $DBI::errstr\n";
> $foundMatch=0;
> $foundMatch=$sth->rows();
>
> #if a match is found increment the number of downloads for the file
> if($foundMatch)
> {
> $sth=$dbh->prepare("SELECT downloads from downloads WHERE name LIKE
> '%$name%';") || die "Prepare failed: $DBI::errstr\n";
> $sth->execute() || die "Coultdnt execute query: $DBI::errstr\n";
> $downloads=$sth->fetchrow_array();
> $downloads++;
> #save the new downloads var to the database
> $sth=$dbh->prepare("UPDATE downloads SET downloads=$downloads WHERE name
> LIKE '%$name%';") || die "Prepare failed: $DBI::errstr\n";
> $sth->execute() || die "Coultdnt execute query: $DBI::errstr\n";
> &printNewDownloadWindow;
> }
>
> This section of code is only run once per cgi session so as you can see im
> quite baffled how it updates every record of teh table! Espcially as
seeing
> theirs a few hundred records which shouldnt ever be touched for quite some
> time.
If $name is not set or blank, you will match every record in the table and
thereore update all of them. Might want to check $name to make sure you have
a value. Could do this simply by length $name > 0. You will also not want
name to have a '%' in it since that means something special to MySQL (as
does '_').
Basically with $name set to nothing you get:
$sth=$dbh->prepare("SELECT name from downloads WHERE name LIKE '%%';")
Since you retrieve all records $foundMatch = #rows returned so your 'if'
block is entered. Then
$sth=$dbh->prepare("SELECT downloads from downloads WHERE name LIKE '%%';")
is executed, again, retrieving all records from 'downloads'. Finally:
$sth=$dbh->prepare("UPDATE downloads SET downloads=$downloads WHERE name
LIKE '%%';")
is executed, updating all records in 'downloads'.
Shay
------------------------------
Date: Sat, 05 May 2001 06:53:12 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: pointer/reference question
Message-Id: <3AF3A48B.69833E19@earthlink.net>
xris wrote:
>
> In article <9c085n$9h7$1@charity.cs.utexas.edu>,
> logan@cs.utexas.edu (Logan Shaw) wrote:
>
> > I think what the original poster wants is for Perl references to
> > behave like C++ references (i.e. for them to be syntactically like
> > regular values by semantically like pointers) but without tweaking
> > the symbol table. I don't think that's likely to happen.
>
> yeah, I think this is more what I'm after.. a world in which:
>
> \$x = \$y;
I assume you want something similar to doing in C++ :
int &x = y;
> works. :) oh well, just wanted to make sure that I really CAN'T do
> that, and that I wasn't just doing something wrong.
>
> and in answer to the aforementioned "$x=$y" thing, that copies the
> data, not the reference. I'm, I guess, looking for that C/C++
> functionality where I can havevariables called $x and $y (not $$x or
> $$y or whatever - I know how to manage with those things) that both
> access the same data space, so that:
>
> $x = 1;
> ...somehow assign \$y=\$x...
Well, you can do
local *y = \$x;
> $y++;
> print $x;
>
> results in "2"...
>
> but I guess that isn't going to happen any time in the future, so I'll
> stop dreaming and get back to actually writing code. :)
It's not really all that bad a dream, but it's a question of how to do
it without undesired side effects.
Using a local assignment to a typeglob from a scalar ref is quite close
to what you want, particularly if no subs are called from within the
block you do it. It does have the side effect of temporarily creating a
global $y for the duration of the block, which may not be what you want;
if a sub (within the block the local assign was made) tries looking for
the 'real' global variable $y it will find your alias for $x.
$y = 'aaa';
sub foo { ++$y; }
sub bar {
my $x = 1;
print foo(), "\n";
{ local *y = \$x;
print ++$y, "\n";
print foo(), "\n"; }
print foo(), "\n";
}
bar();
__END__
aab
2
3
aac
You *can* achieve what you want with no undesired side-effects, by using
a tied scalar. The only drawback I can see of using a tied scalar is
that it may have a higher overhead than you'd like. The thing to do
seems to be to use a local assignment to a glob from a scalar ref in
those situations where the making of a temporary global is harmless
(which should be most of the time), and to use a tied scalar elsewhere.
Oh, and the drawback that you actually have to write the class to tie
to, since I'm not going to do it for you :)
--
Shift to the left, shift to the right, mask in, mask out, BYTE, BYTE,
BYTE !!!
------------------------------
Date: Sat, 05 May 2001 09:11:09 +1000
From: George Bailey <georgebailey@my-deja.com>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <georgebailey-54B1D0.09110905052001@news.connect.com.au>
I keep wanting to say "you know what's a good program for resizing
images? Photoshop, that's what."
Since version 4 Photoshop has had kick-ass automation features built
into it, so making this absolutely not a Perl question at all, you can
get yourself a Photoshop batch processing script which can do any
operation that Photoshop itself can do, for instance letterboxing files
which don't fit your standard size (putting blank white or black space
to fill out the size, with your thumbnail in the center) and it will
also do a much much better job of resizing a GIF because it will change
it to RGB then resize then switch the graphic back to Indexed Color.
Apologies, but it will be a much much better tool for the job than
anything a Perl script can do.
------------------------------
Date: Sat, 05 May 2001 00:43:25 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Recursing a directory tree
Message-Id: <tf6j5disnm8796@corp.supernews.com>
Dave Bailey <dave@sydney.daveb.net> wrote:
> On Fri, 04 May 2001 21:38:19 +1000, Jfreeman <jfreeman@tassie.net.au> wrote:
> [I wrote]
>>Which directory will list with this?
>>
>>dir .\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. (ls ./././././././././././././.)
> The directory with that name, if it exists. Try making a directory
> with that name and see for yourself.
If I tried to make a directory with that name, I would fail, as I
cannot creat the current directory in the current directory.
C:\WINDOWS>mkdir .
Cannot make directory entry - .
[mischief@velma ~]$ mkdir .
mkdir: cannot create directory `.': File exists
[mischief@velma ~]$ mkdir ./././././././././././././.
mkdir: cannot create directory `./././././././././././././.':
File exists
This is what happens when you try to create such a directory
on a Unix variant or on Windows/DOS. If I had an OS which
allowed such evil names, I would likely delete the OS. If I
didn't delete it, it still wouldn't be portable to assume
I could make directories named like that. Although it's not
entirely portable to assume you can't have names like that,
I'd say that having a directory named './././././././././././././.'
on OSes which would allow it is unlikely unless you're just
trying to be a joker.
Now, back to Perl.
Chris
--
For the pleasure of others, please adhere to the following
rules when visiting your park:
No swimming. No fishing. No flying kites. No frisbees.
No audio equipment. Stay off grass. No pets. No running.
------------------------------
Date: 04 May 2001 17:51:51 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Recursing a directory tree
Message-Id: <m11yq4aa8o.fsf@halfdome.holdit.com>
>>>>> "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.
--
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: Fri, 4 May 2001 22:27:16 -0500
From: "Jimi Thompson" <JIMIT@prodigy.net>
Subject: Re: Removing attributes
Message-Id: <9cvrna$58io$1@newssvr05-en0.news.prodigy.com>
Have you tried www.freshmeat.net, www.sourceforge.com, and
http://www.cpan.org for another application? There are a great many out
there for editing LDAP trees.
The previous post wanted to see your PERL code, which if you are having a
problem, you might consider posting. Some of us that are familiar with both
might possibly be able to help you out.
Jimi
Philippe Hamel <hamel@hotmail.com> wrote in message
news:tf5cdig2522k7d@corp.supernews.com...
> Well, I did give you an idea of what my problem is. I'm trying to remove
an
> attribute from an entry. No, there's no error message to parse, because
> there's no code to give an error. That's the same reason why there's no
> code included in my post. I'm not getting an error trying to remove an
> attribute with faulty code, I just plain don't know how to do it.
>
> Using Net::LDAP's "delete" function, I'm able to remove an entry, but not
an
> attribute. Can an attribute be removed using that function or is there
> another one?
>
> I'm sure there's a way to do it, since I'm using an LDAP browser that can
do
> just that. Too bad I don't have access to the code of the browser.
>
> Thank you.
>
> --
> Philippe Hamel
> Bureau :
> Courriel : phamel@logisil.com
> Tel : (514)866-5493 poste 419
> Maison :
> Courriel : philippe.hamel@apiiq.qc.ca
>
> "Jon Ericson" <Jonathan.L.Ericson@jpl.nasa.gov> wrote in message
> news:864rv1lrea.fsf@jon_ericson.jpl.nasa.gov...
> > "Philippe Hamel" <hamel@hotmail.com> writes:
> >
> > > I'm trying to delete attributes from an LDAP entry using perl and
> associated
> > > modules. I've figured out how to remove whole entries, but if I just
> want
> > > to delete attributes from an entry, how do I do that?
> >
> > I don't know the first thing about LDAP (except that I once got
> > Netscape mail to search the jpl.nasa.gov LDAP server). I know even
> > less how the protocol works. I don't know the name of the perl module
> > that speaks LDAP. You didn't give me any perl code to work with. You
> > didn't give me an error message to parse. You didn't give me any
> > hints as to what your problem is. I see you cross-posted to an LDAP
> > group, but this is pretty much off-topic there too (unless there is
> > something about the protocol that makes deleting attributes
> > impossible). Please consider posting some code.
> >
> > Jon
>
>
------------------------------
Date: Sat, 05 May 2001 01:24:16 GMT
From: "flash" <bop@mypad.com>
Subject: reverse of perlcc
Message-Id: <4DII6.3$qY3.3382@news20.bellglobal.com>
is there a ccperl or something.
i need a way to convert c code to perl, can it be done?
------------------------------
Date: 4 May 2001 23:46:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: sub z {return } print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")
Message-Id: <9cvf0a$74p$1@mamenchi.zrz.TU-Berlin.DE>
According to Ilmari Karonen <usenet11446@itz.pp.sci.fi>:
> In article <slrn9f04db.3ts.tjla@thislove.dyndns.org>, Gwyn Judd wrote:
> >
> >and it still prints "yes". It is true that evaluating a list in scalar
> >context evaluates to the last item, and an array in list context
> >evaluates to the number of items. This is evaluating a list assignment
> >in scalar context which appears to be different again.
>
> s/a list in scalar/expressions separated by commas in scalar/
>
> Sorry for being pedantic, but there's still no such thing as a list in
> scalar context. Just keeping the facts straight here.
Yes, that's one of the tenets of the Perl Order. I wonder how slices
used like
$x = @y[ 0 .. 3];
fit in. Unless we decide to postulate a list context to the right
of "=" for the slice all by itself, I wouldn't know how to call the
right side of the assignment, except a list in scalar context.
Anno
------------------------------
Date: Fri, 4 May 2001 22:16:03 +0000 (UTC)
From: Mondo <mondo@serv1.jump.net>
Subject: Re: Uploading files through a web page
Message-Id: <9cv9n3$2un$1@news.jump.net>
Alex Thomas <alex.thomas@mindspring.com> wrote:
> is there a way to write a web page using perl so that you can upload a file
> from a local computer to the server where the script is?
Yep. Make the form enctype "multipart/form-data", like so:
<form method="post" enctype="multipart/form-data" action=upload.pl>
Then, make the input type "file", thusly:
<input type="file" name="upload_file" size=40>
Lastly, grab the file:
$file = $cgi->param('file').
$file is now a filehandle, so you can read and write to it as you see fit.
See the CGI.pm docs (http://search.cpan.org/doc/LDS/CGI.pm-2.753/CGI.pm)
for more info.
--
Mando
------------------------------
Date: Fri, 4 May 2001 22:41:41 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: UPPERCASE to "Sentence Case"
Message-Id: <slrn9f6c15.hrt.abigail@tsathoggua.rlyeh.net>
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.
Abigail
--
$_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
. "\162\1548\110\141\143\153\145\162\0128\177" and &japh;
sub japh {print "@_" and return if pop; split /\d/ and &japh}
------------------------------
Date: 4 May 2001 23:06:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: UPPERCASE to "Sentence Case"
Message-Id: <9cvcku$4nm$2@mamenchi.zrz.TU-Berlin.DE>
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
------------------------------
Date: Fri, 04 May 2001 23:19:08 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: UPPERCASE to "Sentence Case"
Message-Id: <tf6e7c4n7aet56@corp.supernews.com>
Dan (nospam@newsranger.com) wrote:
: Can someone point me to a resource that has information on converting text that
: is all uppercase into "sentence case". All uppercase will need to be converted
: 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.
This is very very *very* hard to do in the general case, given the
potential vagaries of punctuation. 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, this will work (assuming a read from
standard input):
my $text = lc do { local $/; <>; };
$text =~ s/((^|\.)\s*\w)/\U$1/g;
You can have fun tweaking the regex to handle question marks and
exclamation points and so forth, but you'll never be able to handle
arbitrary text correctly. Plan on manually editing resulting text to
catch the weird cases.
: 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 and the code will have to check for those words.
my @capitalized = qw(feeble grorb zoom krod);
my %capmap;
@capmap{@capitalized} = map ucfirst, @capitalized;
$text =~ s/(\w+)/exists $capmap{$1} ? $capmap{$1} : $1/eg;
: If someone could direct me to a resource with information on this topic, I would
: greatly appreciate it.
perldoc perlre
perldoc perlop
perldoc -f lc
perldoc -f ucfirst
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "God becomes as we are that we may be as he is."
| - William Blake
------------------------------
Date: Fri, 4 May 2001 22:24:16 -0500
From: "Jimi Thompson" <JIMIT@prodigy.net>
Subject: Re: Using Modem::Vgetty
Message-Id: <9cvrhr$66d2$1@newssvr05-en0.news.prodigy.com>
Have you tried www.freshmeat.net, www.sourceforge.com, and
http://www.cpan.org
Perl Lover <dj@syntaxerror.crazydj.de> wrote in message
news:20010504.222855.968338082.2945@Syntaxerror.crazydj.de...
> Hello.
> Can anyone of you explain how to use the module Modem::Vgetty to use my
> voice modem as an dial-in-server?
> I have read the documentation, but it doesn't work. Also the examples
> like answering-machine.pl does't work...
> Or maybe you know a better module or way of programming to solve my
> problem.
> Thanks a lot.
------------------------------
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 837
**************************************