[16074] in Perl-Users-Digest
Perl-Users Digest, Issue: 3486 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 26 21:06:16 2000
Date: Mon, 26 Jun 2000 18:05:46 -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: <962067945-v9-i3486@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Jun 2000 Volume: 9 Number: 3486
Today's topics:
# of occurrances in a list <cghansen@micron.com>
Re: # of occurrances in a list <lauren_smith13@hotmail.com>
Re: ASCII progress meter (Daniel E. Macks)
Re: ASCII progress meter <ccbrink@earthlink.net>
Re: ASCII progress meter <ccbrink@earthlink.net>
Re: ASCII progress meter (Daniel E. Macks)
Re: ASCII progress meter <news@webneeds.com>
Re: ASCII progress meter (Abigail)
Re: ASCII progress meter <billy@arnis-bsl.com>
Re: Buscamos Programador para EEUU (David H. Adler)
Re: cgi handling of accents and special chars <rootbeer@redcat.com>
CGI Perl Programmer Needed for Conrtract <anon@anon.com>
Re: CGI Perl Programmer Needed for Conrtract (David H. Adler)
Re: CGI Perl Programmer Needed for Conrtract (Tad McClellan)
Re: Changing case in a file! (David H. Adler)
Re: Changing case in a file! (Jerome O'Neil)
Re: Changing case in a file! <rootbeer@redcat.com>
Re: dbi oracle - newbie question newsposter@cthulhu.demon.nl
Re: Golf (Was: Re: HELP ME PLEASE !!!!) <sumus@aut.dk>
Re: Golf (Was: Re: HELP ME PLEASE !!!!) <sumus@aut.dk>
IO::SELECT IS BROKE! jgore@home.com
Re: Local & anonymous arrays (Abigail)
Re: matching question (http related) <mbmj@erols.com>
Re: matching question (http related) (Tad McClellan)
Re: matching question (http related) <mbmj@erols.com>
Re: More error checking with Getopt thgibbs@my-deja.com
Re: Need Perl Programmer (David H. Adler)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 26 Jun 2000 16:48:56 -0600
From: "Colby Hansen" <cghansen@micron.com>
Subject: # of occurrances in a list
Message-Id: <8j8mkp$41n$1@admin-srv3.micron.com>
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!
------------------------------
Date: Mon, 26 Jun 2000 17:25:39 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: # of occurrances in a list
Message-Id: <8j8s9t$pnp$1@brokaw.wa.com>
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:
>
> 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!
Increment each key's value each time you encounter it:
@arr = (1, 1, 2, 2, 2, 3, 3, 3, 3);
++$hash{$_} for (@arr);
for (keys %hash) {
print "$_: $hash{$_}\n";
}
prints out:
1: 2
2: 3
3: 4
Lauren
------------------------------
Date: 26 Jun 2000 22:15:36 GMT
From: dmacks@mail.sas.upenn.edu (Daniel E. Macks)
Subject: Re: ASCII progress meter
Message-Id: <slrn8lflg7.i95.dmacks@mail2.sas.upenn.edu>
Paul Oliver <poliver@nospam.elrancho.com> said:
>Hey everyone,
> I'm trying to print an ASCII progress bar/meter on stdout to show, well,
>progress, of course. The progress bar will look like:
>
> [################################### ]
>
>and will fill up with hash symbols as it progresses.
Here's a way...
$size=10;
$|=1;
print "["," "x$size,"]","\b"x$size;
for(my $i=0;$i<$size;$i++) {
print "#";
sleep 1;
};
print "]\n"'
dan
--
Daniel Macks
dmacks@a.chem.upenn.edu
dmacks@netspace.org
http://www.netspace.org/~dmacks
------------------------------
Date: Mon, 26 Jun 2000 23:07:17 GMT
From: "Christian Brink" <ccbrink@earthlink.net>
Subject: Re: ASCII progress meter
Message-Id: <FmR55.6427$NP5.96643@newsread2.prod.itd.earthlink.net>
> > I'm trying to print an ASCII progress bar/meter on stdout to show,
> > well, progress, of course. The progress bar will look like:
> >
> > [################################### ]
> >
> > and will fill up with hash symbols as it progresses.
>
> Instead of finishing your print statements with \n (\n = newline =
> form feed + carriage return), finish them with \r (\r = carriage
> return only).
Actually this won't work with the ending square bracket. You can use then
CPAN module curses-1.4 the location is
http://www.perl.com/CPAN/authors/id/WPS/Curses-1.04.tar.gz
HTH
Christian
------------------------------
Date: Mon, 26 Jun 2000 23:07:46 GMT
From: "Christian Brink" <ccbrink@earthlink.net>
Subject: Re: ASCII progress meter
Message-Id: <6nR55.6429$NP5.96643@newsread2.prod.itd.earthlink.net>
<snip>
> $size=10;
> $|=1;
> print "["," "x$size,"]","\b"x$size;
Should be: print "["," "x$size,"]","\b"x($size + 1);
> for(my $i=0;$i<$size;$i++) {
> print "#";
> sleep 1;
> };
> print "]\n"'
You have a trailing single quote here that fails in compilation.
Christian Brink
------------------------------
Date: 26 Jun 2000 23:57:13 GMT
From: dmacks@mail.sas.upenn.edu (Daniel E. Macks)
Subject: Re: ASCII progress meter
Message-Id: <slrn8lfrep.2j3.dmacks@mail2.sas.upenn.edu>
Christian Brink <ccbrink@earthlink.net> said:
><snip>
>> $size=10;
>> $|=1;
>> print "["," "x$size,"]","\b"x$size;
>
>Should be: print "["," "x$size,"]","\b"x($size + 1);
>
>> for(my $i=0;$i<$size;$i++) {
>> print "#";
>> sleep 1;
>> };
>> print "]\n"'
>You have a trailing single quote here that fails in compilation.
Yeah...that's what I get for unrolling a command-line:/
dan
--
Daniel Macks
dmacks@a.chem.upenn.edu
dmacks@netspace.org
http://www.netspace.org/~dmacks
------------------------------
Date: Mon, 26 Jun 2000 17:59:26 -0600
From: "Dan Manion" <news@webneeds.com>
Subject: Re: ASCII progress meter
Message-Id: <fbS55.1836$3v3.47073@news.uswest.net>
You're only off in you're print line statement. Notice the "\r" at the
begging of the print line below.
Here's a quick example. Hope it helps!
use strict;
$| = 1;# autoflush
my $barsize = 60; # how many chars in your progress bar
my $barchar = '#'; # what character you want to use
my $runtime = 7; # time (in seconds) to run the test
{ ## START SNIPIT
print "Running test for $runtime seconds\n";
my $start_t = time;
my $last_dur = 0;
my $dur = 0;
while ((($start_t + $dur) <= ($start_t + $runtime)) ) {
if ($dur != $last_dur) {
$last_dur = $dur;
my $bar = $barchar x int($dur/$runtime * $barsize);
print "\r[$bar" . (" " x ($barsize - length($bar))) . ']';
}
$dur = time - $start_t;
}
print "\ndone\n\n";
} ## END SNIPIT.
"Paul Oliver" <poliver@nospam.elrancho.com> wrote in message
news:3957C8D2.7BE959AB@nospam.elrancho.com...
> Hey everyone,
> I'm trying to print an ASCII progress bar/meter on stdout to show, well,
> progress, of course. The progress bar will look like:
>
> [################################### ]
>
> and will fill up with hash symbols as it progresses. The problem is I
only
> know how to append text to STDOUT, not replace the last line, so I get:
>
> [################################### ]
> [################################### ]
> [#################################### ]
> [#################################### ]
> [##################################### ]
>
> I've tried the following:
> sub updateProgress {
> my ( $current, $total ) = @_;
> print " [" . "#" x int(($current/$total) *
> 50) . " " x (49 - int(($current/$total) * 50)) . "]\n";
> #previous lines are all on one line
> }
>
> So, how do you force Perl to write to the current line of STDOUT over and
> over again (no appending)?
>
> Thanks,
> Paul
>
>
> --
> /*\
> \ / ASCII RIBBON CAMPAIGN
> x AGAINST HTML MAIL
> / \
> == P A U L O L I V E R == poliver AT elrancho DOT com ==
------------------------------
Date: 26 Jun 2000 20:54:51 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: ASCII progress meter
Message-Id: <slrn8lfvsp.ka1.abigail@alexandra.delanet.com>
Paul Oliver (poliver@nospam.elrancho.com) wrote on MMCDXCI September
MCMXCIII in <URL:news:3957C8F8.C1FAA4E3@nospam.elrancho.com>:
..
.. So, how do you force Perl to write to the current line of STDOUT over and
.. over again (no appending)?
That's the wrong question. STDOUT is a stream, and you will always append.
You might, however, output some byte sequences that will be interpreted
by some terminal device. A popular module for doing this is the cursus
module. But that may, or may not, work on your platform. Not all devices
are 2-d addressable.
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
------------------------------
Date: Tue, 27 Jun 2000 00:54:59 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: ASCII progress meter
Message-Id: <8j8u0s$98h$1@nnrp1.deja.com>
In article <3957C8F8.C1FAA4E3@nospam.elrancho.com>,
Paul Oliver <poliver@nospam.elrancho.com> wrote:
> Hey everyone,
> I'm trying to print an ASCII progress bar/meter on stdout to
show, well,
> progress, of course. The progress bar will look like:
>
> [################################### ]
>
> and will fill up with hash symbols as it progresses. The problem is
I only
> know how to append text to STDOUT, not replace the last line, so I
get:
>
> [################################### ]
> [################################### ]
> [#################################### ]
> [#################################### ]
> [##################################### ]
>
> I've tried the following:
> sub updateProgress {
> my ( $current, $total ) = @_;
> print " [" . "#" x int(($current/$total) *
> 50) . " " x (49 - int(($current/$total) * 50)) . "]\n";
> #previous lines are all on one line
> }
>
> So, how do you force Perl to write to the current line of STDOUT over
and
> over again (no appending)?
>
1. Strictly speaking, it is impossible.
STDOUT is a too generic object (simply a stream of bytes),
it cannot by itself handle any 'fancy' things like
cursor movement etc (imagine STDOUT connected to a pipe/FIFO/
socket or a line printer).
2. Instead, a terminal can do it.
In general you should read 'perldoc perlfaq8' or
http://www.cpan.org/doc/manual/html/pod/perlfaq8.html
(FAQ "How do I do fancy stuff with the keyboard/screen/mouse?"
and related ones).
3. But for your task a quick, dirty and non-portable
solution is possible (it will work on _some_ terminals).
So try the following:
(1) replace "\n" with "\r"
(2) unbuffer STDOUT
#!/usr/bin/perl -w
use strict;
sub update_progress
{
my $done = int(50*$_[0]/$_[1]);
print ' [' . '#'x$done . ' 'x(50-$done) . "]\r";
}
$|++;
my $total = 20;
for (1..$total) { update_progress($_, $total); sleep 1 }
# that's all
AFAIK under Windows you should switch STDOUT to 'binary'
mode (but I'm not sure this will work on Windows at all).
For more details about unbuffering see
FAQ "How do I flush/unbuffer an output filehandle?
Why must I do this?" in 'perldoc perlfaq5'
or http://www.cpan.org/doc/manual/html/pod/perlfaq5.html.
Hope this helps.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 26 Jun 2000 23:36:37 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Buscamos Programador para EEUU
Message-Id: <slrn8lfq84.rmt.dha@panix2.panix.com>
On 19 Jun 2000 21:02:04 +0100, Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>On Thu, 15 Jun 2000 10:43:45 GMT Antonio wrote:
>> Buscamos Programador para EEUU Para más información:
>
>I can only suppose that it was because it was not quite the same as the
>usual job advert that it didnt cop the opprobrium that is attracted by
>the others.
Well, that, and yapc. :-)
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"If you want a real optimist, look up Ray Bradbury. Guy's nuts.
He actually likes people." - David Brin
------------------------------
Date: Mon, 26 Jun 2000 16:30:02 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: cgi handling of accents and special chars
Message-Id: <Pine.GSO.4.10.10006261626590.23149-100000@user2.teleport.com>
On Mon, 26 Jun 2000 nathanday@my-deja.com wrote:
> Wondering if there's a quick & easy way to convert cgi submissions
> containing special characters (accents, umlauts, etc) to HTML.
Do you want HTML::Entities, perhaps?
http://search.cpan.org/search?dist=libwww-perl
http://search.cpan.org/doc/GAAS/libwww-perl-5.22/lib/HTML/Entities.pm
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 26 Jun 2000 23:19:11 GMT
From: "Newz" <anon@anon.com>
Subject: CGI Perl Programmer Needed for Conrtract
Message-Id: <PxR55.38954$74.158980@typhoon.tampabay.rr.com>
Am I off topic? If so, where should I post this?
I'm looking for Perl programmers I can depend on when I get work for a UNIX
box.
Marl Atkins
SoftLink Systems
marl@softlinksys.com (reply does not work)
(407) 822-0048
------------------------------
Date: 26 Jun 2000 23:41:17 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: CGI Perl Programmer Needed for Conrtract
Message-Id: <slrn8lfqgt.rmt.dha@panix2.panix.com>
On Mon, 26 Jun 2000 23:19:11 GMT, Newz <anon@anon.com> wrote:
>Am I off topic? If so, where should I post this?
Yep.
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
There is a Perl Jobs Announce list that may be more helpful to you. See
<http://www.pm.org/mailing_lists.shtml> for details.
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Your pluck is admirable. However, arguing for a 'pure computer
science' approach in the perl5-porters mailing list is somewhat like
inquiring about mileage in a Maserati dealership. People are given to
drop their champagne glasses and stare. - Felix Gallo, p5p
------------------------------
Date: Mon, 26 Jun 2000 19:28:14 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: CGI Perl Programmer Needed for Conrtract
Message-Id: <slrn8lfpoe.8an.tadmc@magna.metronet.com>
On Mon, 26 Jun 2000 23:19:11 GMT, Newz <anon@anon.com> wrote:
>Am I off topic?
Yes.
>If so, where should I post this?
In a newsgroup with "jobs" in its name.
See also the Perl Monger's jobs mailing list:
http://www.pm.org/mailing_lists.shtml
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 26 Jun 2000 23:42:31 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Changing case in a file!
Message-Id: <slrn8lfqj7.rmt.dha@panix2.panix.com>
On Mon, 26 Jun 2000 20:59:39 GMT, Rene Nyffenegger
<renenyffenegger@my-deja.com> wrote:
>> URLs are by definition case sensitive. Aside from the degenerate case
>> of a URL that doesn't contain any case-sensitive characters, there are
>> various heroic measures that can be adopted (and often are adopted,
>> specifically by PoBs) to hide the case-sensitivity, but none of them
>> is without deleterious consequences.
>
>What is or who are PoBs?
"Prisoners of Bill" - i.e. Windows users.
best,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"i don't play lead. it interferes with my drinking." - Malcolm Young
------------------------------
Date: Mon, 26 Jun 2000 23:57:50 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Changing case in a file!
Message-Id: <26S55.1834$3v3.45968@news.uswest.net>
"Alan J. Flavell" <flavell@mail.cern.ch> elucidates:
> On Mon, 26 Jun 2000, Tom Phoenix wrote:
>
>> Of course, URLs are, in general, case sensitive,
>
> This topic is quite widely misunderstood, so excuse me for stepping in
> with an attempt at clarification here.
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.
In fact, URL comparison for host and scheme parts in HTTP must
be case insensitive.
------------------------------
Date: Mon, 26 Jun 2000 17:21:01 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Changing case in a file!
Message-Id: <Pine.GSO.4.10.10006261718440.578-100000@user2.teleport.com>
On Mon, 26 Jun 2000, Jerome O'Neil wrote:
> "Alan J. Flavell" <flavell@mail.cern.ch> elucidates:
> > On Mon, 26 Jun 2000, Tom Phoenix wrote:
> >
> >> Of course, URLs are, in general, case sensitive,
> >
> > This topic is quite widely misunderstood, so excuse me for
> > stepping in with an attempt at clarification here.
>
> 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.
>
> In fact, URL comparison for host and scheme parts in HTTP must
> be case insensitive.
...which is why I said "in general". Folks who want the whole story should
read the RFCs. But this no longer has anything to do with Perl, does it?
Follow-ups set, in case there's any Perl-related follow-up. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 26 Jun 2000 22:23:26 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: dbi oracle - newbie question
Message-Id: <8j8l4u$h0h$1@internal-news.uu.net>
jude_carter@my-deja.com wrote:
> I'm trying to look up rows in an oracle table using a flat file for the
> key values to look up. I find that it will fail a match on character
> fields if there are less characters in the field than the total size of
> the field.
You mentioned your database fields are of type 'CHAR(4)' which is
fixed-length string. Then you try to select with a 3-char search string.
Check Oracle/DBI documentation, it is very well possible that trailing
spaces are cut of somewhere, thus never matching. Check DBI/Oracle
documentation.
Solutions:
use VARCHAR2 columns instead of CHAR columns
change SQL to use "WHERE <columns> LIKE 'lll%'"
Erik
------------------------------
Date: 26 Jun 2000 23:55:09 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Golf (Was: Re: HELP ME PLEASE !!!!)
Message-Id: <d7l4p0oy.fsf@macforce.sumus.dk>
kcivey@cpcug.org (Keith Calvert Ivey) writes:
> Jakob Schmidt <sumus@aut.dk> wrote:
>
> >opendir D, '.'; print join $/, grep -d, readdir D;
>
> $, = $/; print grep -d, <*>;
Dammit you're good! :-O
> >NB: I use a lot of whitespace. Redundant whitespace does
> >not count as strokes.
>
> 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.
So I win afterall:
$,=$/;print grep-d,<*>;
;-)
By redundant whitespace I meant whitespace that _can_ be omitted. I think
it's a bit silly to count that since removing it is completely trivial
(though I can't say I was sure about the space between grep and -d before
I tried).
But it seems to be consensus, so I guess I must abide... Apparantly I was
mistaken.
--
Jakob
------------------------------
Date: 27 Jun 2000 00:05:54 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Golf (Was: Re: HELP ME PLEASE !!!!)
Message-Id: <bt0op071.fsf@macforce.sumus.dk>
Uri Guttman <uri@sysarch.com> writes:
> >>>>> "JS" == Jakob Schmidt <sumus@aut.dk> writes:
>
> in the perl golf tournament at tpc4 white space counts. there are
> syntactic tricks to lowering the need for white space so counting it
> make sense in golf.
I thought the necessary whitespace counted - not the "redundant" as I called
it. I mean changing print $x, $y into print$x,$y is not a worthy activity
for a golfer, is it?
> look out for an announcement of the tournament from your local pm group
> and in other place (like here) very soon.
I will. Though sadly I've yet to win my first hole in this ng :-(
--
Jakob
------------------------------
Date: Mon, 26 Jun 2000 23:27:32 GMT
From: jgore@home.com
Subject: IO::SELECT IS BROKE!
Message-Id: <3957e28b.189767536@24.14.77.6>
IO::SELECT is broke!
I'm using an old version of IO. The one that comes with
ActiveState Perl 5.005. If you use Activestate Perl check the
other modules. You'll notice most are kinda dated.
I can't upgrade because the new IO versions
19 and 20 won't compile on Win32 with NMAKE.
REALLY SAD people don't make their code portable. ;-(
Both IO and Socket won't compile on Win32 with Perl 5.005 and NMAKE.
The error below is all I get. Does anyone know how to compile IO and Socket
for Win32, Perrl 5.005, and NMAKE ???? Please help if you do.
C:\temp\temp\Socket-1.5>nmake
Microsoft (R) Program Maintenance Utility Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.
mkdir blib
mkdir blib\lib
mkdir blib\arch
mkdir blib\arch\auto
mkdir blib\arch\auto\Socket
mkdir blib\lib\auto
mkdir blib\lib\auto\Socket
cp Socket.pm blib\lib\Socket.pm
AutoSplitting blib\lib\Socket.pm (blib\lib\auto/Socket)
C:\Perl\bin\perl.exe -IC:\Perl\lib -IC:\Perl\lib C:\Perl\lib\ExtUtils/xs
ubpp -typemap C:\Perl\lib\ExtUtils\typemap Socket.xs >xstmp.c && C:\Perl\bin\pe
rl.exe -IC:\Perl\lib -IC:\Perl\lib -MExtUtils::Command -e mv xstmp.c Socket.c
Usage: xsubpp [-v] [-C++] [-except] [-prototypes] [-noversioncheck] [-nolinenumb
ers] [-s pattern] [-typemap typemap]... file.xs
NMAKE : fatal error U1077: 'C:\PERL\BIN\PERL.EXE' : return code '0xff'
Stop.
C:\temp\temp\Socket-1.5>
------------------------------
Date: 26 Jun 2000 20:32:09 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Local & anonymous arrays
Message-Id: <slrn8lfui6.ka1.abigail@alexandra.delanet.com>
Bart Lateur (bart.lateur@skynet.be) wrote on MMCDXCI September MCMXCIII
in <URL:news:395aa749.10573007@news.skynet.be>:
{}
{} I think so. You need a "deep copy". See the code snippet from Randal
{} Schwartz' article at
{} <http://www.stonehenge.com/merlyn/UnixReview/col30.html>:
{}
{} Here it is:
{}
{} sub deep_copy {
{} my $this = shift;
{} if (not ref $this) {
{} $this;
{} } elsif (ref $this eq "ARRAY") {
{} [map deep_copy($_), @$this];
{} } elsif (ref $this eq "HASH") {
{} +{map { $_ => deep_copy($this->{$_}) } keys %$this};
{} } else { die "what type is $_?" }
{} }
{}
{} I think it would be worth it turning this code into a little module. The
{} only snag is that it doesn't work, as is, with objects (ak bless
{} references).
It also doesn't work with circulair references, or when you have multiple
references pointing to the same thing.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Mon, 26 Jun 2000 18:12:35 -0400
From: Mike Johnson <mbmj@erols.com>
To: Rob <rob@cowsnet.com>
Subject: Re: matching question (http related)
Message-Id: <3957D553.69EC356D@erols.com>
How would you match the left portion of the string, i.e., the path?
From this http://www.path/filename
to this http://www.path
Mike
Rob wrote:
> Ugh ... overcoding ... what is wrong with this
>
> s/.+\///g;
>
> and if you really need the perpending '/' ...
>
> $_ = "/" . $_;
>
> Rob
>
> --
> The email address should read rob at cowsnet dot com
>
> <purl_gurl@my-deja.com> wrote in message news:8j5ofi$6j$1@nnrp1.deja.com...
> > In article <8j5lls$u6q$1@nnrp1.deja.com>,
> > cavenewt@my-deja.com wrote:
> >
> >
> > > I'm trying to match the 'rightmost' pattern in a string
> >
> > > so if I have
> > > http://www.nethole.com/bongo/junior.html it would match to
> > > /junior.html
> >
> > > if I have
> > > http://www.nethole.com/bongo/fred it would match to /fred
> >
> > > if I have
> > > http://www.nethole.com/ it would match to /
> >
> > > the variants of \/$ seem to grab the left most / character.
> > > I want the right most.
> >
> > > If you have suggestions, please e-mail a reply
> >
> >
> > Sure... as if..
> >
> >
> > * snaps her fingers *
> >
> > Wallah! Piece of Marie Antoinette cake.
> >
> >
> >
> > PRINTED RESULTS:
> > ________________
> >
> > Old String: http://www.nethole.com/bongo/junior.html
> > New String: /junior.html
> >
> > Old String: http://www.nethole.com/bongo/fred
> > New String: /fred
> >
> > Old String: http://www.nethole.com/
> > New String: /
> >
> > Done! Godzilla Rocks!
> >
> >
> > TEST SCRIPT:
> > ____________
> >
> > #!/usr/local/bin/perl
> >
> > print "Content-Type: text/plain\n\n";
> >
> > $string = "http://www.nethole.com/bongo/junior.html";
> >
> > &Right_Side;
> >
> > $string = "http://www.nethole.com/bongo/fred";
> >
> > &Right_Side;
> >
> > $string = "http://www.nethole.com/";
> >
> > &Right_Side;
> >
> >
> > sub Right_Side
> >
> > {
> > print "Old String: $string\n";
> > $position = rindex ($string, "/");
> > $length = length ($string);
> > $fetch = ($length - $position);
> > $new_string = substr ($string, $position, $fetch);
> > print "New String: $new_string\n\n";
> > }
> >
> > print "Done! Godzilla Rocks!";
> >
> > exit;
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
------------------------------
Date: Mon, 26 Jun 2000 19:04:14 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: matching question (http related)
Message-Id: <slrn8lfobe.8an.tadmc@magna.metronet.com>
On Mon, 26 Jun 2000 18:12:35 -0400, Mike Johnson <mbmj@erols.com> wrote:
>How would you match the left portion of the string, i.e., the path?
^^^^^^^^
I wouldn't do it with a pattern match at all!
Because there are different patterns required for
different Operating Systems.
I would use the module designed for doing that:
perldoc File::Basename
And please don't quote 100 lines of text for no reason.
And please don't post in reversed time order.
Put what happended first first (the quoted text) and what
happened second second (your comments about the quoted text).
[ snip over 100 lines of Jeopardy quoted text ]
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 26 Jun 2000 20:54:44 -0400
From: Mike Johnson <mbmj@erols.com>
Subject: Re: matching question (http related)
Message-Id: <3957FB53.D3FEDB84@erols.com>
Tad McClellan wrote:
> I wouldn't do it with a pattern match at all!
>
> Because there are different patterns required for
> different Operating Systems.
>
> I would use the module designed for doing that:
>
> perldoc File::Basename
>
Thank you. I will look into the module.
> And please don't quote 100 lines of text for no reason.
Point well taken.
>
> 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?
>
> Put what happended first first (the quoted text) and what
> happened second second (your comments about the quoted text).
>
I stand corrected.
Mike
------------------------------
Date: Mon, 26 Jun 2000 23:03:11 GMT
From: thgibbs@my-deja.com
Subject: Re: More error checking with Getopt
Message-Id: <8j8nf5$4f0$1@nnrp1.deja.com>
> > Does this do what you want?
> >
> > our $opt_f = './hosts.out';
> > getopt('f:');
You might also try:
getopt('f:');
$opt_f ||= './hosts.out';
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 27 Jun 2000 00:15:43 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Need Perl Programmer
Message-Id: <slrn8lfshf.rmt.dha@panix2.panix.com>
On Mon, 26 Jun 2000 18:13:52 +0100, Robert Dupont
<Dupont@netcomuk.co.uk> wrote:
>Need a Perl programmer in the UK for a little work with forms on our web
>site.
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
There is a Perl Jobs Announce list that may be more helpful to you. See
<http://www.pm.org/mailing_lists.shtml> for details.
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Chemistry is easy. It's just like witchcraft, but with less newt.
- Willow
------------------------------
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 3486
**************************************