[19717] in Perl-Users-Digest
Perl-Users Digest, Issue: 1912 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 11 11:05:32 2001
Date: Thu, 11 Oct 2001 08:05:10 -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: <1002812710-v10-i1912@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 11 Oct 2001 Volume: 10 Number: 1912
Today's topics:
Apache Server kennt kein Perl!!! <Markusdaa@yahoo.de>
Re: Apache Server kennt kein Perl!!! <Thomas@Baetzler.de>
Bitwise And <caughran@chem.uga.edu>
DBI:DBD <icon@cgocable.net>
Re: DOS Filename > 8.3 <bart.lateur@skynet.be>
Re: executing batch file from script <tsee@gmx.net>
Finding out about your Perl <lmoran@wtsg.com>
Re: Finding out about your Perl <tsee@gmx.net>
Re: Finding out about your Perl (Anno Siegel)
Re: Finding out about your Perl <lmoran@wtsg.com>
Re: Finding out about your Perl <Thomas@Baetzler.de>
Getting parameters <Anthony.Heuveline@wanadoo.fr>
Re: Getting parameters <Thomas@Baetzler.de>
Re: Hashes news@roaima.demon.co.uk
Re: Hashes <s.warhurst@rl.ac.uk>
Re: Hashes (Garry Williams)
Re: How to run perl under bash not sh <simon.andrews@bbsrc.ac.uk>
Re: Pattern Matching <bart.lateur@skynet.be>
Re: Pattern Matching <bart.lateur@skynet.be>
Re: port scanner (Anno Siegel)
Re: Question about tab delimeted text file from Excel <s.warhurst@rl.ac.uk>
Re: Regular Expressions <bart.lateur@skynet.be>
Re: Regular Expressions (Anno Siegel)
Re: Regular Expressions <bart.lateur@skynet.be>
Re: split into filename and extension (need help before <bart.lateur@skynet.be>
two-dimensional arrays, lists, whatever (A. Garza)
Re: two-dimensional arrays, lists, whatever <Thomas@Baetzler.de>
Re: two-dimensional arrays, lists, whatever (Anno Siegel)
Re: What is faster?? <anordae@pisem.net>
Re: zipping files? <bart.lateur@skynet.be>
Re: zipping files? <JPFauvelle@Colt-Telecom.fr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 11 Oct 2001 15:46:20 +0200
From: "Markus D." <Markusdaa@yahoo.de>
Subject: Apache Server kennt kein Perl!!!
Message-Id: <9q47re$lrtbo$1@ID-86075.news.dfncis.de>
Servus,
ich versuche schon seit Anfang der Woche meinem funktionierenden Apache
1.3.20 das verarbeiten von Perl Scripten beizubringen. Gibt es da ne
richtige erklärung im Netz oder kann mir das hier jemand erklären???
Wie bringe ich Apache dazu, auf .pl und .cgi - Endungen richtig zu
reagieren?
Im Moment bietet er mir die Dateien immer zum Download an, wenn ich sie aus
htdocs aufrufe.
Wenn ich sie aus cgi-bin aufrufe, findet er die Seiten garnicht!!!
Und wenn ich nur das cgi-bin aufrufe, zeigt er einen 403er Fehler an, der
mir sagt, ich hätte keine berechtigung, diesen Ordner aufzurufen!!!
Bitte um Hilfe, ich habe bisher nur mit PHP gearbeitet, da funktioniert
alles Bestens.
Danke
Markus
------------------------------
Date: Thu, 11 Oct 2001 15:52:25 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Apache Server kennt kein Perl!!!
Message-Id: <vr8bstkgupl4rratuem32pvb5u1epkpnpl@4ax.com>
On Thu, 11 Oct 2001, "Markus D." <Markusdaa@yahoo.de> wrote:
>Servus,
>
>ich versuche schon seit Anfang der Woche meinem funktionierenden Apache
>1.3.20 das verarbeiten von Perl Scripten beizubringen. Gibt es da ne
[...]
Please do not crosspost unless it makes sense to do so.
If you have to crosspost, do set an appropriate followup-to: header.
Please select an approriate group to post to. Your Apache configuration
problems have absolutely nothing to do with Perl.
Please do not post German to an international newsgroup.
Tsk,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Thu, 11 Oct 2001 11:02:59 -0400
From: Joel Caughran <caughran@chem.uga.edu>
Subject: Bitwise And
Message-Id: <3BC5B4A3.9E532D2A@chem.uga.edu>
I must not understand the results of the & operand. As I understand it,
6 & 2 would be 2 and 12 & 6 would be 4. However, if I try
perl -e "if (12 & 6 > 0) { print 'hello' }"
it doesn't print anything. What am I missing?
Joel Caughran
--
Joel A Caughran caughran@chem.uga.edu
Chemistry Learning Center caughran@uga.edu
Department of Chemistry
University of Georgia (706) 542-1906 voice
Athens, Georgia 30602-2556 (706) 542-9454 fax
------------------------------
Date: Thu, 11 Oct 2001 13:44:21 GMT
From: "icon" <icon@cgocable.net>
Subject: DBI:DBD
Message-Id: <Vmhx7.56024$0%.8844203@news1.busy1.on.home.com>
Hello ,
Please if you know the answer let me know what is wrong. I am losing my mind
over this.
I've had major hard time trying to compile DBI into my perl 5. Finally got
it and not it's time to get DBD for oracle working so I can run queries from
perl scripts.
I tried to compile DBD but it bitched about whole bunch of libraries which i
fixed by instaling them off of oracle CD. Now it comes up wiht the followinf
error. I'll paste the whole thing so you can see what has happened. The
error is on the bottom.
Thank you very much.
# /usr/local/bin/make
mkdir blib
mkdir blib/lib
mkdir blib/lib/DBD
mkdir blib/arch
mkdir blib/arch/auto
mkdir blib/arch/auto/DBD
mkdir blib/arch/auto/DBD/Oracle
mkdir blib/lib/auto
mkdir blib/lib/auto/DBD
mkdir blib/lib/auto/DBD/Oracle
mkdir blib/man1
mkdir blib/man3
cp oraperl.ph blib/lib/oraperl.ph
cp Oracle.pm blib/lib/DBD/Oracle.pm
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm
cp dbdimp.h blib/arch/auto/DBD/Oracle/dbdimp.h
cp ocitrace.h blib/arch/auto/DBD/Oracle/ocitrace.h
cp Oracle.h blib/arch/auto/DBD/Oracle/Oracle.h
cp Oraperl.pm blib/lib/Oraperl.pm
/usr/local/bin/perl -p -e "s/~DRIVER~/Oracle/g" <
/usr/local/etc/CPAN/lib/perl5/site_perl/5.6.0/sun4-solaris-multi/auto/DBI/Dr
iver.xst > Oracle.xsi
/usr/local/bin/perl -I/usr/local/lib/perl5/5.6.0/sun4-solaris-multi -I/usr/l
ocal/lib/perl5/5.6.0 /usr/local/lib/perl5/5.6.0/ExtUtils/xsubpp -typemap
/usr/local/lib/perl5/5.6.0/ExtUtils/typemap Oracle.xs > Oracle.xsc && mv
Oracle.xsc Oracle.c
/usr/local/bin/gcc -c -I/opt/oracle/app/oracle/product/8.0.5/rdbms/demo -I/o
pt/oracle/app/oracle/product/8.0.5/rdbms/public -I/opt/oracle/app/oracle/pro
duct/8.0.5/plsql/public -I/opt/oracle/app/oracle/product/8.0.5/network/publi
c -I/opt/oracle/app/oracle/product/8.0.5/rdbms/demo -I/opt/oracle/app/oracle
/product/8.0.5/rdbms/demo -I/usr/local/etc/CPAN/lib/perl5/site_perl/5.6.0/su
n4-solaris-multi/auto/DBI -fno-strict-aliasing -I/usr/local/include -D_LARGE
FILE_SOURCE -D_FILE_OFFSET_BITS=64 -O -DVERSION=\"1.12\" -DXS_VERSION=\"
1.12\" -fPIC -I/usr/local/lib/perl5/5.6.0/sun4-solaris-multi/CORE Oracle.c
/usr/local/bin/gcc -c -I/opt/oracle/app/oracle/product/8.0.5/rdbms/demo -I/o
pt/oracle/app/oracle/product/8.0.5/rdbms/public -I/opt/oracle/app/oracle/pro
duct/8.0.5/plsql/public -I/opt/oracle/app/oracle/product/8.0.5/network/publi
c -I/opt/oracle/app/oracle/product/8.0.5/rdbms/demo -I/opt/oracle/app/oracle
/product/8.0.5/rdbms/demo -I/usr/local/etc/CPAN/lib/perl5/site_perl/5.6.0/su
n4-solaris-multi/auto/DBI -fno-strict-aliasing -I/usr/local/include -D_LARGE
FILE_SOURCE -D_FILE_OFFSET_BITS=64 -O -DVERSION=\"1.12\" -DXS_VERSION=\"
1.12\" -fPIC -I/usr/local/lib/perl5/5.6.0/sun4-solaris-multi/CORE dbdimp.c
/usr/local/bin/gcc -c -I/opt/oracle/app/oracle/product/8.0.5/rdbms/demo -I/o
pt/oracle/app/oracle/product/8.0.5/rdbms/public -I/opt/oracle/app/oracle/pro
duct/8.0.5/plsql/public -I/opt/oracle/app/oracle/product/8.0.5/network/publi
c -I/opt/oracle/app/oracle/product/8.0.5/rdbms/demo -I/opt/oracle/app/oracle
/product/8.0.5/rdbms/demo -I/usr/local/etc/CPAN/lib/perl5/site_perl/5.6.0/su
n4-solaris-multi/auto/DBI -fno-strict-aliasing -I/usr/local/include -D_LARGE
FILE_SOURCE -D_FILE_OFFSET_BITS=64 -O -DVERSION=\"1.12\" -DXS_VERSION=\"
1.12\" -fPIC -I/usr/local/lib/perl5/5.6.0/sun4-solaris-multi/CORE oci7.c
/usr/local/bin/gcc -c -I/opt/oracle/app/oracle/product/8.0.5/rdbms/demo -I/o
pt/oracle/app/oracle/product/8.0.5/rdbms/public -I/opt/oracle/app/oracle/pro
duct/8.0.5/plsql/public -I/opt/oracle/app/oracle/product/8.0.5/network/publi
c -I/opt/oracle/app/oracle/product/8.0.5/rdbms/demo -I/opt/oracle/app/oracle
/product/8.0.5/rdbms/demo -I/usr/local/etc/CPAN/lib/perl5/site_perl/5.6.0/su
n4-solaris-multi/auto/DBI -fno-strict-aliasing -I/usr/local/include -D_LARGE
FILE_SOURCE -D_FILE_OFFSET_BITS=64 -O -DVERSION=\"1.12\" -DXS_VERSION=\"
1.12\" -fPIC -I/usr/local/lib/perl5/5.6.0/sun4-solaris-multi/CORE oci8.c
oci8.c: In function `oci_hdtype_name':
oci8.c:100: `OCI_HTYPE_SUBSCRIPTION' undeclared (first use in this function)
oci8.c:100: (Each undeclared identifier is reported only once
oci8.c:100: for each function it appears in.)
oci8.c:109: `OCI_DTYPE_LOCATOR' undeclared (first use in this function)
make: *** [oci8.o] Error 1
------------------------------
Date: Thu, 11 Oct 2001 13:57:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: DOS Filename > 8.3
Message-Id: <ol8bstkt95jlserrdpn79ahvabn69nid8b@4ax.com>
Linda Turner wrote:
>With a lot of help from this newsgroup, I have written a script to
>sweep through a directory and updates some modules in place. However,
>it won't recognize Win NT files with names greater than the
>traditional 8.3 format. Can someone tell me how I can get them to
>recognize them?
I don't understand. I use long file names on Win98 all the time, without
having to take spacial care if it.
Are you sure you describe the problem properly? Because this start
directory doen't look right:
my $start_dir = 'C\\SCRIPTS';
It contains no colon.
If your problem is that you attempt to "drop" a directory on the script
(perhaps as a batch file), and all you see is the 8.3 compatible file
path, then you'll be glad to know that convertors between short and long
filepaths are built into Win32 perl: look up the docs for the Win32
module, and in paricular, the function GetLongPathName:
use Win32;
my $start_dir = Win32::GetLongPathName(shift);
--
Bart.
------------------------------
Date: Thu, 11 Oct 2001 15:14:10 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: executing batch file from script
Message-Id: <9q45t2$q6h$04$1@news.t-online.com>
"Jon Ericson" <Jon.Ericson@jpl.nasa.gov> schrieb im Newsbeitrag
news:86y9mjoc76.fsf@jon_ericson.jpl.nasa.gov...
[snip]
I wrote:
> > Was the value really correct? Always use / for directories within Perl,
even
> > under Windows. (Dunno about MacOS, though.)
> Actually either works in Windows. The reason to use a slash rather
> than a backslash is to avoid confusion and ugliness. I can't think of
> a reason to use dot concatenation rather than string interpolation,
> however.
You're right on the slashes, I happened to read the part of the docs that
mention it later that night. I would still strongly suggest the use of /,
because it - just as you said - avoids confusion. Then, it is (almost:
MacOS) platform independent, too!
The other issue (concatenation) is mostly preference, but it seems more
easily readable to me and it definetly helps avoiding some newbie errors
that easily go unnoticed. (Like "$varText" if you really want "${var}Text")
My last point is that ' is usually preferred over ", but I guess that's
mostly preference, too.
The concatenation is *slightly* faster, but unless you do millions of such
operations you're not going to notice these few percent.
Steffen
------------------------------
Date: Thu, 11 Oct 2001 09:40:17 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Finding out about your Perl
Message-Id: <648bstgg8uaonqfu1qttbgj9d87ugufe3u@4ax.com>
I know about perl -v and perl -V
But if I go to a different machine how can i quickly figure out which
modules are loaded?
I could perldoc Some::Thing but then I would have to know what I am
looking for.
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Thu, 11 Oct 2001 15:45:02 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Finding out about your Perl
Message-Id: <9q47mt$bk4$07$1@news.t-online.com>
"Lou Moran" <lmoran@wtsg.com> schrieb im Newsbeitrag
news:648bstgg8uaonqfu1qttbgj9d87ugufe3u@4ax.com...
> I know about perl -v and perl -V
>
> But if I go to a different machine how can i quickly figure out which
> modules are loaded?
>
> I could perldoc Some::Thing but then I would have to know what I am
> looking for.
>
> --
> TMTOWTDI: My way tends to be wrong...
> lmoran@wtsg.com
search google for something like 'how can I find out which modules are
installed.'
Steffen
------------------------------
Date: 11 Oct 2001 13:57:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Finding out about your Perl
Message-Id: <9q48gu$amf$1@mamenchi.zrz.TU-Berlin.DE>
According to Lou Moran <lmoran@wtsg.com>:
> I know about perl -v and perl -V
>
> But if I go to a different machine how can i quickly figure out which
> modules are loaded?
>
> I could perldoc Some::Thing but then I would have to know what I am
> looking for.
"perldoc perllocal" is the quick way (as far as "quick" and "perldoc"
are compatible). Otherwise, "perl -V" gives you the local @INC, and
you can take it from there.
Anno
------------------------------
Date: Thu, 11 Oct 2001 10:09:46 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Finding out about your Perl
Message-Id: <s0abst8l9lfe62e61djl3ek2tgelna6acc@4ax.com>
On 11 Oct 2001 13:57:50 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote wonderful things about sparkplugs:
>According to Lou Moran <lmoran@wtsg.com>:
>> I know about perl -v and perl -V
>>
>> But if I go to a different machine how can i quickly figure out which
>> modules are loaded?
>>
>> I could perldoc Some::Thing but then I would have to know what I am
>> looking for.
>
>"perldoc perllocal" is the quick way (as far as "quick" and "perldoc"
>are compatible). Otherwise, "perl -V" gives you the local @INC, and
>you can take it from there.
perfect!
>
>Anno
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Thu, 11 Oct 2001 16:27:27 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Finding out about your Perl
Message-Id: <9labst4e5bj9pm6vpbmsd2c885v6keklsh@4ax.com>
On Thu, 11 Oct 2001 09:40:17 -0400, Lou Moran <lmoran@wtsg.com> wrote:
>But if I go to a different machine how can i quickly figure out which
>modules are loaded?
s/loaded/installed/;
On a Unix box, run perl -MCPAN -eshell. If you're not root, copy the
global CPAN config file to where the program tell you locall, and edit
that file to change all relevant paths to your local CPAN directory.
Once you're in the CPAN shell, type "autobundle". This will write first
connect to CPAN to retrieve a list of currently available modules. It
will then print out a list of all of your locally installed modules and
their versions, aswell as the latest version on CPAN and where it can be
found in the authors subtree. It will also create a Snapshot file that
can be used to update another host to the same set of modules.
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Thu, 11 Oct 2001 16:27:08 +0200
From: "Anthony Heuveline" <Anthony.Heuveline@wanadoo.fr>
Subject: Getting parameters
Message-Id: <9q4a75$jq4$1@wanadoo.fr>
Hi,
My problem is the following:
I have a multipart form in a html page which allows the user to upload a
file. When the user clicks on the submit button, I want to display a
"Loading" message so that the action of the first form (upload dialog) is
set to "loading.pl". In loading.pl, I get the path entered in the first page
(upload dialog) and I use the following meta tag to go to the upload script:
print "<meta http-equiv='refresh' content='0; URL=upload.pl'>";
The problem is that I don't manage to get the upload path again in
upload.pl, although I have created a hidden field in loading.pl, which value
is set to the path.
How can I get this path using this method?
Thanks.
Anthony.
------------------------------
Date: Thu, 11 Oct 2001 16:31:19 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Getting parameters
Message-Id: <d6bbstsbj35k8ejvboid3qt85e36khi1da@4ax.com>
On Thu, 11 Oct 2001, "Anthony Heuveline" <Anthony.Heuveline@wanadoo.fr>
wrote:
>I have a multipart form in a html page which allows the user to upload a
>file. When the user clicks on the submit button, I want to display a
>"Loading" message so that the action of the first form (upload dialog) is
>set to "loading.pl". In loading.pl, I get the path entered in the first page
>(upload dialog) and I use the following meta tag to go to the upload script:
>
>print "<meta http-equiv='refresh' content='0; URL=upload.pl'>";
Try doing it the other way 'round, i.e. have the upload script send the
redirect header to the "loading" page. After you have done that, you can
still process the file upload.
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: 11 Oct 2001 14:29:32 GMT
From: news@roaima.demon.co.uk
Subject: Re: Hashes
Message-Id: <3bc59ebc@news.netserv.net>
S Warhurst <s.warhurst@rl.ac.uk> wrote:
> If I have the code:
> $line = "aaaaaa.bbbbbb.com ## 56";
> @tmp = split / ## /,$line;
> $domains{@tmp[0]} = @tmp[1];
> when I try and print it out with the line:
> print "$domains{aaaaaa\.bbbbbb\.com}";
> it doesn't work..
Don't just say "it doesn't work". Explain /why/ you think it doesn't
work. We're not always mind readers.
Anyway, on to solving the problem.
In my version of perl (5.005_03) it complains about the syntax on that
print line, suggesting that there's something wrong with it. (There is.)
So, why should you want to escape the dots? They're part of the literal
key and they're not in an RE, so don't do it.
Once you've got the syntax error sorted you'll see it still doesn't do
what I think you expect (although it is working correctly). You need to
quote the key since it doesn't contain pure alphanumerics, viz
print "$domains{'aaaaaa.bbbbbb.com'}";
Chris
------------------------------
Date: Thu, 11 Oct 2001 14:26:21 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: Hashes
Message-Id: <9q46lu$13pq@newton.cc.rl.ac.uk>
"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
> } $domains{@tmp[0]} = @tmp[1];
> ^ ^
> These should be $.
I've always used @ with arrays if they only have one column, and $ if it is
a table array. So this is wrong, is it? I've never knowingly had any
problems with @array[0] style syntax before.
> } print "$domains{aaaaaa\.bbbbbb\.com}";
>
> You don't need to put backslashes here. "\." hasn't a special meaning in
> double-quoted strings. And The double quotes are superflous here as
> well.
Oops.. I didn't mean to leave those in.. I was getting desperate when trying
to get the procedure to work & was trying any old thing ;)
> You should do :
> print $domains{'aaaaaa.bbbbbb.com'};
>
> What's inside the {} is an expression that should evaluate to a string,
> the hash key. As a special case, and for convenience, when the hash key
> contains only letters, digits and underscores, you can omit the quotes,
Of course! Don't know why I didn't think of that.
> even if you "use strict". You use strict, don't you? and warnings?
> That way, perl warns you when you try to write $d{a.b}.
I don't use strict, no.. not using it means I don't have to bother declaring
variables with "my".. Is this a frowned-upon bit of laziness?
As for warnings, I think I will start to use them now.. youre the second
person today who's suggested using them & it might help weed out anymore bad
habits I seem to have acquired :)
Regards
Spencer
------------------------------
Date: Thu, 11 Oct 2001 14:31:50 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Hashes
Message-Id: <slrn9sbbam.ggr.garry@zfw.zvolve.net>
On Thu, 11 Oct 2001 14:26:21 +0100, S Warhurst <s.warhurst@rl.ac.uk> wrote:
> "Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
>
>> } $domains{@tmp[0]} = @tmp[1];
>> ^ ^
>> These should be $.
>
> I've always used @ with arrays if they only have one column, and $ if it is
> a table array. So this is wrong, is it? I've never knowingly had any
> problems with @array[0] style syntax before.
Then you have never enabled warnings.
--
Garry Williams
------------------------------
Date: Thu, 11 Oct 2001 15:46:04 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: How to run perl under bash not sh
Message-Id: <3BC5B0AC.399948FB@bbsrc.ac.uk>
> > This is probably because under linux, sh is actually bash
> > pretending to be "dumb". Presumably it is accepting
> > "alias" as a command because it's really bash, but won't
> > let you actually define anything, because it's pretending
> > to be a Bourne shell.
>
> It would be nice if I could slocate a "sh" but I can't.
> AFAIK the only sh on my system is a soft link to bash
> but it sure doesn't act the same as bash.
But it is part of bash. From man bash ....
"If bash is invoked with the name sh, it tries to mimic the startup
behavior
of historical versions of sh as closely as possible, while conforming
to
the POSIX standard as well."
I'm sure I've posted this recently in another thread in this group.
TTFN
Simon.
PS This is now drifting way out of the realms of Perl..
------------------------------
Date: Thu, 11 Oct 2001 14:10:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Pattern Matching
Message-Id: <72abstcmpc1m39n593c3guqp6nast8rjeo@4ax.com>
Jeff Zucker wrote:
>shaz wrote:
>>
>> I want to test for the occurance of a particular string within a hash.
>>
>> The following was suggested:
>>
>> $y_or_n = grep { index($_, $small) != -1 } keys %strings;
>
>Umm, whats wrong with
>
> $y_or_n = defined $strings{$small};
s/defined/exists/
--
Bart.
------------------------------
Date: Thu, 11 Oct 2001 14:56:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Pattern Matching
Message-Id: <mocbsto8g68nu69ngg11qj9t6ivp6al1se@4ax.com>
shaz wrote:
>Using the example above:
>
>If $small = "the"
>
>it should match "the end" or "the end of" or "end the book" etc BUT NOT
>"then they" or "there is".
/\bthe\b/
or
/\b$small\b/
--
Bart.
------------------------------
Date: 11 Oct 2001 15:03:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: port scanner
Message-Id: <9q4ccg$pf1$3@mamenchi.zrz.TU-Berlin.DE>
According to novastar <novastar@novastar.dtdns.net>:
> This supossed to be a multi thread scanport. The problem is with the fork
> function ( lines 209 -226 ) . In fact the script does not fork from within a
> loop inside a subroutine. If you want to have a look and find what is wrong
> please send me the correction with email. I have attach the perl script
> because I have not any http account for posting.
> Thanks in advanced.
I think not. Bye.
[200+ lines of uu-encoded garbage snipped]
Anno
------------------------------
Date: Thu, 11 Oct 2001 14:24:18 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: Question about tab delimeted text file from Excel
Message-Id: <9q46i3$pf8@newton.cc.rl.ac.uk>
"Mike" <gbeanery@hotmail.com> wrote in message
news:K5gx7.198267$w7.32624814@news02.optonline.net...
> I am tyring to save a tab delimted text file from an Excel database. The
> problem is that Excel reformats a lot of the stuff and doesnt leave it
> alone. Especially when there are quotes, slashes etc etc. So when I read
> it from a perl script using the \t for tab delimited, it does not parse it
> correctly. The main problem I am having is the links field (html code
that
> points to another web site etc), it never displays for some reason. What
> can I try? In some cases the link is > 256 chars, so that is why I use
> excel. Acces cant handle. Thanks
Access can handle >256 characters.. you have to use a "memo" field type.
Spencer
------------------------------
Date: Thu, 11 Oct 2001 13:35:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Regular Expressions
Message-Id: <136bsts01jpknms820uaa1hehdsiq7mjt3@4ax.com>
Ben wrote:
>Does any one know how to search a string from say four different letters but
>with them in any order? e.g. I want to look for the letters e,l,t and n in
>the Unix words file. They all need to be in the word but can be in any
>order.
It depends on exactly what you want. If you only want to check the
presence of these four letters, you can combine 4 regexes:
/e/ && /l/ && /t/ && /n/
but that hardly counts as one regex. It will be one of the faster
methods, I assume.
Then there's lookahead. That is indeed one regex, though it probably
will be slower than the above method.
/^(?=.*e)(?=.*l)(?=.*t)(?=.*n)/
Don't forget the anchor (/^/), it will likely make a large speed
difference in case the match fails, because it prevents the regex from
doing many useless attempts.
But if you want the letters all right next to one another, with nothing
in between, the above methods won't work. Maybe they can be patched...
but it won't be easy.
That's why in this particular case, I'd take a different approach:
create all permutations of the combination of the 4 letters, and build a
regex with alternatives with them.
For the "permute" sub, look into this excerpt from the Perl Cookbook:
<http://safari.oreilly.com/main.asp?bookname=cookbook&snode=87>
Here's my variation on the first program, which returns a list of
references to the arrays, instead of printing them out:
sub permute {
my $items = shift;
my $perms = shift || [];
unless (@$items) {
return $perms;
} else {
my @all;
foreach my $i (0 .. $#$items) {
my @newitems = @$items;
my @newperms = (@$perms, splice(@newitems, $i, 1));
push @all, permute(\@newitems, \@newperms);
}
return @all;
}
}
For example:
print "@$_\n" foreach permute([qw(cat dog fish bird)]);
To apply that here, here's how to build a regex to test all permutations
of your four letters:
my $re = join "|", map { join "", @$_ }
permute([split "", "eltn"]);
That gives a string of 119 characters.
Now you can go search for it:
/$re/o
where the /o option can give a largish speed boost if you do many
attempts of matching using this regex, but it doesn't allow you to go
look for another combination of letters in the same program run.
--
Bart.
------------------------------
Date: 11 Oct 2001 14:42:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular Expressions
Message-Id: <9q4b4e$pf1$1@mamenchi.zrz.TU-Berlin.DE>
According to Bart Lateur <bart.lateur@skynet.be>:
> Here's my variation on the first program, which returns a list of
> references to the arrays, instead of printing them out:
>
> sub permute {
^^^^
Oh. I understand.
Anno
------------------------------
Date: Thu, 11 Oct 2001 15:00:58 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Regular Expressions
Message-Id: <avcbstor7mfuqud98gir1gbrm7lqhqv279@4ax.com>
Anno Siegel wrote:
>> sub permute {
> ^^^^
>
>Oh. I understand.
??? I don't. Is it a joke?
--
Bart.
------------------------------
Date: Thu, 11 Oct 2001 13:45:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: split into filename and extension (need help before I go insane)
Message-Id: <3a8bst09k65848egdr8rqp6qp4icme98a8@4ax.com>
JHWB wrote:
>how to split a filename into the name and the extension when the filename
>is:
>1. any length
>2. ends in either .jpg eller .gif
>3. can include any character in the name
>
>As I have to insert a date between the name and the extension I (think I)
>will be using two variables $name and $ext.
I think the regex you're looking for is somethin like
/(.*?)\.(jpg|gif)$/s
(not sure about the/s, a filen,ame containing a newline shouldn't be
common) but inserting the date can be done like this:
s/\.(jpg|gif)$/$date.$1/;
You can test the return value of this substitution to see if the
replacement took place, thus to see if indeed the filename ended in
".gif" or ".jpg".
--
Bart.
------------------------------
Date: 11 Oct 2001 07:36:35 -0700
From: mmgarza@peoplepc.com (A. Garza)
Subject: two-dimensional arrays, lists, whatever
Message-Id: <b00b8696.0110110636.152cb9a9@posting.google.com>
can anyone describe and give me an example of how to pass one to/from
a function? i've searched the archives, and i can't find any threads
that deal specifically with this topic.
thanks,
alicia
------------------------------
Date: Thu, 11 Oct 2001 16:49:58 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: two-dimensional arrays, lists, whatever
Message-Id: <opbbstgvf6v70pvhfcm0crmeitl4tkc0na@4ax.com>
On 11 Oct 2001 07:36:35 -0700, mmgarza@peoplepc.com (A. Garza) wrote:
>can anyone describe and give me an example of how to pass one to/from
>a function? i've searched the archives, and i can't find any threads
>that deal specifically with this topic.
You haven't searched very far, then. Check your Perl documentation for
the perlref and perllol pages (i.e. perldoc perllol, perldoc perlref).
You pass nested structures by passing a reference to them. Please note
that if you want to modify a nested structure in a list, it is usually
not necessary to pass back the reference as you are working on the
referenced data.
See also today's thread "&sub(@array1,@array2) ;-( ??".
#!/usr/bin/perl -w
use strict;
sub print_nested_list {
my $ref = shift;
foreach my $item ( @$ref ){
print "user: ", $item->{'user'}, ", ",
"pass: ", $item->{'pass'}, "\n";
}
}
my $nested_list_ref = [
{ 'user' => 'foo',
'pass' => 'bar' },
{ 'user' => 'bla',
'pass' => 'bli' },
{ 'user' => 'frob',
'pass' => 'zork' }
];
print_nested_list( $nested_list_ref );
__END__
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: 11 Oct 2001 14:54:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: two-dimensional arrays, lists, whatever
Message-Id: <9q4bqj$pf1$2@mamenchi.zrz.TU-Berlin.DE>
According to A. Garza <mmgarza@peoplepc.com>:
> can anyone describe and give me an example of how to pass one to/from
> a function? i've searched the archives, and i can't find any threads
> that deal specifically with this topic.
You pass a reference to the array or hash, as the case may be. Unless,
of course, the structure is anonymous. Then you already have a reference
and pass that.
Anno
------------------------------
Date: Thu, 11 Oct 2001 17:05:13 +0400
From: Balance Keeper <anordae@pisem.net>
Subject: Re: What is faster??
Message-Id: <3BC59908.C9A83135@pisem.net>
Bart Lateur wrote:
> Jean-Philippe Fauvelle wrote:
>
> >The second one (split with 3 args) is faster because it allows Perl to
> >stop searching just after the first ':'.
>
> Wrong.
>
> If the LHS contains a fixed amount of scalars, then perl will stop after
> one more. So these are equivalent:
>
> ($haha) = split /:/, $_;
>
> ($haha) = split(/:/, $_, 2);
>
> p.s.
>
> ($haha) = split(/:/, $_, 1);
>
> won't do what you want.
>
> --
> Bart.
Thanks.
--
Temel Nosce
------------------------------
Date: Thu, 11 Oct 2001 14:12:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: zipping files?
Message-Id: <f3abst0qccnnl02dre5oapebdkgjmv1r4h@4ax.com>
Jean-Philippe Fauvelle wrote:
>The module Compress::Zlib is made for you !
Nope. Compress::Zlib makes .gz files. He asked for (Windows style) .zip
files, so Archive::Zip is the better answer.
--
Bart.
------------------------------
Date: Thu, 11 Oct 2001 16:23:55 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: zipping files?
Message-Id: <nhabstk4j6g2dph2ualr8thh5s9hip01p6@4ax.com>
Le Thu, 11 Oct 2001 14:12:08 GMT, Bart Lateur <bart.lateur@skynet.be> écrit:
>Nope. Compress::Zlib makes .gz files. He asked for (Windows style) .zip
>files, so Archive::Zip is the better answer.
As far as i know, winzip supports (reading) the unix zip format (possibly tar'ed).
Because i dont't know the module Archive::Zip, i can't affirm which solution is better.
There's More Than One Way To Do It
Jean-Philipe Fauvelle
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 V10 Issue 1912
***************************************