[16076] in Perl-Users-Digest
Perl-Users Digest, Issue: 3488 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 27 00:05:26 2000
Date: Mon, 26 Jun 2000 21:05:08 -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: <962078708-v9-i3488@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Jun 2000 Volume: 9 Number: 3488
Today's topics:
Re: # of occurrances in a list (Colin Watson)
Re: # of occurrances in a list (Tad McClellan)
Re: C prog access to dbi? <cpcapps@erols.com>
Re: Changing case in a file! <flavell@mail.cern.ch>
Re: Golf (Was: Re: HELP ME PLEASE !!!!) <uri@sysarch.com>
Help with download access of restricted files nelsonmuntz4925@my-deja.com
Re: Help with download access of restricted files <rootbeer@redcat.com>
host lookup; gethostbyaddr <kevin_simmons@msn.com>
Re: iteration # with foreach (Abigail)
Re: matching question (http related) (Tad McClellan)
Re: Newbie question about subroutines... <DNess@Home.Com>
Re: Number of Unique Values (Gwyn Judd)
Re: Perl and Sockets <rootbeer@redcat.com>
Re: regex - slurp file and extract email addresses <roger_pack@hotmail.com>
Re: regex - slurp file and extract email addresses <rootbeer@redcat.com>
Re: Sys::Syslog & _PATH_LOG kjschmi@my-deja.com
Timers in ActivePerl <patrickdoyle@home.com>
Where is IO::Handle::error() defined? <franl-removethis@world.omitthis.std.com>
Re: Who's the man? You can be(ginner) <wyzelli@yahoo.com>
Re: Write to file problem <billy@arnis-bsl.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Jun 2000 02:23:02 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: # of occurrances in a list
Message-Id: <8j9366$b2r$1@riva.ucam.org>
Lauren Smith <lauren_smith13@hotmail.com> wrote:
>Colby Hansen <cghansen@micron.com> wrote in message
>news:8j8mkp$41n$1@admin-srv3.micron.com...
>> I'm using the following to find the number of unique items in a list:
[...]
>> Now I'm looking for a slick way to determine how many
>> occurrances of one particular item there are. Thanks!
>
>Increment each key's value each time you encounter it:
Or, if you're doing this independently of finding unique items, then
this is cleaner:
my $count = grep { $_ eq $item } @list;
--
Colin Watson [cjw44@flatline.org.uk]
"On Usenet, pedantry is not in the service of beauty. It's not even
in the service of truth. It's in the service of EVEN MORE PEDANTRY."
------------------------------
Date: Mon, 26 Jun 2000 21:33:18 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: # of occurrances in a list
Message-Id: <slrn8lg12u.8gs.tadmc@magna.metronet.com>
On Mon, 26 Jun 2000 16:48:56 -0600, Colby Hansen <cghansen@micron.com> wrote:
>I'm using the following to find the number of unique items in a list:
>
>my %unique = ();
>@unique{@list} = (undef) x scalar @list;
>my $uniquecount = scalar keys %unique;
>
>This works great! Now I'm looking for a slick way to determine how many
>occurrances of one particular item there are. Thanks!
my %unique = ();
$unique{$_}++ for @list;
print "$_: $unique{$_}\n" for sort keys %unique;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 26 Jun 2000 23:19:30 -0400
From: cc <cpcapps@erols.com>
Subject: Re: C prog access to dbi?
Message-Id: <39581D41.32904CA1@erols.com>
We are familiar with most of the c interfaces to databases, we have written
them for oracle, sybase, ms-sqlserver, etc. However we are looking for the
maintainability of odbc across platforms. This system is a distributed one,
that will need to run on all platforms, hence the interest in dbi. Can't
the dbi modules be accessed from C, that then can be linked into Java.
cc
Jonathan Stowe wrote:
> On Sun, 25 Jun 2000 11:28:31 -0400 cc wrote:
> > Does anyone know how to call dbi from a C program. We want to
> > distribute binaries and source. Actually, we wrote the whole system in
> > java and the performance is not acceptable, so we are exploring the
> > possibility of writing a database io component in dbi. We want to
> > distribute binaries if possible to simplify installation. Ideas?
> >
>
> I dont think that is very sensible. Most database vendors will provide
> a C interface which you can write to. I would look to the documentation
> for the database.
>
> /J\
> --
> ** This space reserved for venue sponsor for yapc::Europe **
> <http://www.yapc.org/Europe/>
------------------------------
Date: Tue, 27 Jun 2000 02:47:12 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Changing case in a file!
Message-Id: <Pine.GHP.4.21.0006270244460.18268-100000@hpplus03.cern.ch>
On Mon, 26 Jun 2000, Jerome O'Neil wrote:
> Indeed.
>
> > URLs are by definition case sensitive.
>
> I'm curious as to what definition of URL you are looking that would
> lead you to make such a statement.
Drat. I originally typed " - well, at least the URLpath part - " and
then trimmed that detail out again thinking that as I was off-topic,
I'd better not go into too much detail.
Oh well. Better luck next time, I suppose.
all the best
------------------------------
Date: Tue, 27 Jun 2000 03:10:31 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Golf (Was: Re: HELP ME PLEASE !!!!)
Message-Id: <x7n1k7u8d6.fsf@home.sysarch.com>
>>>>> "JS" == Jakob Schmidt <sumus@aut.dk> writes:
JS> kcivey@cpcug.org (Keith Calvert Ivey) writes:
>> If you say so, but that's not the rule in most of the Perl golf
>> I've seen. It could affect which entry wins, since some
>> whitespace can be omitted and some can't.
JS> $,=$/;print grep-d,<*>;
JS> By redundant whitespace I meant whitespace that _can_ be omitted. I think
JS> it's a bit silly to count that since removing it is completely trivial
JS> (though I can't say I was sure about the space between grep and -d before
JS> I tried).
JS> But it seems to be consensus, so I guess I must abide... Apparantly I was
JS> mistaken.
in the tpc4 tournament, every char is counted. so knowing how to
eliminate unnecessary white space is a very useful skill in perl
golf. some other simple tricks include using y/// instead of tr/// and
length, using an expression instead of a block in map/grep, removing
white space before vars as the $/@/% will end a previous token, etc.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 27 Jun 2000 01:03:41 GMT
From: nelsonmuntz4925@my-deja.com
Subject: Help with download access of restricted files
Message-Id: <8j8uh4$9l8$1@nnrp1.deja.com>
Hi have a perl script which authenticates a user then allows them to
download a big (24 MB) zip file. I simply set the content-type to
application/zip then open the file and start printing... Is that the
right way to do it? (I can not put it under the doctree for security
reasons, they must go thru the cgi).
My problem is that when they pick "save-as" it tries to save it as
download.cgi (that's my script name) rather than ABC123.zip. Is there
some header or something I can set to control the "save-as"?
Since these are big files, will the performance kill a server (having
the process run for so long). Or is there a better way to do this?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 26 Jun 2000 20:55:28 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Help with download access of restricted files
Message-Id: <Pine.GSO.4.10.10006262053460.578-100000@user2.teleport.com>
On Tue, 27 Jun 2000 nelsonmuntz4925@my-deja.com wrote:
> I simply set the content-type to application/zip then open the file
> and start printing... Is that the right way to do it?
> My problem is that when they pick "save-as" it tries to save it as
> download.cgi (that's my script name) rather than ABC123.zip. Is there
> some header or something I can set to control the "save-as"?
> Since these are big files, will the performance kill a server (having
> the process run for so long). Or is there a better way to do this?
Sounds as if you have a CGI programming problem. Perhaps you want to
search for the docs, FAQs, and newsgroups about CGI programming. Reading
comp.infosystems.www.authoring.cgi may help you to get started. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 26 Jun 2000 20:31:54 -0700
From: "Kevin Simmons" <kevin_simmons@msn.com>
Subject: host lookup; gethostbyaddr
Message-Id: <Ocbwej#3$GA.285@cpmsnbbsa09>
I am using gethostbyaddr to lookup internet IP addresses to hostnames. I am
processing many records and would like to be able to control the timeout and
retry values such as can be done when using nslookup. It appears that the
default values are being used, retry=4, timeout=5. Does anyone know a way to
adjust these values for use with gethostbyaddr? Here is a section of the
perl script that does the lookup:
# get hostname for URL
($hostip, $urlname) = split(/:/, $url);
next if !$hostip;
$addr = Socket::inet_aton($hostip); # lookup hostname
($hostname, $noise) = gethostbyaddr($addr, AF_INET);
if (!$hostname) {
$hostname = $hostip;
Tnx,
-Kevin
------------------------------
Date: 26 Jun 2000 21:41:02 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: iteration # with foreach
Message-Id: <slrn8lg2jb.ka1.abigail@alexandra.delanet.com>
Clinton A. Pierce (clintp@geeksalad.org) wrote on MMCDXCI September
MCMXCIII in <URL:news:ifO55.11271$fR2.134013@news1.rdc1.mi.home.com>:
:} [Posted and mailed]
:}
:} In article <3957a6bc.3572261@news.demon.co.uk>,
:} phil.taylor@bigfoot.com (Philip Taylor) writes:
:} > Is there a tidy way to establish the iteration number within a foreach
:} > loop without having to create a variable and increment it manually. ie
:} > to avoid this:-
:} >
:} > my $i=0;
:} > foreach (@myArray) { $i++; print $i, $_ }
:} >
:} > and do this:-
:} >
:} > foreach (@myArray) { print $someSpecialInternalThingy, $_; }
:}
:} The short answer is no. The long answer is also no. The ugly answer
:} is:
:}
:} # $i is the index, $v is the current value
:} # and @e is the original array
:}
:} foreach(my($i,$v)=0; $v=$e[$i],$i<@e; $i++) {
:} print "$i $v";
:} }
:}
:} Normally though, I find that I either want the offset or the value.
:} Hardly ever both.
foreach my $x (do {my $i = 0; map {[$i ++ => $_]} @array}) {
my ($index, $value) = @$x;
....
}
Although this is inefficient for large arrays.
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
------------------------------
Date: Mon, 26 Jun 2000 21:50:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: matching question (http related)
Message-Id: <slrn8lg235.8jf.tadmc@magna.metronet.com>
On Mon, 26 Jun 2000 20:54:44 -0400, Mike Johnson <mbmj@erols.com> wrote:
>Tad McClellan wrote:
>> And please don't post in reversed time order.
>
>Some say DO post in reverse time order, some say DON'T post in reverse time
>order. Who's a guy to believe?
Note the quality of the answers given by the the two different
styles, and decide for yourself who you want to emulate :-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 27 Jun 2000 01:21:34 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: Newbie question about subroutines...
Message-Id: <395801A3.46F0C913@Home.Com>
Bart Lateur wrote:
>
> The guy said he wanted to query several Internet search engines at once.
>
> If the bottleneck is your connection to the internet, then you're stuck
> with it.
>
> If, however, either the servers are slow to reply, or the routing from
> them to your machine takes a long time, then they are the bottlneck, and
> speed gain by doing threading is possible.
>
Oh. But surely if one wants to `talk to the net' there's no need to expect
that the responses should synchronize with the requests anyway, so it would
seem (to me at least) not a good use of multiple threads in any case...
------------------------------
Date: Tue, 27 Jun 2000 02:28:38 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Number of Unique Values
Message-Id: <slrn8lg4aj.l54.tjla@thislove.dyndns.org>
I was shocked! How could Abigail <abigail@delanet.com>
say such a terrible thing:
>Chris Sorensen (csorensen@uptimeresources.net) wrote on MMCDXCI September
>MCMXCIII in <URL:news:3957A7DD.B92D5201@uptimeresources.net>:
>
>Abigail
>--
>perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
>0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
>=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
>!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
...prints out
MMCDXCII September MCMXCIII
What is the significance of this number? It (2492 September 1993)
doesn't make much sense to me.
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
BOFH excuse #333:
A plumber is needed, the network drain is clogged
------------------------------
Date: Mon, 26 Jun 2000 20:49:38 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl and Sockets
Message-Id: <Pine.GSO.4.10.10006262046500.578-100000@user2.teleport.com>
On Tue, 27 Jun 2000 valarkin@my-deja.com wrote:
> I have tried most of the values for "S", V, v, I, i, M, m and the
> others.
That sounds as if you're trying format letters at random, rather than
looking in the docs to find the one that you need.
> How would I check to see if I got the 4 bytes?
See that the return value from sysread() is what you'd expect.
> And if I didn't get the data what should I do?
Generally, die() with a message that can help the user to find and fix the
problem.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 27 Jun 2000 01:30:05 GMT
From: <roger_pack@hotmail.com>
Subject: Re: regex - slurp file and extract email addresses
Message-Id: <slg0stpbjev119@corp.supernews.com>
Chris, Maybe you are a better programmer than me, only a intermediate or
less, but I have found a perl program from Earl Hood, with the whole
program code line.... I have tried to do the same thing you are trying
too. Go to altavista, search engine, type "free extract email addresses".
Many companies will tell us all, "free". NOT. I have used hours
researching....I am sorry, Chris, I am disabled have my bad grammar after
a stroke. Please, email my back if you need any more help, or please email
me back if you Good News.
Thank You , Roger Pack
Chris Sorensen wrote:
>
> Abigail wrote:
> > If there file is in free format, there isn't much you can do, as you
> > will have no idea where an email address might start, and where it
> > will end. Even newlines can be part of an email address.
> >
>
> the email addresses are all in the middle of a line - none are at the
> beginning or end (fortunately)
>
> > ][ $address =~ /^\s+/\Q@\E/\s+$/
> > ][ This seems wrong since it could start at the first whitespace in the
> >
> > You didn't even *try* this, did you? The above doesn't even compile.
> >
>
>
> i did try it .. and no .. it doesn't compile .. that's why I am asking
> for help .. I'm totally unsure of the syntax .. I'm trying to build an
> expression using the pocket reference as my guide .. I see that \s =
> whitespace and \S = non-whitespace ..
>
> I need to figure out how to say .. count forward and backward from @ to
> the closest whitespace on either side ..
>
> > You'd use \S, but what does "closest whitespace in front and at the
back
> > of @" have to do with email addresses? Addresses can contain
whitespace,
> > and can be delimited by other things than whitespace.
> >
>
> I haven't run across email addresses that contain whitespace .. that
> doesn't mean they can't .. it just means it's not usual.
> whitespace/something/@/something/whitespace is the best I could come up
> with ..
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Mon, 26 Jun 2000 20:44:20 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: regex - slurp file and extract email addresses
Message-Id: <Pine.GSO.4.10.10006262040420.578-100000@user2.teleport.com>
On 26 Jun 2000, Chris Sorensen wrote:
> If I don't ask .. how will I lean the syntax of regular expressions ..
No one is saying that you're not allowed to ask. But what you're trying to
do can't be done with simple patterns.
> I haven't seen an email address that looks like this joe
> blow@something.net ... there's usually an _ between the joe and blow
How about this one:
<"fred and barney"@redcat.com>
Okay, now you _have_ seen a valid e-mail address with a space in it. :-)
Now, if you still want to find out the format of e-mail addresses, you can
read RFC-822.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 27 Jun 2000 02:12:27 GMT
From: kjschmi@my-deja.com
Subject: Re: Sys::Syslog & _PATH_LOG
Message-Id: <8j92i0$cea$1@nnrp1.deja.com>
Daniel,
Thanks for running with this bug report. As I mentioned in a previous
post (sorry if you received multiples, had some confusion on my end:),
I encountered the same problem with HP-UX 10.20. And, while not
confirmed, it would appear to be a problem on HP-UX 11.0 as well as
Solaris since _PATH_LOG is not defined anywhere and /dev/log is not a
unix-domain socket on these platforms.
The same steps that you detailed also fixed the problem on hp-ux 10.20,
though an internet socket connection will be used even if trying to log
locally. Don't know how hard it would be to make the 'unix' option
work appropriately across all unix variants...
One minor note: changing &_PATH_LOG to _PATH_LOG() in Syslog::connect()
should not be required; using the former syntax appears to work as
expected.
Let me know if I can be of any assistance in gathering more details or
testing any changes.
- Kevin
In article <3957E5BA.C5B9A5DF@itg.uiuc.edu>,
d-weber@uiuc.edu wrote:
> OK, I believe I have a solution, but I am totally unfamiliar with the
process
> for submitting problems & solutions like this to the perl developers.
I'd be
> glad to get some advice from those "in the know" (Tom? Jonathan?) how
to
> approach it.
>
> The problem (for review):
> Attempting to use the Net::Daemon package, I discovered that
Syslog.pm was
> reporting errors when the _PATH_LOG function was being called. This
happend on
> both IRIX 6.5.8 and AIX 4.3.3, and was caused by the lack of a
_PATH_LOG
> variable under both OS's. This is for perl-5.6.0.
>
> The overall solution:
> Both Syslog.pm and Syslog.xs have problems, at least as far as I can
tell:
> Syslog.pm in how it is using calls to the _PATH_LOG subroutine, and
what it is
> doing with those responses; Syslog.xs in how it is handling the lack
of
> _PATH_LOG information.
>
> At first it appeared that all that was missing from Syslog.xs was the
correct
> #include file for the definition of _PATH_LOG. This is not the case,
especially
> for AIX where there is no _PATH_LOG macro in any .h file! The fix
should be made
> wholly without the inclusion of the _PATH_LOG macro.
>
> The cause of the problem is that the _PATH_LOG() function croaks if
there is no
> defined macro _PATH_LOG. This should not happen, as Syslog.pm is
expecting a
> returned value from _PATH_LOG( ). Removing the croak allows the
_PATH_LOG
> function to return a NULL value which can then be captured by the
Syslog.pm
> module.
>
> At one point, Syslog.pm uses the _PATH_LOG function in a "defined"
context, and
> using the "&" form of the function call:
> if ( defined &_PATH_LOG ) {
> $sock_type = 1;
> } else {
> return undef;
> }
> Given that the Syslog.xs file has defined this function, the result
of the
> preceeding conditional is always true! This is not what is wanted.
Instead these
> statements should read:
> if ( defined _PATH_LOG( ) ) {
> $sock_type = 1;
> } else {
> return undef;
> }
> as pointed out in a couple of posts here. Fixing this causes
$sock_type to be
> unassigned, and then later, the correct portion of code in
Syslog::connect to be
> executed.
>
> The other use of &_PATH_LOG should also probably change to _PATH_LOG(
), though
> there is no harm in leaving it as far as I can see.
>
> What's a bigger question to me now is: Should all of those functions
in
> Syslog.xs croak? Or should they return NULL values if the macros
aren't defined?
>
> Below are the diffs between my Syslog.{xs,pm} original files and the
working new
> versions. I hope these help others struggling with the same problems.
>
> -daniel
>
> *** Syslog.xs.orig Mon Jun 26 15:43:24 2000
> --- Syslog.xs Mon Jun 26 15:43:32 2000
> ***************
> *** 550,556 ****
> #ifdef _PATH_LOG
> RETVAL = _PATH_LOG;
> #else
> - croak("Your vendor has not defined the Sys::Syslog macro
_PATH_LOG");
> RETVAL = NULL;
> #endif
> OUTPUT:
> --- 550,555 ----
>
> *** Syslog.pm.orig Mon Jun 26 15:53:03 2000
> --- Syslog.pm Mon Jun 26 15:53:29 2000
> ***************
> *** 159,165 ****
> local($setsock) = shift;
> &disconnect if $connected;
> if (lc($setsock) eq 'unix') {
> ! if (defined &_PATH_LOG) {
> $sock_type = 1;
> } else {
> return undef;
> --- 159,165 ----
> local($setsock) = shift;
> &disconnect if $connected;
> if (lc($setsock) eq 'unix') {
> ! if (defined _PATH_LOG() ) {
> $sock_type = 1;
> } else {
> return undef;
> ***************
> *** 274,280 ****
> socket(SYSLOG,AF_INET,SOCK_DGRAM,$udp) || croak
"socket: $!"
> ;
> connect(SYSLOG,$that) || croak
"connect: $!
> ";
> } else {
> ! my $syslog = &_PATH_LOG || croak
"_PATH_LOG n
> ot found in syslog.ph";
> my $that = sockaddr_un($syslog) || croak
"Can't locat
> e $syslog";
> socket(SYSLOG,AF_UNIX,SOCK_STREAM,0) || croak
"socket: $!"
> ;
> if (!connect(SYSLOG,$that)) {
> --- 274,280 ----
> socket(SYSLOG,AF_INET,SOCK_DGRAM,$udp) || croak
"socket: $!"
> ;
> connect(SYSLOG,$that) || croak
"connect: $!
> ";
> } else {
> ! my $syslog = _PATH_LOG() || croak
"_PATH_LOG
> not found in syslog.ph";
> my $that = sockaddr_un($syslog) || croak
"Can't locat
> e $syslog";
> socket(SYSLOG,AF_UNIX,SOCK_STREAM,0) || croak
"socket: $!"
> ;
> if (!connect(SYSLOG,$that)) {
>
> --
>
> ]:o_ | Daniel E. Weber (d-weber@uiuc.edu) - ITG Information
Technologies | _o:{
> |O =| 4311 Beckman Institute, 405 N Mathews, Urbana, IL, 61801 MC-
251 |= O|
> |_o=| 217-244-3191 (off) * 217-244-6219 (fax) * 217-244-3074
(lab) |=o_|
> \ |
*moo* | /
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 27 Jun 2000 03:20:22 GMT
From: "Patrick Doyle" <patrickdoyle@home.com>
Subject: Timers in ActivePerl
Message-Id: <W3V55.48837$Do1.552192@news1.rdc1.bc.home.com>
After writhing a program that connected a bot to a MUD, Making it
Reply to people talking, Peoples Whispers and my Online Commands, I am
Stuck...
[this is a Program Written In ActiveState's, ActivePerl]
How could I do a timer, Without Using Sleep? [I want something changed every
60 seconds]
I have written one with Sleep, But it Pauses the Program, and nothing Else
works while the timer times =P
So the way this timer is supost to work is Updater a Var every 60seconds
and add 1 to the Var $uptime, Then Send a command to the Mud Server....
So it basicaly Logs how many minutes it is online...
Could someone Offer any help?
-Thanks, Patrick
------------------------------
Date: Tue, 27 Jun 2000 02:47:47 GMT
From: Francis Litterio <franl-removethis@world.omitthis.std.com>
Subject: Where is IO::Handle::error() defined?
Message-Id: <m3u2efj0vg.fsf@franl.andover.net>
From the output of "perldoc Handle":
$fh->error
Returns a true value if the given handle has
experienced any errors since it was opened or since
the last call to clearerr.
And sure enough, this script behaves as expected:
#!/usr/bin/perl -w
use strict;
use IO::Handle;
print "no error on STDIN\n" unless STDIN->error();
But I can't find the implementation of method error(). If I comment out
the "use IO::Handle;", Perl complains:
Can't locate object method "error" via package "IO::Handle" at
./foo line 6.
So clearly, loading package IO::Handle causes that method to be defined,
but where?
--
Francis Litterio
franl-removethis@world.std.omit-this.com
PGP public keys available on keyservers.
------------------------------
Date: Tue, 27 Jun 2000 11:52:38 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Who's the man? You can be(ginner)
Message-Id: <kdU55.18$h26.5064@vic.nntp.telstra.net>
<8inches_manmeat@my-deja.com> wrote in message
news:8j8keh$269$1@nnrp1.deja.com...
> Hi, I need a little help with perl. If you have any insight for me
that
> would be cool. Thanks.
>
> I have a text file that has a bunch of email addresses
>
> foo.bar@domain.com
> foo.bar@domain.com
> foo.bar@domain.com
> foo.bar@domain.com ...
>
> etc.
>
> For each 'foo.bar@domain.net' I want 'Foo Bar'. In other words, for
> 'mike.smith@hotmail.com' I want 'Mike Smith'
>
> It's part of a larger script that will be run on a Windows machine, so
I
> can't make system calls to unix commands. (right?)
>
#!/usr/bin/perl -w
use strict;
while (<DATA>){
if (my($first,$last) = /(\w+)\.(\w+)\@.*/){
my $full = ucfirst $first . ' ' . ucfirst $last;
print "$full\n";
}
}
__END__
foo.bar@domain.com
foo.bar@domain.com
foo.bar@domain.com
foo.bar@domain.com
Wyzelli
------------------------------
Date: Tue, 27 Jun 2000 01:13:16 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: Write to file problem
Message-Id: <8j8v30$a1r$1@nnrp1.deja.com>
In article <3957E3B6.ED21C9B1@home.com>,
Tim <aranick@home.com> wrote:
> Hello,
>
> I'm having a problem writing to a file. The problem is that I can't
get
> it to print each item of info, on a new line. Some lines it works,
other
> times it drops down two lines instead of one. Any suggestions would be
> much aprecaited.
>
> Write code:
>
> open (QF, ">/qfile$qfile.txt");
> print QF "$Theinfo[0]\n";
> print QF "$Theinfo[1]\n";
> print QF "$Theinfo[2]\n";
> print QF "$Theinfo[3]\n";
> print QF "$Theinfo[4]";
> print QF "$Theinfo[5]";
> print QF "$Theinfo[6]";
> print QF "$Theinfo[7]";
> close (QF);
>
> *All the info in the scalars is fine and can be worked with.
> I've tried lots of combinations of the \n's (all, none, half, ..) But
> none work. I think it might write differently if it's a single number
> then a two or 3 diget number. (Thats what the info will be, numbers)
>
It will happen if $Theinfo[$i] contains a newline
at the end itself - so you get two newlines.
BTW, how do you get these $Theinfo[$i] items ?
If you got them from <HANDLE> there are chances
you forgot to chomp() the lines.
Good luck.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3488
**************************************