[9698] in Perl-Users-Digest
Perl-Users Digest, Issue: 3292 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 30 03:17:11 1998
Date: Thu, 30 Jul 98 00:00:38 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 30 Jul 1998 Volume: 8 Number: 3292
Today's topics:
Another Win32 install prob (5.005_01) -- probably STILL <cjdpcssd@ims-1.com>
Change Unix NIS password though the WEB interface (Mr Lo Kai Cheong)
Re: Coverage Tool? (brian d foy)
Re: cperl-mode vs vi <ix@maz.org>
Re: Help on my very short script using hash (M.J.T. Guy)
Re: HTML module - would this be useful to you? (brian d foy)
Re: newbie string questions. (Martien Verbruggen)
Re: Perl 5.004/5.005 difference? (Bug?) (Martien Verbruggen)
problem with script creating files under Perl 5 "-T" (Geo)
Re: question about url (brian d foy)
references and scope <rob@netcentral.net>
Re: references and scope <rob@netcentral.net>
Re: references and scope (Mark-Jason Dominus)
Re: references and scope <ckilburn@nbnet.nb.ca>
Re: removing accented characters from a string (mop)
replication <edwardv@jps.net>
Script trouble <momiji@slip.net>
Re: Submit only Once (Martien Verbruggen)
Re: Y2K problem in PERL with localtime() (Craig Berry)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 29 Jul 1998 23:08:00 -0500
From: "Curtis Jewell / Dennis Whalen" <cjdpcssd@ims-1.com>
Subject: Another Win32 install prob (5.005_01) -- probably STILL another idiot
Message-Id: <6pork6$hqf@enews2.newsguy.com>
Well, I'm trying to install Perl 5.005_01 on my Windows 95 system.
I downloaded 4dos, dmake and mingw32-ecgs, like README.win32 suggests I
should.
Here's what comes out.
MingW32 build with DMAKE, w/o fcrypt, of 5.005_01
CCTYPE *= GCC
CCHOME *= C:\mingw32
EMAIL *= curtis_whalen+perl@geocities.com
4DOS 6.01A (Win95) DOS 7.10
It couldn't seem to find miniperlmain.c, even though it existed.
I'll try renaming it to mpmain.c (and fixing makefile.mk appropriately):
--------------- STARTING....
c:\windows\desktop\perl5.005_01\win32>dmake
del /f config.h
Deleting C:\WINDOWS\DESKTOP\perl5.005_01\win32\config.h
1 file deleted 69,632 bytes freed
copy config_H.gc config.h
C:\WINDOWS\DESKTOP\perl5.005_01\win32\config_H.gc =>
C:\WINDOWS\DESKTOP\perl5.00
5_01\win32\config.h
1 file copied
if not exist ".\mini" mkdir ".\mini"
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\av.o ..\av.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\byterun.o ..\byterun.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\deb.o ..\deb.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\doio.o ..\doio.c
..\doio.c: In function `Perl_do_aexec':
..\doio.c:979: warning: passing arg 2 of `win32_execvp' from incompatible
pointe
r type
..\doio.c:981: warning: passing arg 2 of `win32_execvp' from incompatible
pointe
r type
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\doop.o ..\doop.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\dump.o ..\dump.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\globals.o ..\globals.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\gv.o ..\gv.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\hv.o ..\hv.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\mg.o ..\mg.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\op.o ..\op.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\perl.o ..\perl.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\perly.o ..\perly.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\pp.o ..\pp.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\pp_ctl.o ..\pp_ctl.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\pp_hot.o ..\pp_hot.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\pp_sys.o ..\pp_sys.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\regcomp.o ..\regcomp.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\regexec.o ..\regexec.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\run.o ..\run.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\scope.o ..\scope.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\sv.o ..\sv.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\taint.o ..\taint.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\toke.o ..\toke.c
..\toke.c: In function `Perl_yylex':
..\toke.c:1944: warning: passing arg 2 of `win32_execv' from incompatible
pointe
r type
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\universal.o ..\universal.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\util.o ..\util.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\mpmain.o ..\mpmain.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\perlio.o ..\perlio.c
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\win32.o win32.c
In file included from
C:\MINGW32\LIB\GCC-LIB\i386-mingw32\egcs-2.90.27\../../../
../i386-mingw32/include/windows.h:39,
from win32.c:17:
C:\MINGW32\LIB\GCC-LIB\i386-mingw32\egcs-2.90.27\../../../../i386-mingw32/i
nclud
e/Windows32/Base.h:264: warning: redefinition of `TCHAR'
C:\MINGW32\LIB\GCC-LIB\i386-mingw32\egcs-2.90.27\../../../../i386-mingw32/i
nclud
e/tchar.h:143: warning: `TCHAR' previously declared here
win32.c: In function `win32_fsetpos':
win32.c:1574: warning: passing arg 2 of `fsetpos' discards `const' from
pointer
target type
gcc -c -I..\lib\CORE -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -
g -O2
-o.\mini\win32sck.o win32sck.c
In file included from win32sck.c:31:
C:\MINGW32\LIB\GCC-LIB\i386-mingw32\egcs-2.90.27\../../../../i386-mingw32/i
nclud
e/assert.h:58: warning: `assert' redefined
../perl.h:1473: warning: this is the location of the previous definition
gcc -v -o ..\miniperl.exe -LC:\mingw32\lib \
C:\Windows\Temp\mk000001
Reading specs from C:\MINGW32\LIB\GCC-LIB\i386-mingw32\egcs-2.90.27\specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
C:\MINGW32\LIB\GCC-LIB\i386-mingw32\egcs-2.90.27\../../../../i386-mingw32\b
in\l
d.exe -o ..\miniperl.exe
C:\MINGW32\LIB\GCC-LIB\i386-mingw32\egcs-2.90.27\../../
../../i386-mingw32\lib\crt1.o -LC:\mingw32\lib -LC:\MINGW32\LIB\GCC-LIB\i38
6-min
gw32\egcs-2.90.27 -LC:\MINGW32\LIB\GCC-LIB -LC:\MINGW32\LIB\GCC-LIB\i386-mi
ngw32
\egcs-2.90.27\../../../../i386-mingw32\lib -LC:\MINGW32\LIB\GCC-LIB\i386-mi
ngw32
\egcs-2.90.27\../../..
C:\Windows\Temp\mk000001 -lmingw32 -lgcc -lmoldname -lcrt
dll -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lcrtdll
--------------- STOPPING here for a sec...
Looks ok up to here. A few warnings. I expect that.
miniperl.exe is created.
--------------- RESTARTING....
cd .. && miniperl minimod.pl > lib\ExtUtils\Miniperl.pm
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = "",
LANG = ""
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
..\miniperl.exe -I..\lib config_sh.PL "INST_DRV=c:"
"INST_TOP=c:\perl"
"INST_VER=\5.005
01" "archname=MSWin32-x86"
"cc=gcc"
"ccflags
=-g -O2 -DWIN32 "
"cf_email=curtis_whalen+perl@geocities.c
om" "d_crypt=undef"
"d_mymalloc=undef"
"libs= -ladvapi32 -luser
32 -lnetapi32 -lwsock32 -lmingw32 -lgcc -lmoldname -lcrtdll -lkernel32"
"incpath=C:\mingw32\include"
"libperl=libperl.a"
"libpth=C:\mingw32\lib"
"libc=-lcrtdll"
"make=dm
ake" "_o=.o" "obj_ext=.o"
"_a=.a" "lib_ext=.a"
"static_ext=Dyna
Loader" "dynamic_ext=Socket IO Fcntl Opcode
SDBM_File PO
SIX attrs Thread B re Data/Dumper"
"nonxs_e
xt=Errno" "usethreads=undef"
"LINK_FLAGS= -LC:\mingw32\lib "
"optimize=-g -O2
" config.w32 > ..\config.sh
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = ""
LANG = ""
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Can't open lib_ex: No such file or directory
cd .. && miniperl configpm
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = "",
LANG = ""
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Can't open ./config.sh: No such file or directory
Use of uninitialized value at configpm line 403.
configpm: lib/Config.pm not valid at configpm line 403.
DMAKE.EXE: Error code 2, while making '..\lib\Config.pm'
DMAKE.EXE: '..\lib\Config.pm' removed.
--------------- END....
??!@??!@@??
Maybe someone can explain these last few, I'm no mind-reader.
--Curtis
------------------------------
Date: 30 Jul 1998 06:45:50 GMT
From: lkcheong@news.hk.super.net (Mr Lo Kai Cheong)
Subject: Change Unix NIS password though the WEB interface
Message-Id: <6pp4qu$t2d$2@tst.hk.super.net>
Where can I find any info about changing the Unix NIS password through the
Web Interface?
Thanks!
Pls email a copy to lkcheong@Hk.super.net
------------------------------
Date: Thu, 30 Jul 1998 02:11:20 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Coverage Tool?
Message-Id: <comdog-3007980211200001@news.panix.com>
Keywords: just another new york perl hacker
In article <6poi51$om5$1@monet.op.net>, mjd@op.net (Mark-Jason Dominus) posted:
> In article <6poc16$rnt$1@mark.ucdavis.edu>,
> Eric Sheng <shenge@ece.ucdavis.edu> wrote:
> >I was wondering if there is any tools out there or inside the perl debugger
> >that would keep track of which lines of the script has been hit or executed
> >during run-time.
>
> Devel::Coverage.
>
> Available from http://www.perl.com/CPAN/modules/by-module/Devel/Devel-Coverage-0.1.tar.gz
in the same directory is Devel::SmallProf which is a line profiler.
kinda nifty.
--
brian d foy <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Wed, 29 Jul 1998 21:37:24 -0700
From: Brian Moseley <ix@maz.org>
Subject: Re: cperl-mode vs vi
Message-Id: <35BFF884.19334B61@maz.org>
Paul D. Smith wrote:
> bm> it sounds like i need some type of perl-mode hook that will run
> bm> through the entire buffer and replace each tab character with the
> bm> appropriate number of spaces. anything like that built into
> bm> cperl-mode or emacs that i dont know about?
>
> Next, examine the functions (C-h f) tabify, tabify-buffer, untabify, and
> untabify-buffer.
ah yes. it looks like i could either tabify-buffer when writing the file or
untabify-buffer when finding the file. i've very little elisp knowledge .. can
somebody provide the code for this functionality, or at least name the hooks i
should be using?
oh and, tabify-buffer and untabify-buffer don't seem to be available :) i'm
using 20.2.1.
--
Brian Moseley
Agent of Chaos - Critical Path
------------------------------
Date: 30 Jul 1998 00:03:26 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Help on my very short script using hash
Message-Id: <6pod8e$kej$1@pegasus.csx.cam.ac.uk>
Aaron B. Dossett <aarond@alpha.ewl.uky.edu> wrote:
>Tom Phoenix (rootbeer@teleport.com) wrote:
>> How is it that you're running this with warnings turned on and you aren't
>> getting a warning for this? Are you using some very old version of perl?
>
>It doesn't have to be all that old, my copy of 5.003 doesn't issue a
>warning.
Perl 5.003 is very old.
Not as old as a flea-bitten camel carcass, but ...
Mike Guy
------------------------------
Date: Thu, 30 Jul 1998 02:13:25 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HTML module - would this be useful to you?
Message-Id: <comdog-3007980213250001@news.panix.com>
Keywords: just another new york perl hacker
In article <35BF852A.5C3C@databeam.com>, rbowen@databeam.com posted:
> So, my question is whether anyone else other than me sees the value of
> this, and, if so, would HTML::Template be a reasonable name for it, or,
> am I just missing an existing implementation of this same idea?
is there any reason it has to be limited to HTML? does it do the
same thing as Text::Template?
just some things to consider.
good luck :)
--
brian d foy <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: 30 Jul 1998 04:57:38 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: newbie string questions.
Message-Id: <6poug2$jst$1@nswpull.telstra.net>
In article <35BDD24A.AE574963@sterlingdi.com>,
Michael Maraist <maraism@sterlingdi.com> writes:
> Simple enough.. Just require that a sentence be defined as a line of
Would you consider 'Simple enough..' to be a sentence?
> characters followed by a period and two spaces. That's how I've always
> been taught at least.. Then you could do something like.
ditto.
In this case it becomes another problem. You now _require_ that any
text that you get is formatted in a certain way. I doubt very much if
that is a realistic requirement. Most people, including me, have
abandoned the double space following a full stop to signify a new
sentence a long time ago. To actually put in a double space requires
effort on my part.
Sure, it would be a solution. I am simply wondering if it is realistic
to expect your input to conform to this rigid format. You might as
well tell users that you will expect every sentence to be on a line of
its own, and a paragraph break would be an line with only the line
break. That way you can split on that. Or you could tell people to put
the magic sequence '<FOOBAR_END_OF_SENTENCE_BARFOO>' at the end of
every sentence.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 30 Jul 1998 05:15:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl 5.004/5.005 difference? (Bug?)
Message-Id: <6povh3$l0g$1@nswpull.telstra.net>
In article <6pkn0p$8gu$1@pegasus.csx.cam.ac.uk>,
mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
> Lars Andersson <barse@acc.umu.se> wrote:
>>I think I found a bug in the 5.005 version of Perl. The program
>>
>>foreach $i (60..90) {
>> if ($i =~ /7/g){next}
That's a weird thing to do :) Anyway:
>> else {print "$i "}
>>}
# perl5.004_04 -e 'foreach (60..90) { next if /7/g; print "$_ "}'
60 61 62 63 64 65 66 68 69 80 81 82 83 84 85 86 88 89 90
# perl5.005 -e 'foreach (60..90) { next if /7/g; print "$_ "}'
60 61 62 63 64 65 66 68 69 71 73 75 78 80 81 82 83 84 85 86 88 89 90
Indeed. A difference.
A little more investigation:
#!/usr/local/bin/perl5.005 -w
foreach (68..82)
{
print "pos:",pos,"\n";
if (/7/g)
{
print "m:$_:$&:",pos,"\n";
}
else
{
print "n:$_:$&:",pos,"\n";
}
}
__END__
pos:
n:68::
pos:
n:69::
pos:
m:70:7:1
pos:1
n:71::
pos:
m:72:7:1
pos:1
n:73::
pos:
m:74:7:1
pos:1
n:75::
pos:
m:76:7:1
pos:1
m:77:7:2
pos:2
n:78::
pos:
m:79:7:1
pos:1
n:80::
pos:
n:81::
pos:
n:82::
Looks like pos isn't being reset.
Might be worth a perlbug report.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Thu, 30 Jul 1998 05:17:48 GMT
From: 4geonospam@316csi.conn (Geo)
Subject: problem with script creating files under Perl 5 "-T"
Message-Id: <6povm2$nmj@world6.bellatlantic.net>
I have a block of code that let's my scripts create a new file with a unique
name, however, I tried to use it in a script that is running with the -T
option and it won't work...
Here's what I usually do...
----------------
open (ORDERLOG, "+>$path/$timestamp.log");
print ORDERLOG "$timestamp\n\n";
print ORDERLOG $content\n\n;n";
close (ORDERLOG);
---------------
Evidently Perl 5 feels it is "tainted" and prevents the script from writing
new files.
How do you accomplish this under Perl5 "-T"?
to reply via e-mail, remove the letter "4" and the phrase "nospam" from the reply to address (4geonospam@316csi.conn) of this post. You will also need to change "316csi.conn" to "316csi.com". Visit my personal page @ http://316csi.com/geo ..
------------------------------
Date: Thu, 30 Jul 1998 02:16:43 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: question about url
Message-Id: <comdog-3007980216430001@news.panix.com>
Keywords: just another new york perl hacker
In article <6pnep3$ooc$1@news.worldonline.nl>, "Maarten" <mtveermanAD@mindlessDOT.com> posted:
> They provide me a url like:
> http://www.yourdomain.com/postcards/birthday/13yearsold/cardsent.html
> I need to get rid of the cardsent.html.........
> Apache Guardian has a line which gets rid of all behind .com. But that is
> not what I need. I should end up with
> http://www.yourdomain.com/postcards/birthday/13yearsold/
> Do you know a way to do this?
you can use URI::URL to break the string into its parts, and then
use File::Basename on the path portion of the url.
good luck :)
--
brian d foy <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Thu, 30 Jul 1998 04:07:17 GMT
From: Rob Huffstedtler <rob@netcentral.net>
Subject: references and scope
Message-Id: <35BFF153.56813806@netcentral.net>
I am attempting to reimplement the unix program cal in perl (I realize
this has already been done, but I am trying to do it without consulting
existing code), so that I can determine whether it might be a suitable
assignment for a class I am teaching (if you have any interest in seeing
what we've done so far, take a look at
www.bagpipe.com/comp/perl_class.html.) I would probably just have them
do a single month calendar, which is pretty trivial.
However, to do a whole year at once, it seems like the best approach is
to create each month as a two dimensional array and maintain a reference
to it, so that as I am doing each block of 3 months, I can easily switch
between them. Unfortunately, when experimenting with it doing just one
month, I can only get six blank lines when printing it. According to
the camel book, variables should stay in scope as long as they have a
reference count greater than one, but that doesn't seem to be happening
in my case. I believe the problem is that I have a fundamental
misunderstanding of array references. I've used them in
multidimensional structures before, but this is the first time I have
ever tried to pass them to functions or return them from functions.
Here is some of my code. If you have any idea what I might be doing
wrong, please let me know. It would be great if you could email me as
well as posting a reply, since I only check the group a couple of times
a week.
foreach $week(&build_it) {
for ($day = 0; $day < 7; $day++) {
print "$week[$day] ";
}
print "\n";
}
sub build_it {
my $cday = 0; #The current cell of the array
my $fday = 3; #first day of month. For now, hardcoded to Wed.
my $last_day = 31; #last day of the month.
my @array;
for (my $week = 0; $week <= 5; $week++) {
for (my $day = 0; $day <=6; $day++) {
if ($cday <= $last_day) {
$array[$week][$day] = $cday;
} else {
$array[$week][$day] = 0;
}
$cday++;
}
}
return (\@array);
}
------------------------------
Date: Thu, 30 Jul 1998 04:42:21 GMT
From: Rob Huffstedtler <rob@netcentral.net>
Subject: Re: references and scope
Message-Id: <35BFF98B.7D06E62A@netcentral.net>
I finally had a breakthrugh. It seems that there is not an easy way to use
a foreach on an array reference. Is there any way at all? This works:
$test = &build_it;
for ($week = 0; $week < 6; $week++) {
for ($day = 0; $day < 7; $day++) {
print "$test->[$week]->[$day] ";
}
print "\n";
}
In an instance like this, where I always know that the array will have 6
rows and 7 columns, that's ok, I suppose, but I imagine that there are
instances
where I would need to process a multidimensional array of arbitrary size.
Does anyone know how I would go about that?
Incidentally, for those who may have been looking closely, I'm aware that I
am not populating the grid properly to take the first day into account. I
have
that working in another version of the code and will copy it over when I
solve this problem.
Rob Huffstedtler wrote:
> I am attempting to reimplement the unix program cal in perl (I realize
> this has already been done, but I am trying to do it without consulting
> existing code), so that I can determine whether it might be a suitable
> assignment for a class I am teaching (if you have any interest in seeing
> what we've done so far, take a look at
> www.bagpipe.com/comp/perl_class.html.) I would probably just have them
> do a single month calendar, which is pretty trivial.
>
> However, to do a whole year at once, it seems like the best approach is
> to create each month as a two dimensional array and maintain a reference
> to it, so that as I am doing each block of 3 months, I can easily switch
> between them. Unfortunately, when experimenting with it doing just one
> month, I can only get six blank lines when printing it. According to
> the camel book, variables should stay in scope as long as they have a
> reference count greater than one, but that doesn't seem to be happening
> in my case. I believe the problem is that I have a fundamental
> misunderstanding of array references. I've used them in
> multidimensional structures before, but this is the first time I have
> ever tried to pass them to functions or return them from functions.
> Here is some of my code. If you have any idea what I might be doing
> wrong, please let me know. It would be great if you could email me as
> well as posting a reply, since I only check the group a couple of times
> a week.
>
> foreach $week(&build_it) {
> for ($day = 0; $day < 7; $day++) {
> print "$week[$day] ";
> }
> print "\n";
> }
>
> sub build_it {
>
> my $cday = 0; #The current cell of the array
> my $fday = 3; #first day of month. For now, hardcoded to Wed.
> my $last_day = 31; #last day of the month.
> my @array;
>
> for (my $week = 0; $week <= 5; $week++) {
> for (my $day = 0; $day <=6; $day++) {
> if ($cday <= $last_day) {
> $array[$week][$day] = $cday;
> } else {
> $array[$week][$day] = 0;
> }
> $cday++;
> }
> }
> return (\@array);
> }
------------------------------
Date: 30 Jul 1998 01:30:11 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: references and scope
Message-Id: <6pp0d3$psq$1@monet.op.net>
In article <35BFF98B.7D06E62A@netcentral.net>,
Rob Huffstedtler <rob@netcentral.net> wrote:
>for ($week = 0; $week < 6; $week++) {
> for ($day = 0; $day < 7; $day++) {
> print "$test->[$week]->[$day] ";
> }
> print "\n";
>}
>
>In an instance like this, where I always know that the array will
>have 6 rows and 7 columns, that's ok, I suppose, but I imagine that
>there are instances where I would need to process a multidimensional
>array of arbitrary size. Does anyone know how I would go about that?
for ($week = 0; $week < @$test; $week++) {
for ($day = 0; $day < @{$test->[$week]}; $day++) {
print $test->[$week][$day], " ";
}
print "\n";
}
# Or...
foreach $week (@$test) {
foreach $day (@$week) {
print $day, " ";
}
print "\n";
}
# Or...
foreach $week (@$test) {
print "@$week \n";
}
------------------------------
Date: Thu, 30 Jul 1998 02:57:40 -0300
From: Colin Kilburn <ckilburn@nbnet.nb.ca>
To: Rob Huffstedtler <rob@netcentral.net>
Subject: Re: references and scope
Message-Id: <35C00B54.54641C67@nbnet.nb.ca>
Rob Huffstedtler wrote:
> I am attempting to reimplement the unix program cal in perl
> in my case. I believe the problem is that I have a fundamental
> misunderstanding of array references.
foreach $week (@{&build_it}) { #dereference the outer array ref
for $day (0..6) {
print "@$week[$day] "; #dereference the inner array ref
} # could use "$week->[$day] "
print "\n";
}
Your problem appears to be in dereferencing.
- read the perldocs: perllol, perldsc, perlref
- write some test scripts to test your new knowledge.
- use x to dump the contents of a variable (ref) in the debugger
if you get frustrated.
good luck,
C.
> foreach $week(&build_it) {
> for ($day = 0; $day < 7; $day++) {
> print "$week[$day] ";
> }
> print "\n";
> }
------------------------------
Date: Thu, 30 Jul 1998 03:26:11 GMT
From: orion@damage.inc (mop)
Subject: Re: removing accented characters from a string
Message-Id: <35bfe74e.17720841@news.acns.nwu.edu>
On Wed, 29 Jul 1998 20:34:16 -0400, rjk@coos.dartmouth.edu (Ronald J
Kimball) wrote:
>> How could I have the "tr" expression replace any accented letter with an
>> English letter?
>
>The same way you use tr to replace any other character with another
>character. Put the character(s) you want to replace on the left, and
>the character(s) you want them replaced with on the right. :-)
>
>tr/q/n/;
>
>You could also specify the accented letters by ASCII value:
>
>tr/\x96/n/;
Ah, ok.. I'll try the ASCII approach. Thanks a lot!
Ultrasparc
tberger@nwu.edu
------------------------------
Date: Wed, 29 Jul 1998 21:33:14 -0700
From: "Edward Villalovoz" <edwardv@jps.net>
Subject: replication
Message-Id: <35bff7d7.0@blushng.jps.net>
Does anyone know what the best way to check one table in an informix
database, compare it with a table in another informix database, and if there
is new data in the first table, append only the new data to the second
table? And I need to do this from perl. If you have any sample code it
would be helpful. :) Thanks in advance.
------------------------------
Date: Wed, 29 Jul 1998 21:35:49 -0700
From: Eric Umehara <momiji@slip.net>
Subject: Script trouble
Message-Id: <35BFF823.78995DD5@slip.net>
Hi
I'm just beginning to learn and appreciate Perl. But I have run into
a wall that has stumped me for couple days now. After covering three
chapters I tried to write a script that would take out all the white
spaces out of a text document that contains a list of plants that I
compiled in MS Acess then latter exported. This script is supposed to
remove all white spaces so I can use other scripts that I hope to write
in the future to do some stuff. The problem is that I can't seem to get
this script to work. If someone can correct my mistake I would
appreciate it.
Below is the script and a sample line.
#!/perl/usr/bin
"Willow ";"c = 2 to 4 meters (7 to 13 ft.) ";"U = upright
tree ";"yes ";"yes ";" ";"yes";"SH =
partial shade";"S = Spring ";;;111;
open (plantlist, "<<plant.txt");
open (final, "|final.txt")
while (<plantlist>) {
$_=@sfline;
@sfline= m!tr/l/ /!;
($name , $height , $grow , $1 , $2 , $3 , $4 , $light , $season ,
$page)=$sfline;
foreach $whites ($name , $height , $light , $season , $page) {
$whites=/{2,}$/;
print final "$whites\n";
}
}
close plantlist;
close final;
------------------------------
Date: 30 Jul 1998 05:37:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Submit only Once
Message-Id: <6pp0rg$lqu$1@nswpull.telstra.net>
Followups set. Please take this discussion to that group.
In article <35bfeb6c.29022644@news.tornado.be>,
bart.mediamind@tornado.be (Bart Lateur) writes:
> Jim Woodgate wrote:
>
>>You could generate a random number, store it in a hidden field (which
>>would need to be recalculated on a form reset), then store that
>>hidden/random number in a database when they submit a *good* form.
>
> I love it. Brilliant. Generate the form from within a CGI script, and
> you're set.
What's so brilliant about this? This is a standard way in CGI stuff.
And it has NOTHING to do with perl. Nothing in this thread has.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 30 Jul 1998 05:34:32 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6pp0l8$b5v$1@marina.cinenet.net>
John Stanley (stanley@skyking.OCE.ORST.EDU) wrote:
: >Your whole argument rests on an (intentional?) confusion between the data
: >and the presentation of that data, or the 'model' and the 'view' to steal
: >terms from one of my favorite design philosophies.
:
: No, my "whole argument" rests on the fact that 02-29-100 is the
: presentation of the data, and as such, it is not as unambiguous at it
: is claimed to be.
No (sane) Perl author would intentionally write a script which would
present that view of the time data to the user.
: >Nobody is proposing that you use the raw localtime year value in
: >human-viewable output; the fact that some misguided people did so is one
: >of the core causes of the whole y2k problem.
:
: That's right. And what I was replying to was the comment that 02-29-100
: is not ambiguous. I don't intend on using raw localtime output, nor have
: I ever said that it was the right thing to do.
So what exactly is your point? Ambiguity is *always* context-dependent.
If you walk up and say "four" to me without preliminaries, I have no idea
what you're talking about. If we've prearranged that "four" is the
special code signal meaning "time for lunch," then there is no ambiguity.
Same "view" (presentation of data) different (or absent) "model"
(underlying and agreed upon semantics of data).
: That is my point. The argument is called 'reductio ad absurdum'. The
: assumption that one person knows the format so there is no ambiguity
: leads to a ridiculous conclusion, thus the assumption is questionable.
: You can usually detect such arguments because they start, as mine did,
: with a statement similar to "if we assume your statement is correct..."
Yes, but in this case the model (localtime's year-1900 behavior) is known
to *anyone* who reads the relevant docs. That there are those who don't
know or think about it is a matter of failures in due diligence, not
unavailability of information.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 V8 Issue 3292
**************************************