[12600] in Perl-Users-Digest
Perl-Users Digest, Issue: 11 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 2 20:57:31 1999
Date: Fri, 2 Jul 1999 17:51:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 2 Jul 1999 Volume: 9 Number: 11
Today's topics:
Re: INC not working properly (Tad McClellan)
Including variables <warnock@home.com>
Re: Including variables (Greg Bacon)
Re: Including variables <cantrela@agcs.com>
Re: Including variables <warnock@home.com>
Re: Including variables <warnock@home.com>
IO::Select and IO::Socket <streaking_pyro@my-deja.com>
Re: IO::Select and IO::Socket <tchrist@mox.perl.com>
Re: Is perl 8-bit safe? (Bart Lateur)
Re: Is perl 8-bit safe? (Philip 'Yes, that's my address' Newton)
Re: linking directories? <chris@mobiles.co.uk>
localtime <leonid76@erols.com>
Re: localtime (M.J.T. Guy)
Re: Looking for old version of Perl (Tad McClellan)
Re: Looking for old version of Perl (Bart Lateur)
Re: Looking for old version of Perl (Bart Lateur)
Re: Looking for real-time chat <td90537@hotmail.com>
Re: magical string increment subtlety (Charles DeRykus)
Re: magical string increment subtlety <uri@sysarch.com>
Re: magical string increment subtlety <tye@metronet.com>
Re: magical string increment subtlety <monty@primenet.com>
Re: magical string increment subtlety (R.L. Horn)
Re: make my day fix an array :-) (Abigail)
Re: make my day fix an array :-) <wavey@pilot.infi.net>
Re: make my day fix an array :-) (Bart Lateur)
Re: make my day fix an array :-) <uri@sysarch.com>
Re: make my day fix an array :-) (Lee)
Re: make my day fix an array :-) (Abigail)
Re: make my day fix an array :-) <elaine@cts.wustl.edu>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 1 Jul 1999 15:27:54 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: INC not working properly
Message-Id: <qffgl7.114.ln@magna.metronet.com>
Dorr Lewright (dlewright@nuworld.com) wrote:
: I am new to Perl, and when I attempt to use the "use" command, I get the
: message "Can't locate strict.pm in @INC (@INC contains: .) at
: D:\NCH\PERL\myscript.plx line 23." I am working on Windows NT 4.0 (I
: came from a Solaris shop to an NT shop).
Have you looked up your error message in perldiag.pod?
Here it is for the documentation challenged:
----------------------
=item Can't locate %s in @INC
(F) You said to do (or require, or use) a file that couldn't be found
in any of the libraries mentioned in @INC. Perhaps you need to set the
PERL5LIB or PERL5OPT environment variable to say where the extra library
is, or maybe the script needs to add the library name to @INC. Or maybe
you just misspelled the name of the file. See L<perlfunc/require>.
----------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 02 Jul 1999 14:10:44 GMT
From: "Archie Warnock" <warnock@home.com>
Subject: Including variables
Message-Id: <EL3f3.12883$UK2.9121@news.rdc1.md.home.com>
There's got to be a simple way to do this.
I have a set of variables that I need to include in a bunch of CGI scripts -
they're all set to initial values (paths, filenames, the like) used by each
of the scripts, and if I have to change any of them, I'd like to do it in
one place (for example, one of the variables is the location of a style
sheet to include in each generated HTML page). I'm trying to find an
equivalent to a #include in C - just import the names and values and then
compile the script.
It seemed like
use Constants;
ought to work, but I'm having trouble with getting it to work the way I want
if I include
use strict;
at the same time. I can manage to compile the whole thing by adding
use vars '$CGILink';
but the values I assigned in the Constants.pm file get lost then. I'm sure
I'm overlooking something obvious, but I can't figure out how to do what I
want without either skipping the "use strict" or writing all the constants
into an initialization file that I explicitly read in. There's got to be A
Better Way To Do It. Any suggestions?
------------------------------
Date: 2 Jul 1999 14:47:50 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Including variables
Message-Id: <7lijem$9f6$5@info2.uah.edu>
In article <EL3f3.12883$UK2.9121@news.rdc1.md.home.com>,
"Archie Warnock" <warnock@home.com> writes:
: There's got to be a simple way to do this. [How do I import variables
: from a module?]
There is.
package Constants;
sub import {
no strict 'refs';
my $class = shift;
my $pkg = caller;
*{ $pkg . '::' . 'FOO' } = sub () { 'BAR' };
*{ $pkg . '::' . 'QUUX' } = sub () { ( 'a', 'b', 'c', ) };
my $scalar = 42;
*{ $pkg . '::' . 'scalar' } = \$scalar;
my @array = qw( foo bar baz );
*{ $pkg . '::' . 'array' } = \@array;
my %hash = ( a => 1, b => 2 );
*{ $pkg . '::' . 'hash' } = \%hash;
}
1;
You might use this like
#! /usr/bin/perl -w
use strict;
use Constants;
print "FOO = ", FOO, "\n";
print "QUUX = (", join(",", QUUX), ")\n";
print "\$scalar = $scalar\n";
$" = "]["; # mjd++
print "\@array = [@array]\n";
print "%hash:\n";
for (keys %hash) {
print " $_ => $hash{$_}\n";
}
Alternatively, you could use the Exporter (read man Exporter for all
the gory details), but it's really not necessary. See mjd's Hardware
Store talk.
Enjoy,
Greg
--
Bigamy is having one wife too many. Monogamy is the same.
-- Oscar Wilde
------------------------------
Date: Fri, 02 Jul 1999 08:17:33 -0700
From: Andy Cantrell <cantrela@agcs.com>
To: Archie Warnock <warnock@home.com>
Subject: Re: Including variables
Message-Id: <377CD80D.32C27B3D@agcs.com>
Archie Warnock wrote:
>
> There's got to be a simple way to do this.
>
> I have a set of variables that I need to include in a bunch of
> CGI scripts -
> they're all set to initial values (paths, filenames, the like) used
> by each of the scripts, and if I have to change any of them, I'd
> like to do it in one place
The following is something I use from time to time:
require $path_to_var_file ;
The var_file has the perl code you'd use to assign the
variables you want.
--
Andy Cantrell - cantrela@agcs.com
AG Communication Systems
Office (AZ) (623) 582-7495 (Voice mail)
Office (WI) (414) 249-0215
Modem (WI) (414) 249-0239
------------------------------
Date: Fri, 02 Jul 1999 15:41:03 GMT
From: "Archie Warnock" <warnock@home.com>
Subject: Re: Including variables
Message-Id: <j45f3.12896$UK2.9092@news.rdc1.md.home.com>
Andy Cantrell wrote in message <377CD80D.32C27B3D@agcs.com>...
>Archie Warnock wrote:
>>
>> There's got to be a simple way to do this.
>>
>> I have a set of variables that I need to include in a bunch of
>> CGI scripts -
>The following is something I use from time to time:
>
>require $path_to_var_file ;
>
>The var_file has the perl code you'd use to assign the
>variables you want.
It doesn't quite do what I want, and maybe I didn't include enough detail in
my original message. I can use require to pull in the file, but when the
script is run, it wants the package name to be explicitly named when I try
to use one of the variables. So
use strict;
require 'Constants.pl';
print $foo;
generates an error message (where $foo is initialized in Constants.pl), but
use strict;
require 'Constants.pl';
print $main::foo;
works fine. Small point, but I'd like it to find a way to make it function
like
use strict;
my $foo="Hello, world!\n";
print $foo;
Maybe I can't do it, but I think I'm missing something. I wasn't really
intending my little chunk of included code to be a full-blown package. That
seems like overkill for something so straightforward.
Thanks for the suggestions. I appreciate them all.
------------------------------
Date: Fri, 02 Jul 1999 15:43:34 GMT
From: "Archie Warnock" <warnock@home.com>
Subject: Re: Including variables
Message-Id: <G65f3.12898$UK2.9129@news.rdc1.md.home.com>
Greg Bacon wrote in message <7lijem$9f6$5@info2.uah.edu>...
>In article <EL3f3.12883$UK2.9121@news.rdc1.md.home.com>,
> "Archie Warnock" <warnock@home.com> writes:
>: There's got to be a simple way to do this. [How do I import variables
>: from a module?]
>
[sneaky stuff deleted...]
I like it - it's sneaky and underhanded, just like perl should be ;-) I'll
give it a try. Much appreciated.
------------------------------
Date: Fri, 02 Jul 1999 06:33:24 GMT
From: R.Joseph <streaking_pyro@my-deja.com>
Subject: IO::Select and IO::Socket
Message-Id: <7lhmfk$3iv$1@nnrp1.deja.com>
I have read all the pages in perlfunc about these two modules and I
still do not understand exactly how I would go about creating, say a
socket-based server that can handle 10 connections...if anyone knows of
any good web pages out there that explain the use of these modules, or
if anyone maybe has a little time to explain this to me that would be
great! Thanks alot in advance.
--
R.Joseph
http://www.24-7design.com
http://bowdown.to
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 2 Jul 1999 04:22:22 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: IO::Select and IO::Socket
Message-Id: <377c92de@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
R.Joseph <streaking_pyro@my-deja.com> writes:
:I have read all the pages in perlfunc about these two modules and I
:still do not understand exactly how I would go about creating, say a
:socket-based server that can handle 10 connections...if anyone knows of
:any good web pages out there that explain the use of these modules, or
:if anyone maybe has a little time to explain this to me that would be
:great! Thanks alot in advance.
That's an RTFM, sir.
% man perlipc
....
Internet TCP Clients and Servers
--tom
--
"... an initial underscore already conveys strong feelings of
magicalness to a C programmer."
--Larry Wall in <1992Nov9.195250.23584@netlabs.com>
------------------------------
Date: Fri, 02 Jul 1999 06:23:10 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Is perl 8-bit safe?
Message-Id: <377c58e2.273526@news.skynet.be>
Harriet Severinio wrote:
>I am using perl scripts quite heavily, and we need to add support for
>European languges to our product. This means 8-bit character encoding.
>
>Has anyone tested perl 4 and perl 5 for handeling 8-bit characters?
Yes. Yes. Yes. I use it all the time. Be aware that different platforms,
like Mac and Windows, use a different character encoding scheme. For
example, an "é" has a different character ("Ascii") code on both.
But, to ease your mind, you can even use a Perl script to convert
between the two. :-)
Note that Windows uses it' own extension on Iso-Latin-1; which is pretty
standard for Unix (some extra characters for codes which are "undefined"
in Iso-Latin-1), but DOS uses a different character encoding scheme
altogether. A Mac is different still. BTW the official name you may
encounter is "code page".
Oh, the lower range is Ascii compatible for all platforms: all the same,
except for the newlines.
And I'm not talking about Unicode, which you may need for Chinese etc.,
but not for European language. Support for Unicode is pretty shakey,
still. Windows is "Unicode ready", but not really.
HTH,
Bart.
------------------------------
Date: Thu, 01 Jul 1999 19:02:38 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: Is perl 8-bit safe?
Message-Id: <377bb9d1.95253651@news.nikoma.de>
On Thu, 01 Jul 1999 14:04:13 GMT, Harriet Severinio <hseverin@bbn.com>
wrote:
>Has anyone tested perl 4 and perl 5 for handeling 8-bit characters?
Don't know about perl 4 but perl 5 is completely 8-bit clean AFAIK.
You can even have null bytes in the middle of your scalars! (Try doing
that in C and still getting by with strlen, strcpy and friends.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.net>
------------------------------
Date: Fri, 2 Jul 1999 18:04:51 +0100
From: Chris Conwell <chris@mobiles.co.uk>
Subject: Re: linking directories?
Message-Id: <HLkjBAAzEPf3EAdK@mobiles.co.uk>
>> I know how to use "symlink" to link two filenames together but how do I
>> replicate the "ln -s" command in Perl so that I can link two directories
>> together?
>
>directories are files.
>
>symlink OLD_DIRNAME, NEW_DIRNAME
<repeatedly hitting myself over head with Camel book>
Of course! Why didn't I think of that. :-)
--
Chris (Mobiles, Watford) http://www.mobiles.co.uk
+--------------------------------------------------------------------------+
|Very special deals for The Orange List: http://www.mobiles.co.uk/list.htm |
| Boxed & Ready: Phone, Connection & 15 months line rental just 79.99 ukp |
| Contact: 01923-804444 Mobile: 07970-804444 & 24hr Fax: 01923-805555 |
+--------------------------------------------------------------------------+
Retail Shop & Nokia Service Centre: 346-348 St Albans Rd, Watford, WD2 5PQ
Nokia Service Centre Tel 01923-801111 Nokia Service Centre Fax 01923-802222
------------------------------
Date: Fri, 2 Jul 1999 16:44:12 -0400
From: "Leonid Goltser" <leonid76@erols.com>
Subject: localtime
Message-Id: <7lj86n$lj7$1@autumn.news.rcn.net>
I want my script to print current time. I tried to use 'localtime', but it
returns time only in GMT. I want to print time for different time zones.
Is there any method (function) to do that?
------------------------------
Date: 3 Jul 1999 00:02:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: localtime
Message-Id: <7ljjur$e18$1@pegasus.csx.cam.ac.uk>
In article <7lj86n$lj7$1@autumn.news.rcn.net>,
Leonid Goltser <leonid76@erols.com> wrote:
>I want my script to print current time. I tried to use 'localtime', but it
>returns time only in GMT. I want to print time for different time zones.
If you mean "I want to print time in the local timezone", then that is
what localtime() is meant to do. If it doesn't, you've got a
misconfigured platform. That isn't a Perl problem - you'd get
the same results from C.
If you mean "how do I get localtime to give me the time in some
non-local timezone", then that is platform-dependent. Here's how you
can do it on Solaris 2.6 - adjustment for other platforms is an
exercise for the reader.
perl -wle'for(</usr/share/lib/zoneinfo/*>){$ENV{TZ}=$_;print"$_: ",scalar localtime}'
/usr/share/lib/zoneinfo/africa: Fri Jul 2 23:47:14 1999
/usr/share/lib/zoneinfo/asia: Fri Jul 2 23:47:14 1999
/usr/share/lib/zoneinfo/australasia: Fri Jul 2 23:47:14 1999
/usr/share/lib/zoneinfo/Australia: Fri Jul 2 23:47:14 1999
/usr/share/lib/zoneinfo/backward: Fri Jul 2 23:47:14 1999
/usr/share/lib/zoneinfo/Brazil: Fri Jul 2 23:47:14 1999
/usr/share/lib/zoneinfo/Canada: Fri Jul 2 23:47:14 1999
/usr/share/lib/zoneinfo/CET: Sat Jul 3 01:47:14 1999
/usr/share/lib/zoneinfo/Chile: Sat Jul 3 01:47:14 1999
/usr/share/lib/zoneinfo/CST6CDT: Fri Jul 2 18:47:14 1999
/usr/share/lib/zoneinfo/Cuba: Fri Jul 2 19:47:14 1999
/usr/share/lib/zoneinfo/EET: Sat Jul 3 02:47:14 1999
/usr/share/lib/zoneinfo/Egypt: Sat Jul 3 02:47:14 1999
/usr/share/lib/zoneinfo/Eire: Sat Jul 3 00:47:14 1999
/usr/share/lib/zoneinfo/EST: Fri Jul 2 18:47:14 1999
.....
Mike Guy
------------------------------
Date: Thu, 1 Jul 1999 17:40:24 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Looking for old version of Perl
Message-Id: <88ngl7.t44.ln@magna.metronet.com>
Robert Greenwood (robert.greenwood@citicorp.com) wrote:
: Does anyone know how I can get hold of an old copy of the
: Perl source distribution? I'm looking for 4.0.1.8.
Why do you want it?
It has very serious security problems too.
see www.cert.org
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 02 Jul 1999 06:26:59 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Looking for old version of Perl
Message-Id: <377d5b64.915764@news.skynet.be>
Robert Greenwood wrote:
>Does anyone know how I can get hold of an old copy of the
>Perl source distribution? I'm looking for 4.0.1.8.
Maybe you can look around for older Perl CD-ROM's on car boot sales. If
the CD is a few years old, it will contain older versions.
Bart.
------------------------------
Date: Fri, 02 Jul 1999 11:00:17 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Looking for old version of Perl
Message-Id: <377d9b9b.349542@news.skynet.be>
Tad McClellan wrote:
>: Does anyone know how I can get hold of an old copy of the
>: Perl source distribution? I'm looking for 4.0.1.8.
> Why do you want it?
Some people collect old "computers". Maybe this guy is into old
software.
Bart.
------------------------------
Date: Fri, 02 Jul 1999 08:29:57 +0200
From: distler <td90537@hotmail.com>
Subject: Re: Looking for real-time chat
Message-Id: <377C5C64.203FE92D@hotmail.com>
Try this at least it is for free.
Thomas
Dennis Voss wrote:
> Hi,
>
> I'm looking for a real time chat script for my intranet.
> I have located several ones that modify a static page and
> the browser reloads it every 5 secs. - But I'm looking for
> a real-time script.
> Please tell me where I could find one.
> Thanks,
>
> Dennis
------------------------------
Date: Fri, 2 Jul 1999 02:29:58 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: magical string increment subtlety
Message-Id: <FE81Ly.15M@news.boeing.com>
In article <377BDAF0.4E32AD8C@cs.cmu.edu>,
Christopher Hogan <chogan@cs.cmu.edu> wrote:
>I've tried the following on both 5.004_04 and 5.005_02, with the same
>strange result:
>
>> perl -e '$o="k1pam0000" ; $o++ ; print "$o\n" ;'
>1
>
>> perl -e '$o="kpam0000" ; $o++ ; print "$o\n" ;' # note no '1' in string
>kpam0001
>
>Is this a bug or a feature? What's a work-around to get the latter
>behavior in the former case (my filenames just come with numbers in
>them)?
>
Feature. One quick possibility for a workaround:
substr($o,-1,1)++;
although final digit incrementing may not be what you want,
e.g.
... k1pam0019 k1pam00110 ... etc.
hth,
--
Charles DeRykus
------------------------------
Date: 01 Jul 1999 22:46:38 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: magical string increment subtlety
Message-Id: <x7r9mr3h0x.fsf@home.sysarch.com>
>>>>> "DS" == Dan Sugalski <sugalskd@netserve.ous.edu> writes:
DS> It's a feature. Magic increment only works with strings that match
DS> /^[A-Za-z]+\d*$/, which is why the second works but the first doesn't.
DS> (Since the first doesn't match, perl does a numeric conversion then
DS> increments the result. -w will warn you about this one)
that regex looked wrong to me so i tested this:
perl -le '$a="009";$a++;print $a'
010
and checked perlop:
If, however, the variable has been used in only string contexts since it
was set, and has a value that is not null and matches the pattern
/^[a-zA-Z]*[0-9]*$/
as i thought, a string of digits works magically as well. in your regex
the + should be a *.
uri
NOTE: 3 in a row without sarcasm. i must be very mellow today.
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 2 Jul 1999 12:03:57 -0500
From: Tye McQueen <tye@metronet.com>
Subject: Re: magical string increment subtlety
Message-Id: <7lirdt$pql@fumnix.metronet.com>
Christopher Hogan <chogan@cs.cmu.edu> writes:
)
) > perl -e '$o="k1pam0000" ; $o++ ; print "$o\n" ;'
) 1
)
) > perl -e '$o="kpam0000" ; $o++ ; print "$o\n" ;' # note no '1' in string
) kpam0001
)
) Is this a bug or a feature? What's a work-around to get the latter
) behavior in the former case (my filenames just come with numbers in
) them)?
Others have responded why this doesn't work but none [that I
can see so far] have given a solution:
> perl -e '$o="k1pam0000"; $o =~ s/(\d+)$/my $x=$1;++$x/e; print "$o\n"'
k1pam0001
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: 2 Jul 1999 19:35:03 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: magical string increment subtlety
Message-Id: <7lj497$ch2$1@nnrp03.primenet.com>
Dan Sugalski <sugalskd@netserve.ous.edu> wrote:
> Christopher Hogan <chogan@cs.cmu.edu> wrote:
> > I've tried the following on both 5.004_04 and 5.005_02, with the same
> > strange result:
> >
> > perl -e '$o="k1pam0000" ; $o++ ; print "$o\n" ;'
> > 1
> >
> > perl -e '$o="kpam0000" ; $o++ ; print "$o\n" ;' # note no '1' in string
> > kpam0001
> >
> > Is this a bug or a feature? What's a work-around to get the latter
> > behavior in the former case (my filenames just come with numbers in
> > them)?
>
> It's a feature. Magic increment only works with strings that match
> /^[A-Za-z]+\d*$/ [sic], which is why the second works but the first
> doesn't. (Since the first doesn't match, perl does a numeric conversion
> then increments the result. -w will warn you about this one)
>
> The only real option you've got is to duplicate magic increment's
> functionality yourself with a bit more leniency.
Or just apply the magic with a bit more precision, like this:
$ perl -wle '$_ = "kpam0000"; s/(\d+)$/my $t = $1; ++$t/e; print;'
kpam0001
$ perl -wle '$_ = "k1pam0000"; s/(\d+)$/my $t = $1; ++$t/e; print;'
k1pam0001
$
The substring matched by (\d+)$ must be saved to a temp variable
because the built-in variable $1 is read-only and cannot be
autoincremented.
Swap the variable assigment for a couple of function calls by
doing what Dan suggested:
$ perl -wle '$_ = "k1pam0000";
> s/(\d+)$/sprintf "%0*d", length $1, $1 + 1/e; print;'
k1pam0001
$
The more precise application of the magical form of the autoincrement
operator can save you from "gotchas" such as this one:
$ perl -wle '$_ = "PREFIX9999"; print ++$_;'
PREFIY0000
$ perl -wle '$_ = "PREFIX9999"; s/(\d+)$/my $t = $1; ++$t/e; print;'
PREFIX10000
$
Here, "PREFIX" is alphabetic and not part of the value (the integer
suffix) that we want to increment.
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: 2 Jul 1999 20:12:50 GMT
From: rlhorn@mailroom.com (R.L. Horn)
Subject: Re: magical string increment subtlety
Message-Id: <slrn7nq7db.sr.rlhorn@hani.compact.bogus>
On Fri, 2 Jul 1999 02:29:58 GMT, Charles DeRykus <ced@bcstec.ca.boeing.com>
wrote:
>One quick possibility for a workaround:
>
>substr($o,-1,1)++;
>
>although final digit incrementing may not be what you want,
>e.g.
>
> ... k1pam0019 k1pam00110 ... etc.
Or, just grab the bit of the string that will work with the magic increment:
$foo = "k1pam0019";
# grab the final letters + digits
if ($foo =~ /([a-zA-Z]+\d+)$/) {
$tmp = $1;
$bar = $` . (++$tmp);
undef $tmp;
print "$foo --> $bar\n";
} else {
print "Something's not right with $foo!\n";
}
It's ugly as sin, but it does work.
------------------------------
Date: 2 Jul 1999 01:28:05 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: make my day fix an array :-)
Message-Id: <slrn7nomv1.31h.abigail@alexandra.delanet.com>
Uri Guttman (uri@sysarch.com) wrote on MMCXXXI September MCMXCIII in
<URL:news:x7zp1f3icx.fsf@home.sysarch.com>:
::
::
:: (i met abigail at yapc and that totally changed my attitude towards her.)
But, but, but, I wasn't myself those days! Pittsburgh air made a mess
with my mind. Yeah, that's it. I blame the air! ;)
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=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 02 Jul 1999 02:48:12 -0400
From: "Mr. Dave" <wavey@pilot.infi.net>
Subject: Re: make my day fix an array :-)
Message-Id: <377C60AC.B0EC6687@pilot.infi.net>
actually it might go:
=abigail= Jun 25 10:10:10, dane
=jimbob= Jun 25 10:10:40, jamesgr
=abigail= Jun 25 10:11:09, dane
the diff. being the name on the end. I work in tech support and one script
varifies the customer we are speaking with and leaves a log (above snippet)
Part of my script should remove entries that END in the same name within 1 min of
each other. So abigail was varified at 10:10:10 by dane and again at 10:11:09
by dane, prob. the second time she was varified was not a seperate call but the
same.
So remove the second entry and continue on .... (scrip will count how many calls
each
tech has taken). Jimbob was varified around the same time but by another tech...
I thank all that replyed including Uri :-)
I solved my problem with a sort (&tech, @log) where sub tech was
{ reverse($a) cmp reverse($b); } that put all the techs together where
my sub eliminate could remove calls w/in a minute.
then went back to chronological order with sort (&time, @newlog)
where &time was {a <=> b}
I did not realize you could sort with a subroutine before my posting.
I'm new....
again thank you all :-)
Abigail wrote:
Poor specification. What is supposed to happen with:
> =abigail= Jun 25 10:10:10, abigail
> =abigail= Jun 25 10:10:40, abigail
> =abigail= Jun 25 10:11:20, abigail
>
> How much entries does the result have:
> 0: 10:10:10 is within a minute of 10:10:40, which is within a
> minute of 10:11:20, hence all entries disappear.
> 1: 10:10:40 is within a minute of 10:10:10, and 10:11:20 is within
> a minute of 10:10:40, leaving just 10:10:10.
> 2: 10:10:40 is withing a minute of 10:10:10. 10:11:20 is more than
> a minute from 10:10:10.
>
> I'd say the first option is the most logical one, because "within" is
> a symmetric relationship.
>
> Abigail
> --
> srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
> //=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
>
> -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
> http://www.newsfeeds.com The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 02 Jul 1999 08:53:57 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: make my day fix an array :-)
Message-Id: <377e7d02.7260261@news.skynet.be>
Uri Guttman wrote:
>(i met abigail at yapc and that totally changed my attitude towards her.)
You mean she IS female? Does that make a difference? Or is it something
else?
Bart.
------------------------------
Date: 02 Jul 1999 09:59:29 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: make my day fix an array :-)
Message-Id: <x71zer2lvi.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> Uri Guttman wrote:
>> (i met abigail at yapc and that totally changed my attitude towards her.)
BL> You mean she IS female? Does that make a difference? Or is it something
BL> else?
that would be telling. i am just using 'her' as an easier to use
pronoun. i got tired of refering to her as it. :-)
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Fri, 02 Jul 1999 17:07:53 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: make my day fix an array :-)
Message-Id: <B3A2A26996687E942@0.0.0.0>
In article <377e7d02.7260261@news.skynet.be>,
bart.lateur@skynet.be (Bart Lateur) wrote:
>Uri Guttman wrote:
>
>>(i met abigail at yapc and that totally changed my attitude towards her.)
>
>You mean she IS female? Does that make a difference? Or is it something
>else?
She's *far* too good at impersonating my ex-wife to be an imposter.
Lee
------------------------------
Date: 2 Jul 1999 18:42:31 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: make my day fix an array :-)
Message-Id: <slrn7nqjim.31h.abigail@alexandra.delanet.com>
Lee (rlb@intrinsix.ca) wrote on MMCXXXI September MCMXCIII in
<URL:news:B3A2A26996687E942@0.0.0.0>:
^^
^^ She's *far* too good at impersonating my ex-wife to be an imposter.
Maybe I *am* your ex-wife.
Abigail
--
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 02 Jul 1999 18:59:09 -0500
From: Elaine -HappyFunBall- Ashton <elaine@cts.wustl.edu>
Subject: Re: make my day fix an array :-)
Message-Id: <377D524B.E6EE2E54@cts.wustl.edu>
Abigail wrote:
> ^^ She's *far* too good at impersonating my ex-wife to be an imposter.
>
> Maybe I *am* your ex-wife.
Wait! I thought you were *MY* ex-wife Abigail darling. :D
e.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 11
************************************