[10387] in Perl-Users-Digest
Perl-Users Digest, Issue: 3980 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 15 10:07:21 1998
Date: Thu, 15 Oct 98 07:00:31 -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, 15 Oct 1998 Volume: 8 Number: 3980
Today's topics:
Re: Are there any "perl.newbie" group or forum? (Snowhare)
Re: Are there no PERL experts out there?? Is there no o <shawn@magma.ca>
Re: CGI and Perl <perlguy@technologist.com>
cgi/perl upload script vivekvp@hotmail.com
Compiling perl with mingw32 massimobalestra@my-dejanews.com
Re: Deleteing a line <shawn@magma.ca>
Re: Equivalent of "unload" after "require"? wyndo@cxo.com
Extracting from text files - Please help! <yuhsin@hprc15.sgp.hp.com>
Re: help! trying to emulate server side includes... (Tad McClellan)
How to clear "variable" hash on reentry to subroutine? <tturton@cowboys.anet-dfw.com>
Re: How to clear "variable" hash on reentry to subrouti <jdf@pobox.com>
Re: How to clear "variable" hash on reentry to subrouti (David Alan Black)
How to create variables from an array <rolf.rettinger@desy.de>
Re: How to create variables from an array <jdf@pobox.com>
Re: MacPerl windows <Arved_37@chebucto.ns.ca>
newbie at array parsing <marx@idiom.com>
One question on writing Perl module (Wong Kin Sang)
Re: One question on writing Perl module <Arved_37@chebucto.ns.ca>
Re: perl compile problem <michaelr@lndn.tensor.pgs.com>
Printing in Landscape mark_chunn@hp.com
Problem creating chart levt4072@my-dejanews.com
problem with "use lib" <dmitri@sw-systemekarlhickl.de>
Re: problem with "use lib" <jdf@pobox.com>
Re: problem with "use lib" (Mark-Jason Dominus)
Re: problem with "use lib" <tchrist@mox.perl.com>
Raleigh.pm (Raleigh, NC, USA perl mongers) has register (John Klassa)
Re: references to package subroutines and SIG (Andrew M. Langmead)
Regarding FileHandle b_pillai@hotmail.com
Saw your reply to a similar perl question. I wonder... <mb@cup.hp.com>
Re: Sorry (Lee Brandson)
tag <arp.s@tip.nl>
tag <arp.s@tip.nl>
Re: tag (Matthew Bafford)
Re: What is overwriting my variable? (Mark-Jason Dominus)
Re: Win32::OLE and Netscape <msergeant@ndirect.co.uk_NOSPAM>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Oct 1998 12:49:15 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <704r0b$ipk$1@nnrp1.snfc21.pbi.net>
Nothing above this line is part of the signed message.
In article <36256E49.FE9CEDD5@bbnplanet.com>,
Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
>Russ Allbery wrote:
>
>> You tend to find more Perl the less emphasis the CS department as a
>> whole has on theoretical compiler design and the like. Academics
>> tend not to like Perl very much for all of the sloppy,
>> unconstrained reasons that one may expect.
>
>Sloppy in what regard?
If I were of the academic bent, I would start with the lack of
strong typing and enforced privacy for object internals and work
my way up through orthagonality (the mantra of 'there is more than
one way to do it' is not regarded as a necessarily _good_ thing in
some circles).
Perl is a very cool language - but it is also a language that makes
it very easy to shoot yourself in surprising places without warning.
That is one of the reasons you see the experienced programmers here
lean away from it being a _first_ language in favor of more strictly
structured languages.
Benjamin Franz
Version: 2.6.2
iQCVAwUBNiXu7ejpikN3V52xAQG96gP/aNFBOmqwxHB4LJ6KCm6livMI5/vWkl+L
eg+X8kE+Tb08C+LhBER+rqxmBEfUVIa2io+YPUpNycIy4614Ic2JfpMruASTu0A0
EYGpDcEeduDUJE+IFd8tSi+4ur08mPD3iBOl/wZU3zHDjAk5QN152It35dkx2n0d
i2Gs4c0GMFc=
=W0kC
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 15 Oct 1998 13:59:41 GMT
From: Shawn Corey <shawn@magma.ca>
Subject: Re: Are there no PERL experts out there?? Is there no one who can solve this??
Message-Id: <3625FF9B.1B9CB8D7@magma.ca>
This is a multi-part message in MIME format.
--------------090FE32D90CDE2D1109E7061
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Rafely@xxiname.com wrote:
>
> Hello,
>
> I'm making a form so users can send me information.
> The also have to send me their name. How do I check
> and see if the name only consists of letters and white
> spaces?? So "My Name" is allowed but "Jj&*d d#fdhd"
> is not allowed!!! I want to send a message saying that
> the name was invalid! But how do I check and see if
> the name is valid? I've posted this questions several
> times in this newsgroup and other CGI newsgroup and
> CGI forums. I've tried all the suggestions but none of
> them work!! I'm a newbie to PERL, but this seems like
> a very easy question and there must be someone out
> there that knows the answer!! Here are a few
> sufggestions I got that don't work!!
>
> 1. if ( /\w/ ) {
>
> # do something
>
> } else {
>
> # do something else
> }
> }
>
> 2. /^[a-zA-Z0-9]+$/
>
> 3. $something =~ /^-?[a-zA-Z0-9.]+$/;
>
> Or
>
> $something =~ /[a-zA-Z0-9.]/;
>
> 4. $something =~ /^\w+$/;
>
> 5. /^[^\W_]*$/ # Matches "" or "\n"
>
> or
>
> /^[^\W_]+$/ # Requires at least one letter or digit
>
> 6. if( $a =~ /[^a-zA-Z ]+/ || $a !~ /\w/ ){ do error thing }
>
> PLEASE HELP!!!!
To match letters and whitespace: /^([a-zA-Z]|\s)*$/
--
Shawn Corey
s @m .c
h a a
a g
w m
n a
--------------090FE32D90CDE2D1109E7061
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Corey, Shawn
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Shawn Corey
n: Corey;Shawn
org: Corey Consultants
adr: 51 Wessex Road;;;Ottawa;Ontario;K2J 1X3;Canada
email;internet: shawn@magma.ca
title: President
tel;work: 823-4132
tel;home: 823-4132
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------090FE32D90CDE2D1109E7061--
------------------------------
Date: Thu, 15 Oct 1998 11:08:02 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: CGI and Perl
Message-Id: <3625D792.696D0D66@technologist.com>
Use the DBI module. There is an ODBC driver for it that allows
connection to ODBC databases (Access). That is what I use and it works
great.
HTH
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Thu, 15 Oct 1998 10:04:19 GMT
From: vivekvp@hotmail.com
Subject: cgi/perl upload script
Message-Id: <704hb0$c2m$1@nnrp1.dejanews.com>
i am looking for a cgi or perl script that will allow a user to upload a file
to my server.
anyone with an ideas where to find one???
please email if you know! thanx
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 15 Oct 1998 10:18:49 GMT
From: massimobalestra@my-dejanews.com
Subject: Compiling perl with mingw32
Message-Id: <704i66$d0d$1@nnrp1.dejanews.com>
Hi,
I am trying to compile Perl with mingw32 (with gcc) but I've got some
compilation errors.
I tryed also with egcc but I have the same errors.
Does someone have suggestions?
...........
some compilations without errors
...........
gcc -c -I..\lib\CORE -I.\include -I. -I.. -Ic:\mingw32\\include -DWIN32 -
DPERLDLL -DPERL_CORE -g -O2 -o.\mini\doio.o ..\doio.c
..\doio.c: In function `Perl_do_aexec':
..\doio.c:1010: warning: passing arg 2 of `win32_execvp' from incompatible
pointer type
..\doio.c:1012: warning: passing arg 2 of `win32_execvp' from incompatible
pointer type
...........
some compilations without errors
...........
gcc -c -I..\lib\CORE -I.\include -I. -I.. -Ic:\mingw32\\include -DWIN32 -
DPERLDLL -DPERL_CORE -g -O2 -o.\mini\toke.o ..\toke.c
..\toke.c: In function `Perl_yylex':
..\toke.c:2065: warning: passing arg 2 of `win32_execv' from incompatible
pointer type
...........
some compilations without errors
...........
gcc -c -I..\lib\CORE -I.\include -I. -I.. -Ic:\mingw32\\include -DWIN32
-DPERL DLL -DPERL_CORE -g -O2 -o.\mini\win32.o win32.c In file included from
c:\mingw32\\include\windows.h:39, from win32.c:17:
c:\mingw32\\include\Windows32/Base.h:231: redefinition of `TCHAR'
c:\mingw32\\include\tchar.h:138: `TCHAR' previously declared here win32.c: In
function `win32_environ': win32.c:1345: `_environ' undeclared (first use in
this function) win32.c:1345: (Each undeclared identifier is reported only
once win32.c:1345: for each function it appears in.) win32.c: At top level:
win32.c:1581: conflicting types for `win32_fsetpos'
..\lib\CORE\win32iop.h:68: previous declaration of `win32_fsetpos' gcc -v -o
..\miniperl.exe -L c:\mingw32\\lib \ C:\WINDOWS\TEMP\mk000001 Reading
specs from \mingw32\lib\gcc-lib\i386-mingw32\2.8.1\specs gcc version 2.8.1
ld -o ..\miniperl.exe C:\MINGW32\lib\crt1.o -L c:\mingw32\\lib
-Lc:\mingw32\lib \gcc-lib -LC:\MINGW32\lib
-L\mingw32\lib\gcc-lib\i386-mingw32\2.8.1 -L\mingw32\l ib
C:\WINDOWS\TEMP\mk000001 -lmingw32 -lgcc -lmoldname -lcrtdll -lkernel32 -ladv
api32 -lshell32 -lmingw32 -lgcc -lmoldname -lcrtdll ld: cannot open
.\mini\win32.o: No such file or directory cd .. && miniperl minimod.pl >
lib\ExtUtils\Miniperl.pm Error during file creation ..\miniperl.exe -I..\lib
config_sh.PL "INST_DRV=c:" "INST_TOP=c:\perl" "INST_VER=\5.00551"
"archname=MSWin32-x86" "cc=gcc" "ccflags=-g -O2 -DWIN32 " "cf_email="
"d_crypt=undef" "d_mymalloc=undef" "libs= -ladvapi32 -luser32 -lnetapi32
-lwsock32 -lmingw32 -lgcc -lmoldname - lcrtdll -lkernel32"
"incpath=c:\mingw32\\include" "libperl=libperl.a" "libpth=c:\mingw32\\lib"
"libc=-lcrtdll" "make=dmake" "_o=.o" "obj_ext=.o" "_a=.a" "lib_ext=.a"
"static_ext=DynaLoader" "dynamic_ext=Socket IO Fcntl Opcode SDBM_File POSIX
attrs Thread B reData/Dumper" "nonxs_ext=Errno" "usethreads=undef"
"LINK_FLAGS= -L c:\mingw32\\lib " "optimize=-g -O2" config.w32 > ..\config.sh
Command or file name not valid cd .. && miniperl configpm too many
parameters - &&
Bye Thank you
Massimo
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 15 Oct 1998 13:54:25 GMT
From: Shawn Corey <shawn@magma.ca>
Subject: Re: Deleteing a line
Message-Id: <3625FE5F.5F7DDC04@magma.ca>
This is a multi-part message in MIME format.
--------------8DE369E3703F83EF5021F0DE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Keith L. Miller wrote:
>
> I have a perl script that opens one file and basically writes the contents
> to another file:
>
> ie:
>
> open (IN, file);
> open (OUT, newfile);
> while(<IN>){
> if ( blah blah blah){
> print OUT $_;
> }
> }
>
> if ( something ){
> delete last line printed from the newfile
> }
> close(OUT);
> close(IN);
>
> my problem is that I need to figure out that last if statement. I know it
> is actually like this
>
> if ($count == 5){
> something
> }
>
> I don't know what that something is. I have a cludge workaround, but I was
> wondering if you new a way to erase the last line from a file. Is there a
> UNIX command to strip the last line of a file?
>
> Any help would be greatly appreciated.
>
> Keith L. Miller
> Fathers Matter WebBoard
> http://www.fathersmatter.com
For small files:
open( IN, $file ) || die "$0: cannot open $file: $!\n";
@in = <IN>;
close IN;
@out = ();
for $line ( @in ){
if( blah blah blah ){
push( @out, $line );
}
}
undef @out[ $#out ];
open( OUT, $newfile ) || die "$0: cannot open $newfile: $!\n";
for $line ( @out ){
print OUT $out;
}
close OUT;
__END__
--
Shawn Corey
s @m .c
h a a
a g
w m
n a
--------------8DE369E3703F83EF5021F0DE
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Corey, Shawn
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Shawn Corey
n: Corey;Shawn
org: Corey Consultants
adr: 51 Wessex Road;;;Ottawa;Ontario;K2J 1X3;Canada
email;internet: shawn@magma.ca
title: President
tel;work: 823-4132
tel;home: 823-4132
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------8DE369E3703F83EF5021F0DE--
------------------------------
Date: Thu, 15 Oct 1998 13:38:41 GMT
From: wyndo@cxo.com
Subject: Re: Equivalent of "unload" after "require"?
Message-Id: <704tt2$q8n$1@nnrp1.dejanews.com>
> 1) do $file is like eval `cat $file`, except the former:
> 1.1: searches @INC and updates %INC.
> 1.2: bequeaths an *unrelated* lexical scope on the eval'ed code.
>
> 2) require $file is like do $file, except the former:
> 2.1: checks for redundant loading, skipping already loaded files.
> 2.2: raises an exception on failure to find, compile, or execute $file.
Hmmm, this means do $file isn't going to halt on errors? Darn it. 2.1 is
exactly what I don't want to happen (which is why I need "do $file"). I also
check to see if the file exists so I'm covered in part of 2.2 there, but I
need it to warn if there is an execution error. Hmm... I may need to go with
the other idea suggested to me, "delete $INC{'filename'};" then re-require
it.
Mike.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 14 Oct 1998 12:37:05 +0800
From: webbert <yuhsin@hprc15.sgp.hp.com>
Subject: Extracting from text files - Please help!
Message-Id: <36242A70.2CBDD215@bigfoot.com>
Hello,
Sorry for a newbie question.
I have a huge text file with entries in the form:
***
Record 1
Name: John Smith
Address: Street 123
One Tree Road
Apartment 123
Telephone: 1234567
4783333
Directory: /home/john
***
Record 2
Name: B Smith
Address: Street 456
Two Trees Road
Apartment 456
Telephone: 1234999
4783333
Directory: /home/bsmith
:
:
Has anyone already written a script to extract these information into an
array where the fields would be $record,$name, $address,
$telephone,$directory?
Thank you very much in advance for the help, and would appreciate any
responses to be mailed to hsin@bigfoot.com.
------------------------------
Date: Thu, 15 Oct 1998 00:25:14 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: help! trying to emulate server side includes...
Message-Id: <qv0407.5aj.ln@flash.net>
minus the SPAMSUCKSChris Stanley (cstanley@SPAMSUCKSusit.net) wrote:
: be kind, i'm new. :)
: i am running a script that parses and displays html pages. the only
: problem is, it doesn't emulate server side includes which i use
: heavily. i'm assuming i need to do a s/PATTERN/REPLACEMENT/gie type
: operation, but i can't get the pattern quite right and i'm not sure
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What patterns have you tried?
If you post it, maybe we could fix it.
It's really hard to troubleshoot code that you can't see ;-)
: any assistance would be
: greatly appreciated.
Post your code.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 15 Oct 1998 07:30:00 -0500
From: Tom Turton <tturton@cowboys.anet-dfw.com>
Subject: How to clear "variable" hash on reentry to subroutine?
Message-Id: <3625EAC7.35AC149A@cowboys.anet-dfw.com>
Thought I found a "clever" way to create variable hashes in a script. I
now want to make that script into a subroutine, but I want to make sure
I'm starting with a clean (empty) hash the first time into the sub.
I've figured out the basic step for "hard-coded" hashes, i.e. declaring
them as local variables. My problem is I don't KNOW the names of all
the "variable" hashes I will be creating so I can't predefine them as
local.
Any suggestions, clues would be greatly appreciated. Below is a sample
of the type of code I have.
$equip_id = $record[0]; # a string, e.g. B737
$aequip_id = $air_id."_equip"; # $air_id is a string so $aequip_id
# might be AAL_equip
if (!exists(${aequip_id}_bkwd"}->{$equip_id})) {
${"aequip_id}_fwd"}->{${"${aequip_id}_index"}} = $equip_id;
${"${aequip_id}_index"} += 1;
${"${aequip_id}_bkwd"}->{$equip_id} = ${"${aequip_id}_index"};
$ci = ${"${aequip_id}_index"};
}else{
$ci = ${"${aequip_id}_bkwd"}->{$equip_id};
}
As you can see, I've created hashes of the form:
%AAL_equip_fwd
%AAL_equip_bkwd
And a variable of the form
$AAL_equip_index
and I may have the same for DAL_ , UAL_ , etc, etc, etc
Not knowing in advance which hashes/variables will be created, how can I
specify them as local so the next time I call this subroutine, they
won't already be in existance with possible data stored in them?
Thanks.
---Tom Turton
------------------------------
Date: 15 Oct 1998 15:08:10 +0200
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: How to clear "variable" hash on reentry to subroutine?
Message-Id: <m3d87ut1l1.fsf@joshua.panix.com>
Tom Turton <tturton@cowboys.anet-dfw.com> writes:
> Not knowing in advance which hashes/variables will be created, how can I
> specify them as local so the next time I call this subroutine, they
> won't already be in existance with possible data stored in them?
I won't answer *that* question, because the assumptions you have going
into it are not good. Instead of constructing "soft references" to
several variables by dynamically building the variable names, you
should use a hash of hash references. Example:
$href->{hash_one}->{key_1} = 'foo';
$href->{hash_one}->{key_2} = 'bar';
$href->{hash_two}->{key_1} = 'baz';
Now a single entity--$href--contains all of those hashes and can be
passed around cleanly without fear of namespace collisions. You can
retrieve the hash names with
keys %$href
See the following docs: perlref, perllol, and perldsc.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 15 Oct 1998 09:38:46 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: How to clear "variable" hash on reentry to subroutine?
Message-Id: <704tt6$f2c$1@pilot.njin.net>
Hello -
Tom Turton <tturton@cowboys.anet-dfw.com> writes:
>Thought I found a "clever" way to create variable hashes in a script. I
You mean symbolic references (hashes are already variable(s)).
>now want to make that script into a subroutine, but I want to make sure
>I'm starting with a clean (empty) hash the first time into the sub.
>I've figured out the basic step for "hard-coded" hashes, i.e. declaring
>them as local variables. My problem is I don't KNOW the names of all
>the "variable" hashes I will be creating so I can't predefine them as
>local.
>Any suggestions, clues would be greatly appreciated. Below is a sample
>of the type of code I have.
>$equip_id = $record[0]; # a string, e.g. B737
>$aequip_id = $air_id."_equip"; # $air_id is a string so $aequip_id
> # might be AAL_equip
>if (!exists(${aequip_id}_bkwd"}->{$equip_id})) {
> ${"aequip_id}_fwd"}->{${"${aequip_id}_index"}} = $equip_id;
> ${"${aequip_id}_index"} += 1;
> ${"${aequip_id}_bkwd"}->{$equip_id} = ${"${aequip_id}_index"};
> $ci = ${"${aequip_id}_index"};
>}else{
> $ci = ${"${aequip_id}_bkwd"}->{$equip_id};
>}
This is incredibly hard to read, and ties you in all sorts of knots with
respect to scope.
I'd seriously consider doing something more like this (untested - I'm
not sure what to test):
#!/usr/local/bin/perl -w
# Big hash of all IDS.
my %IDS = ();
# Test case.
$equip_id = "B737";
$air_id = "AAL;
$IDS{$air_id} = {};
# ...
my $a = $IDS{air_id};
$a{fwd}[$a{index}++] = $equip_id;
# ...
Or something. Perhaps create a class for aequip_id. But one way or another,
I'd get rid of the symbolic references and thin out the texture of the
code.
David Black
dblack@pilot.njin.net
P.S. "bkwd"? Anything we need to know before we fly American again?
------------------------------
Date: Thu, 15 Oct 1998 14:38:07 +0200
From: "Rolf Rettinger" <rolf.rettinger@desy.de>
Subject: How to create variables from an array
Message-Id: <704qcm$9t7$1@claire.desy.de>
I have problems to create variables from an array file. I have the array
@AdmGroups = ("mpy_" "zdv_" "mki_" "V02" "etc") and I would like to create
automatically the variables $AdmGroup1, $AdmGroup2, $AdmGroup3, $AdmGroup4,
etc. wherebye the @AdmGroups array varies depending on the user from 1 up to
10 entries.
Can anybody help me how to do that?
Rolf
------------------------------
Date: 15 Oct 1998 15:15:24 +0200
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: How to create variables from an array
Message-Id: <m3btnet18z.fsf@joshua.panix.com>
"Rolf Rettinger" <rolf.rettinger@desy.de> writes:
> I have problems to create variables from an array file. I have the array
> @AdmGroups = ("mpy_" "zdv_" "mki_" "V02" "etc") and I would like to create
> automatically the variables $AdmGroup1, $AdmGroup2, $AdmGroup3, $AdmGroup4,
> etc. wherebye the @AdmGroups array varies depending on the user from 1 up to
> 10 entries.
Why? You've already got that in your example code above, such that
$AdmGroups[0] is 'mpy_', $AdmGroups[1] is 'zdv_', etc. What are you
trying to do that you can't already?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Thu, 15 Oct 1998 08:32:32 -0300
From: Arved Sandstrom <Arved_37@chebucto.ns.ca>
To: "K. Finstad" <kfinstad@unm.edu>
Subject: Re: MacPerl windows
Message-Id: <Pine.GSO.3.95.iB1.0.981015082938.11533B-100000@halifax.chebucto.ns.ca>
This is a question best asked in the MacPerl mailing list. For info, go to
www.perl.com and follow the Macintosh links, or go to www.ptf.com, and
look there.
This same question came up some time ago, was addressed, and some code
examples provided.
If you're using MacPerl, you should be on the mailing list for sure.
Arved.
On Wed, 14 Oct 1998, K. Finstad wrote:
> Does anyone know how to clear a window (e.g., STDOUT) of text?
> I have a very text-intensive project that fills up the window, and on
> slower machines (Classic IIs), the output starts jumping and flickering. I
> can't find any documentation anywhere (books or pods) that describe how to
> do this. One thing I tried is redirecting STDOUT to a new window, which
> works, but then the getc() command I'm using doesn't seem to work with any
> STDIN other than Dev:Console (the MacPerl window), even after a redirect.
>
> Thanks,
> Kraig Finstad
>
>
------------------------------
Date: Thu, 15 Oct 1998 08:20:25 -0500
From: "Marcus J. Foody" <marx@idiom.com>
Subject: newbie at array parsing
Message-Id: <3625F699.141D@idiom.com>
Hello, I'm trying to pull out a specific value(field) inside the
array($line). Is this possible? Below is my output. I'm trying to
pull out the value |709|. If you have a suggestion on this matter it
would be much appreciated.
|BUSINESS UNIT #709|REC BATCH|19980707|709|HPC INVOICE
MEMOS|INVOICE|3|USD|5500.00
Here is my while loop which was give to me by someone that generated the
above output.
while ($line=<FH25>) {
chomp;
$line =~ m,^\|REC FILE(\|[^|]+)\|,;
$prefix = $1 if $1;
if ($line =~ /REC BATCH/) {
$line = $prefix . $line;
print $line;
}
}
thanks again
marcus
------------------------------
Date: Thu, 15 Oct 1998 10:34:49 GMT
From: wongksp@netvigator.com (Wong Kin Sang)
Subject: One question on writing Perl module
Message-Id: <3625ccfd.22639523@news.netvigator.com>
Hi all of you,
Thanks for your help last time on writing Perl script. Now I'd like to
extract some common functions on some Perl scripts written by me.
However when I try to run the following script to use the module
written. It can't work. Here is the listing of the module and the
script :
--------------------------- Listing of the script---------------------
use utility;
$str="c:\opt\abc\bin";
utility::SetPath($str);
---------------------------------End ---------------------------------
--------------Start of the module listing-----------------------------
package utility;
use Win32::Registry;
require Exporter;
@ISA = qw(Exporter);
# Utility functions for scripts doing installation
@EXPORT = qw(SetPath );
sub utility::SetPath
{
local ($add_path) = shift;
my $Register = "System\\CurrentControlSet\\Control\\Session
Manager\\Environment
";
my $hkey, $value, $RegType, $RegKey, $RegValue, $path_val,
$newpath_val;
my %values;
$HKEY_LOCAL_MACHINE->Open($Register,$hkey) || print $!;
$hkey->GetValues(\%values);
foreach $value (keys(%values))
{
$RegType =$values{$value}->[1];
$RegValue =$values{$value}->[2];
$RegKey =$values{$value}->[0];
if ($RegKey eq "Path")
{
$path_val = $RegValue;
}
}
open (SOC,"c:/opt/NTconfig/cluster");
while (<SOC>)
{
if(/$ENV{COMPUTERNAME}/)
{
($machine, $SOC, $stuff1, $stuff2, $stuff3)
= split(" ",$_);
}
}
close(SOC);
open (VERNO,"c:/opt/NTconfig/$SOC/nt_release");
while (<VERNO>)
{
if(/$pkgname/)
{
($name, $ver_no) = split(" ",$_);
}
}
close(VERNO);
$newpath_val = $path_val.$add_path;
undef $garbage;
$hkey->SetValueEx("Path", $garbage,REG_SZ, $newpath_val);
$hkey->RegFlushKey();
$hkey->Close();
}
1;
-----------------------------End--------------------------------------------
Please suggest any error\modification needed. Once again thanks!!
Patrick
------------------------------
Date: Thu, 15 Oct 1998 08:39:41 -0300
From: Arved Sandstrom <Arved_37@chebucto.ns.ca>
Subject: Re: One question on writing Perl module
Message-Id: <Pine.GSO.3.95.iB1.0.981015083721.11533C-100000@halifax.chebucto.ns.ca>
In your package 'utility', for one, just name the subroutine SetPath, not
utility::SetPath. That's what the "package SomePackage" statement is for,
after all.
Can't comment on the rest of the code, except to say that it reinforces my
determination to treat myself with dignity and hence avoid Windows... :-)
Arved (UNIX and MacOS)
------------------------------
Date: Wed, 14 Oct 1998 18:27:45 +0100
From: Michael Renshaw <michaelr@lndn.tensor.pgs.com>
Subject: Re: perl compile problem
Message-Id: <3624DF11.68DD@lndn.tensor.pgs.com>
Does anyone know how to set the subject of an email when
opening and writing data to a file via a pipe in perl ?
cheers
Mike
michaelr@lndn.tensor.pgs.com
------------------------------
Date: Thu, 15 Oct 1998 08:48:12 -0400
From: mark_chunn@hp.com
Subject: Printing in Landscape
Message-Id: <3625EF0C.AF30F811@hp.com>
To anyone who may know:
Someone mentioned to me that you could programatical change to print in
landscape mode from a Netscape window. My web-site is written in
HTML/perl.
Any thoughts?
------------------------------
Date: Thu, 15 Oct 1998 11:09:52 GMT
From: levt4072@my-dejanews.com
Subject: Problem creating chart
Message-Id: <704l61$g3n$1@nnrp1.dejanews.com>
Hello!
I try to run example provided in the source distrubution of the graph.pm
module. Reference to this module found on the www.perl.com site:
#!/usr/bin/perl
# Graph.pm example File
# Please see documentation for more info
use Graph;
$Graph::debug = 1;
$graph = new Graph;
srand();
for ($i=0; $i<30; $i++) {
$num = int( rand()*20000 + 10000);
if (($i % 5) == 0) {
$label = "Sun";
}
else {
$label="";
}
$graph->data($num,$label);
}
$graph->title("Daily Web Site Hits");
$graph->subtitle("Content pages only");
$graph->keys_label("Day of the Week");
$graph->values_label("Hits");
$graph->value_min(0);
$graph->value_max(35000);
$graph->value_labels("10000,20000,30000");
$graph->background_image("bg.gif");
print $graph->output("d:\\graph\\example.gif");
It fails on the last step with the following output:
Setting title to Daily Web Site Hits
Setting subtitle to Content pages only
Setting keys_label to Day of the Week
Setting values_label to Hits
Setting value_min to 0
Setting value_max to 35000
Setting value_labels to 10000,20000,30000
Setting background_image to bg.gif
Minimum Data value: 10089
Maximum Data value: 29837
Minimum Y value set to 0
Maximum Y value set to 35000
Image Created: 928 x 366
Colors Allocated
Usage: GD::Image::gif(image) at Graph.pm line 856.
I'm running perl V5.004_02 on NT4.0
If somebody encountered the same problem I need your help!
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 15 Oct 1998 14:01:40 +0200
From: Dmitri Levitin <dmitri@sw-systemekarlhickl.de>
Subject: problem with "use lib"
Message-Id: <3625E423.ACFC6B8A@sw-systemekarlhickl.de>
Hi,
I have a problem with pragma use lib.
I want to make my own module library in /u/lib/perl but i would like to
have it in my script rather so:
my $MY_LIB = "/u/lib/perl";
use lib $MY_LIB;
than so:
use lib "/u/lib/perl";
In case 1 the new path don't appears in @INC and thus my module library
can not be found!
In case 2 is everything OK.
How can I use variables at that place?
Thanks.
Answer please to d_levitin@gmx.net
------------------------------
Date: 15 Oct 1998 15:01:45 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: Dmitri Levitin <dmitri@sw-systemekarlhickl.de>
Subject: Re: problem with "use lib"
Message-Id: <m3g1cqt1vq.fsf@joshua.panix.com>
Dmitri Levitin <dmitri@sw-systemekarlhickl.de> writes:
> my $MY_LIB = "/u/lib/perl";
This happens at runtime.
> use lib $MY_LIB;
This happens at compile time.
Solution:
BEGIN {
my $MY_LIB = "/u/lib/perl";
use lib $MY_LIB;
}
Suggestions: Always use the -w switch. Read perlmod for discussion
of BEGIN and END blocks. Read the lib docs.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 15 Oct 1998 09:43:58 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: problem with "use lib"
Message-Id: <704u6u$eut$1@monet.op.net>
In article <m3g1cqt1vq.fsf@joshua.panix.com>,
Jonathan Feinberg <jdf@pobox.com> wrote:
>Solution:
>
> BEGIN {
> my $MY_LIB = "/u/lib/perl";
> use lib $MY_LIB;
> }
Nope! At compile time, Perl goes to execute the BEGIN block. To
execute the BEGIN block, it must first compile it. Perl compiles the
BEGIN block, it executes the use at compile time. Then it executes
the BEGIN block and sets $MY_LIB, too late. Then it executes the rest
of the program.
Try this instead:
{ my $MY_LIB;
BEGIN { $MY_LIB = "/u/lib/perl" }
use lib $MY_LIB;
}
> Suggestions: Always use the -w switch. Read perlmod for discussion
>of BEGIN and END blocks. Read the lib docs.
Tricky, isn't it?
------------------------------
Date: 15 Oct 1998 13:14:23 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: problem with "use lib"
Message-Id: <704sff$erb$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jonathan Feinberg <jdf@pobox.com> writes:
:> my $MY_LIB = "/u/lib/perl";
:This happens at runtime.
:> use lib $MY_LIB;
:This happens at compile time.
:Solution:
: BEGIN {
: my $MY_LIB = "/u/lib/perl";
: use lib $MY_LIB;
: }
In what fashion do you think that is a solution? The use still happens
before the assignment does. And you can't just write:
BEGIN { my $MY_LIB = "/u/lib/perl" } # WRONG
use lib $MY_LIB;
Or the lexical will evaporate before you can use it.
You could do this:
{
my $MY_LIB;
BEGIN { $MY_LIB = "/u/lib/perl" }
use lib $MY_LIB;
}
Or just:
BEGIN { $MY_LIB = "/u/lib/perl" }
use lib $MY_LIB;
--tom
--
With a PC, I always felt limited by the software available. On Unix, I am
limited by my knowledge. --Peter J. Schoenster <pschon@baste.magibox.net>
------------------------------
Date: 15 Oct 1998 12:31:34 GMT
From: klassa@aur.alcatel.com (John Klassa)
Subject: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <704pv6$el8$1@aurwww.aur.alcatel.com>
The Raleigh.pm perl mongers group has registered... I'm in the process of
gauging the level of interest in such a thing, so that I can figure out
where to hold the first meeting.
If you're interested, send me some mail (klassa@ipass.net)... If you
know of a suitable place for the first meeting (i.e. someplace readily
accessible, and more importantly free :-)), *please* let me know. I'm at a
loss for where to have this thing...
Thanks!
John
--
John Klassa / Alcatel / Raleigh, NC, USA / $perl_monger{Raleigh}[0] / <><
------------------------------
Date: Thu, 15 Oct 1998 13:51:49 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: references to package subroutines and SIG
Message-Id: <F0vFuD.2sK@world.std.com>
Marc Bernstein <mb@cup.hp.com> writes:
>My appologies! Jonathan's suggestion DOES work.
>> Jonathan Feinberg wrote:
>> >
>> > $SIG{WHATEVER} = sub { $obj->method(); };
If you ever have problems with this again, one thing to look for is to
be sure that $obj is a lexically local variable (a my()'d variable)
and not a package (global) variable.
--
Andrew Langmead
------------------------------
Date: Thu, 15 Oct 1998 12:30:14 GMT
From: b_pillai@hotmail.com
Subject: Regarding FileHandle
Message-Id: <704psm$lt7$1@nnrp1.dejanews.com>
Hi,
I am working on Perl Extenstions of NT. I have a perl script
that does FileHandle::new_tmpfile(). The handle returned is
passed as one of the arguments to a function of a dll that
this perl attaches to. Whenenver this handle is accessed in the
dll it gives error and comes out. I am using C-runtime functions
in the dll.
First of all i would like to ask is : does FileHandle::new_tmpfile()
returns a Handle or file pointer. If handle then how do i get
file pointer. If file pointer where am i going wrong.
This is works fine on UNIX. I have 5.004_02 perl version
Can somebody please help me.
Thanks in advance
Biju
b_pillai@hotmail.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 13 Oct 1998 15:03:24 -0700
From: Marc Bernstein <mb@cup.hp.com>
To: markj@cup.hp.com
Subject: Saw your reply to a similar perl question. I wonder...
Message-Id: <3623CE2C.AD7EA3BC@cup.hp.com>
if you would mind taking this one. I understand if you'ld rather not.
Thanks in advance.
I am trying to create a Daemon process. When I execute:
............................................ CODE segment
................................................
...
Daemon::forkme(/usr/eclipse/lib/perl/Daemon.pm:59):
59: close STDIN;
DB<1>
Daemon::forkme(/usr/eclipse/lib/perl/Daemon.pm:60):
60: close STDOUT;
DB<1>
Daemon::forkme(/usr/eclipse/lib/perl/Daemon.pm:61):
61: close STDERR;
DB<1>
Daemon::forkme(/usr/eclipse/lib/perl/Daemon.pm:64):
64: if ($pid = fork()){
DB<1> Daemon::forkme(/usr/eclipse/lib/perl/Daemon.pm:68):
70: return $! if ($! =~ /Not owner/);
Forked, but do not know how to change a TTY.
Define $DB::fork_TTY or get_fork_TTY().
DB<1> Daemon::forkme(/usr/eclipse/lib/perl/Daemon.pm:68):
68: exit 0; # Parent exits
...
...............................................................................................................................
I wonder about the messages I get above:
DB<1>
Daemon::forkme(/usr/eclipse/lib/perl/Daemon.pm:70):
70: return $! if ($! =~ /Not owner/);
Forked, but do not know how to change a TTY.
Define $DB::fork_TTY or get_fork_TTY().
(Daemon is a package I tried to put together to make this easy...)
When I try to execute the program outside of the debugger it exits with
no message to stderr or stdout (since I close them?) - and doesn't fork
the child.
Unfortunately I can find precious little reference to this subject in
either,
Perl 5 camel book, Perl Module Reference or Advanced Perl Programming.
Thanks again,
Marc Bernstein
------------------------------
Date: Thu, 15 Oct 1998 08:24:59 -0600
From: rlb@intrinsix.ca (Lee Brandson)
Subject: Re: Sorry
Message-Id: <rlb-1510980825150001@204.112.166.151>
In article <ona207.tnf.ln@flash.net>, tadmc@flash.net (Tad McClellan) wrote:
> Robin Bank (rbank@csf.edu) wrote:
>
> : Hey all... Sorry about my last posts. I'll think of questions that aren't
> : so stupid
>
>
> The problem is not that the questions were stupid, but rather
> that they have already been adequately answered (in the FAQ,
> or in recent threads accessable via a Usenet archive such as
> www.dejanews.com).
>
>
> New stuff, even stupid new stuff, is welcomed.
As an occasional watcher of this ng and its predecessor for some two years
now, I would like to ask whether it is strictly necessary to be as rude as
possible when answering (or not answering, as the case may be) a question?
Is this what it takes to be "in the club?" Do you enjoy the unending long
threads of justifications for such rudeness?
Q: Why do universities have both libraries and instructors?
A: Because it is not always sufficient that a given piece of information
be archived somewhere.
Lee Brandson
------------------------------
Date: Thu, 15 Oct 1998 13:42:18 -0100
From: "A. van de Repe" <arp.s@tip.nl>
Subject: tag
Message-Id: <362609CA.4204@tip.nl>
I cant make it work.
Suppose I have the string
"<a><b>ccc</a></b><a><b>ddd</a></b>
I want to isolate the ccc and ddd part against a given list of tags
with one regex.
any help eppreciated
anton
------------------------------
Date: Thu, 15 Oct 1998 13:52:07 -0100
From: "A. van de Repe" <arp.s@tip.nl>
Subject: tag
Message-Id: <36260C17.1AF7@tip.nl>
I cant make it work.
Suppose I have the string
"<a><b>ccc</a></b><a><b>ddd</a></b>
I want to isolate the ccc and ddd part against a given list of tags
with one regex.
any help eppreciated
anton
------------------------------
Date: Thu, 15 Oct 1998 09:19:37 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: tag
Message-Id: <MPG.108fc0767132f0e99896d9@news.scescape.net>
In article <<36260C17.1AF7@tip.nl>>, arp.s@tip.nl (A. van de Repe)
pounded the following:
=> I cant make it work.
Can't make what work?
=> Suppose I have the string
=> "<a><b>ccc</a></b><a><b>ddd</a></b>
=>
=> I want to isolate the ccc and ddd part against a given list of tags
=> with one regex.
=>
Ok! Sounds like you have a plan! :)
Go at it, and let us know what you get!
Next time post what you've tried, what it's doing, and what you think
it should be doing. We are here to help, but C<use Mind::Reader;>
still doesn't work just like we'd like.
'Course it looks like your attempting to parse HTML. There have been
many discussions on why it isn't a good idea to use a regex to do
this. See DejaNews for more info.
=> any help eppreciated
Just let us know what you've tried, and we'll point you in the right
direction.
=> anton
--Matthew
------------------------------
Date: 15 Oct 1998 09:33:57 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: What is overwriting my variable?
Message-Id: <704tk5$erp$1@monet.op.net>
In article <362575C3.D13CB804@mediaone.net>,
Michael D. Schleif <mds-resource@mediaone.net> wrote:
>sub parse {
># $_ = shift;
> my $specific;
> for (@_) {
When you write `for', the loop index vaariable, $_ in this case, is
aliased to the array element. If you modify $_, you change the array.
This is documented under `for'.
Then inside the loop, you call a subroutine:
> $specific = "AIX " . wruntask() . " ";
And inside the subroutine you do indeed modify $_:
>sub wruntask {
> while (<WRUNTASK>) {
> chomp;
Simplest fix: Inside of `wruntask', add
local $_;
then the old value of $_ will be restored when control returns from wruntask.
Not quite as simple fix: use
my $i;
for $i (@_) {
...
}
in `parse'; then the $i is private to `parse'.
------------------------------
Date: Thu, 15 Oct 1998 13:49:08 +0100
From: Matt Sergeant <msergeant@ndirect.co.uk_NOSPAM>
Subject: Re: Win32::OLE and Netscape
Message-Id: <3625EF44.2A13266B@ndirect.co.uk_NOSPAM>
Francois Besnier wrote:
[snip]
> $web->Read($content, $contentlen)
> or die "Could not READ URL: $! \n";
>
> print "content=$content\n";
>
> $web->Close();
>
> This script returns:
>
> contentlen=9120
> Could not READ URL:
>
> It seems that "$web->Read($content, $contentlen);" does not work.
>
> Why did i get this error?
Because you didn't read the docs. Read returns 0 if there is no data
currently. It looks like you have to loop around while
(!$web->IsFinished()) {} and read the data. Read returns 0 if there is
no data _currently_. There may be more later.
--
<Matt/>
| Fastnet Software Ltd | Perl in Active Server Pages |
| Perl Consultancy, Web Development | Database Design | XML |
| http://come.to/fastnet | Information Consolidation |
------------------------------
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 3980
**************************************