[22588] in Perl-Users-Digest
Perl-Users Digest, Issue: 4809 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 3 06:05:43 2003
Date: Thu, 3 Apr 2003 03:05:08 -0800 (PST)
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, 3 Apr 2003 Volume: 10 Number: 4809
Today's topics:
ActivePerl FTP Performence <arikg@zoran.co.il>
Re: alternation & grouping in regexp <laocoon@fastmail.fm>
Re: cpan (Anno Siegel)
Re: cpan news@roaima.freeserve.co.uk
Re: Dialup using Perl <minceme@start.no>
Re: How to use newlines in DOS command options (Gian-Reto Alig)
Re: How to use newlines in DOS command options (Gian-Reto Alig)
Re: implementing a threaded serial device (or any other <stacom@stacom-software.de>
Installing Crypt-SSLeay on win32 ActivePerl 5.8.0 (Jesper)
Re: Installing Crypt-SSLeay on win32 ActivePerl 5.8.0 <kalinabears@hdc.com.au>
Re: Newbie question about copying directories <me@privacy.net>
Re: Newbie question about copying directories <NoSpamPleaseButThisIsValid2@gmx.net>
Re: Odd UTF-8 error with Switch.pm (Simon Fairey)
Re: Perl One-Liner (Helgi Briem)
RegEx Help for convert url! (Luca)
Re: RegEx Help for convert url! <josef.moellers@fujitsu-siemens.com>
Re: RegEx Help for convert url! (Anno Siegel)
Re: SMS <Andrew.McGregor@amtrak.co.uk>
Re: strict, global vars and 'require' <tunmaster@hotmail.com>
Re: strict, global vars and 'require' <tunmaster@hotmail.com>
Re: strict, global vars and 'require' (Helgi Briem)
Re: Which is better - hashes or subroutines <ubl@schaffhausen.de>
Re: Which is better - hashes or subroutines <ubl@schaffhausen.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 3 Apr 2003 12:36:14 +0300
From: "Arik" <arikg@zoran.co.il>
Subject: ActivePerl FTP Performence
Message-Id: <b6grq6$k9b$1@news2.netvision.net.il>
Hi,
My problem is that the transfare rate of using FTP and ActivePerl is match
slower than using standard win2k's ftp application.
For the same file I got about 4Sec using ActivePerl and 0.7 Sec using
win2k's FTP.
Please Help !!!
Arik
I wrote the following code,
use strict;
use Win32 ;
use Net::FTP;
my $ftp = Net::FTP->new("u447");
$ftp->login("xxxx",'yyyyyy');
$ftp->binary;
$ftp->cwd("/xxx/yyy");
$ftp->put("c:/abc.def" );
$ftp->quit;
------------------------------
Date: Thu, 3 Apr 2003 12:43:31 +0200
From: Lao Coon <laocoon@fastmail.fm>
Subject: Re: alternation & grouping in regexp
Message-Id: <Xns9352819273F71laocoon@62.153.159.134>
"Mike" <mike@luusac.co.uk> wrote in
news:RbMia.1744$0i4.11497@newsfep4-glfd.server.ntli.net:
> So how can I ensure that the \n between blah\nblah is not included in
> the match ?
You'll have to "cut around it"..
my $match;
if(/^(<ident> Identity:\n[\w\s]*)\n?([\w\s]*\n\n<\/end>)/)
{ $match = $1.$2 }
Lao
------------------------------
Date: 3 Apr 2003 09:22:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: cpan
Message-Id: <b6gugb$9lb$1@mamenchi.zrz.TU-Berlin.DE>
Ian <Ian@junk.net> wrote in comp.lang.perl.misc:
> Hi,
> I'm very new to this. I'm configuring cpan with "o conf init" and I'm
> getting asked some questions that I find awkward to answer.
> What do you guys use for unzip? Gzip I have and winzip is not command line.
If it shows a default, accept the default.
> for FTP proxy?
> for http proxy?
> for no proxy ???
If you don't have proxies, use the defaults.
> for a nearby continent?
The continent you're on.
> Also what's a good url to give it? www.cpan.org may not be what you all
> use.
If you answer the "continent" question, it will give you a list of
servers to select from.
Anno
--
--
sub nmax { @$_[ @_] = (); $#$_ }
------------------------------
Date: Thu, 3 Apr 2003 10:52:39 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: cpan
Message-Id: <790h6b.u0u.ln@moldev.cmagroup.co.uk>
Ian <Ian@junk.net> wrote:
> I'm very new to this. I'm configuring cpan with "o conf init" and I'm
> getting asked some questions that I find awkward to answer.
> What do you guys use for unzip? Gzip I have and winzip is not command line.
If you have gzip you /should/ also have gunzip. You can either,
* copy (link) gzip to gunzip, and use that
* try "gzip -d" (as per the man page for gzip)
> for FTP proxy?
> for http proxy?
> for no proxy ???
The proxy is really only necessary if you're on a LAN of some sort (for
example, a corporate network) that uses them. If this is the case then you
should ask your IT Support staff. Othewise, you probably don't need them.
> for a nearby continent?
Well. That clearly depends on where you are. JUNK.NET is registered to
what appears to be a Korean organisation, so I'd suggest that "nearby
continents" might include chunks of AsiaPac and maybe Australasia.
> Also what's a good url to give it? www.cpan.org may not be what you all
> use.
That depends on your choice of continents. What CPAN is trying to help you
select is a mirror site that has high bandwidth and low latency *for you*.
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Thu, 3 Apr 2003 09:30:39 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: Dialup using Perl
Message-Id: <b6guvv$qqd$1@troll.powertech.no>
* Graham Drabble:
> What I need is a way to get perl to check whether a connection exists
> and, if it doesn't, dial up and supply the username and password for
> the ISP. I've had a look in the FAQs but can't find anything. If it
> helps I'm using Win 2000.
Check out the command-line utility rasdial for options.
rasdial /?
--
Vlad
------------------------------
Date: 3 Apr 2003 01:22:03 -0800
From: gian-reto.alig@gmx.ch (Gian-Reto Alig)
Subject: Re: How to use newlines in DOS command options
Message-Id: <b59dd496.0304030122.e431817@posting.google.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E8B41DA.EA45DD0A@earthlink.net>...
> Gian-Reto Alig wrote:
[snip]
> > Is there any way to use newlines in a commandline option in DOS?
>
> I'm afraid not. It's not perl which is changing your newlines, it's the
> operating system itself. You simply cannot get newlines into arguments
> on windows. (Maybe NT or Win2000, I don't know, but definitely not on
> Win95).
In this case its not possible on NT either... I tried it on NT 4.0,
seems to have the same restrictions in this case as Win95
> > Is it possible using the Win32::Process module?
>
> I don't think so.
was just a last desperate idea... :-/
> #######
>
> What I suspect you will need to do, is get your tool to read attributes
> from stdin, or from a file, instead of from the commandline.
I think, this would be the best thing to do... I'll try to get some
help from the telelogic support.
Thanks for the help
Gian-Reto Alig
------------------------------
Date: 3 Apr 2003 01:23:56 -0800
From: gian-reto.alig@gmx.ch (Gian-Reto Alig)
Subject: Re: How to use newlines in DOS command options
Message-Id: <b59dd496.0304030123.35e9ad42@posting.google.com>
yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in message news:<3e8b5627@news.victoria.tc.ca>...
> Benjamin Goldberg (goldbb2@earthlink.net) wrote:
> : Gian-Reto Alig wrote:
[snip]
> : > Is there any way to use newlines in a commandline option in DOS?
>
> : I'm afraid not. It's not perl which is changing your newlines, it's the
> : operating system itself. You simply cannot get newlines into arguments
> : on windows. (Maybe NT or Win2000, I don't know, but definitely not on
> : Win95).
>
> : > Is it possible using the Win32::Process module?
>
> : I don't think so.
>
> : #######
>
> : What I suspect you will need to do, is get your tool to read attributes
> : from stdin, or from a file, instead of from the commandline.
>
> You might be able to use another shell. Cygwin comes with a small shell
> called sh, and you can run it as an independent program as long as the
> right .dll is also in the path (i.e. you do not need to "install" cygwin
> to use it).
Sounds interesting... will it run with Win NT 4.0?
------------------------------
Date: Thu, 03 Apr 2003 10:29:49 +0200
From: Alexander Eisenhuth <stacom@stacom-software.de>
Subject: Re: implementing a threaded serial device (or any other parallelway)
Message-Id: <b6grdu$55huo$1@ID-155280.news.dfncis.de>
Benjamin Goldberg schrieb:
>
> Now, you've *discarded* the blessed, shared, reference, and created a
> new, unblessed reference, in a new lexical variable (unrelated to the
> old one, except by name), and are not using the old blessed, shared,
> reference at all.
>
Thanks for your patinence. Now I think I got it, but anyhow it won't work. See
my scripts:
---------------- main.pm ----------------------------
use developThreadInPerlWork;
# -- setup a device
$comDev = new CComClass();
# -- wait for return
$a = <STDIN>;
# -- signal, that we want to shutdown
$comDev->exitThread();
# -- wait
sleep 2;
---------------- developThreadInPerlWork.pm
use threads;
use threads::shared; # to share data amoung threads
package CComClass;
sub new { # Allocator and Initializer
my ($packageName) = @_;
my $comObj = bless {running=>1}, $packageName;
threads::shared::share $comObj;
$comObj->{$watchThread} = create threads \&watchDevice, $comObj; # line 11
return $comObj;
}
sub exitThread {
my ($obj) = @_;
$obj->{running} = 0;
}
sub watchDevice {
my ($comObj) = @_;
threads->self->detatch;
print "threadLoop comObj >>>",$comObj, "<<<\n";
print ">>>running:$comObj->{running}\n";
while ($comObj->{running}) {
print "threadLoop($comObj->{running})\n";
sleep 1;
};
print "thread finished($comObj->{running})\n";
}
return 1
-----------------------------------------------------
output:
Invalid value for shared scalar at developThreadInPerlWork.pm line 11.
A thread exited while 2 other threads were still running.
------------------------------
Date: 3 Apr 2003 00:42:43 -0800
From: surferburfer@ids.se (Jesper)
Subject: Installing Crypt-SSLeay on win32 ActivePerl 5.8.0
Message-Id: <377997f1.0304030042.3656e036@posting.google.com>
I don't understand how to install Crypt-SSLeay (for surfing https with
lwp) on ActivePerl 580. Ppm says
"Error: no suitable installation target found for package
Crypt-ssleay."
I also tried to download the module in zip (crypt-ssleay.zip) from
activestate, http://ppm.activestate.com/PPMPackages/, with various
results. There is one for ActivePerl 5.xx that requires an old
installation of activeperl. There is one for 6.xx that is for solaris
only. There is none for 8.xx on windows.
I guess the only way is to run a version 5 (522) installation for
this. :-(
Or does anybody have a solution?
Thanks a lot,
Jesper
------------------------------
Date: Thu, 3 Apr 2003 20:20:04 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Installing Crypt-SSLeay on win32 ActivePerl 5.8.0
Message-Id: <3e8c0bbf$0$18826@echo-01.iinet.net.au>
"Jesper" <surferburfer@ids.se> wrote in message
news:377997f1.0304030042.3656e036@posting.google.com...
> I don't understand how to install Crypt-SSLeay (for surfing https with
> lwp) on ActivePerl 580. Ppm says
> "Error: no suitable installation target found for package
> Crypt-ssleay."
>
> I also tried to download the module in zip (crypt-ssleay.zip) from
> activestate, http://ppm.activestate.com/PPMPackages/, with various
> results. There is one for ActivePerl 5.xx that requires an old
> installation of activeperl. There is one for 6.xx that is for solaris
> only. There is none for 8.xx on windows.
>
> I guess the only way is to run a version 5 (522) installation for
> this. :-(
>
> Or does anybody have a solution?
>
> Thanks a lot,
> Jesper
For ActivePerl builds 8xx:
ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd
Cheers,
Rob
------------------------------
Date: Thu, 3 Apr 2003 19:10:18 +1000
From: "Tintin" <me@privacy.net>
Subject: Re: Newbie question about copying directories
Message-Id: <b6gtq0$54i37$1@ID-172104.news.dfncis.de>
<tribeguy_15@hotmail.com> wrote in message
news:v2sm8vcrk73ugnecojh2sphutap1lpe86l@4ax.com...
> Hi,
> I'm using version Perl 5.005_03 built for i386-freebsd and
> have a problem I can't figure out.
> I've made a script to copy a file in a particular directory to another
> directory and it works just fine:
> system "cp","/usr/templates/.qmail","/home/$username/.qmail" || die
> "cannot create $username/.qmail";
>
> I'm trying to do the same type of thing but with directories:
> system "cp -R","/usr/templates/Maildir","/home/$username/" || die
> "cannot create $username/Maildir";
>
> This script exits without any errors but Maildir and its
> subdirectories are not copied to /home/$username for some reason. Can
> anyone tell me what I'm doing wrong?
Suggest you read the documention for system.
perldoc -f system
------------------------------
Date: Thu, 03 Apr 2003 11:59:26 +0200
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid2@gmx.net>
Subject: Re: Newbie question about copying directories
Message-Id: <3E8C05FE.3C8F004E@gmx.net>
tribeguy_15@hotmail.com wrote:
>
> Hi,
> I'm trying to do the same type of thing but with directories:
> system "cp -R","/usr/templates/Maildir","/home/$username/" || die
> "cannot create $username/Maildir";
>
> This script exits without any errors but Maildir and its
> subdirectories are not copied to /home/$username for some reason. Can
> anyone tell me what I'm doing wrong?
Two things:
- "cp -R" is not an executeable.
- || has high precedence, use or instead:
perl -MO=Deparse,-p -e "system $a,$b || die 'c'"
system($a, ($b || die('c')));
-e syntax OK
See
perldoc -f system
and
perldoc perlop
Wolf
------------------------------
Date: 3 Apr 2003 02:17:34 -0800
From: simon.fairey@ft.com (Simon Fairey)
Subject: Re: Odd UTF-8 error with Switch.pm
Message-Id: <af9e67d1.0304030217.33747196@posting.google.com>
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote in message news:<slrnb8mfla.48j.rgarciasuarez@dat.local>...
> Simon Fairey wrote in comp.lang.perl.misc :
> >
> > Used my first 'switch' statement today and when it runs I get the
> > following:
> >
> > Malformed UTF-8 character (unexpected continuation byte 0x9e, with no
> > preceding start byte) in bitwise and (&) at
> > /opt/customer/local/perl58/lib/5.8.0/Switch.pm line 251.
>
> Could you provide a sample minimal script that triggers this error ?
> The output of "perl -V" could be also useful.
I'll try and get an example to you soon but in the meantime I found
that if I did utf8::encode() of the string used in the switch
statement it didn't complain. The string in question is an attibute
from an xml file that has been accessed using
XML::SimpleObject::LibXML.
perl -V gives:
Summary of my perl5 (revision 5.0 version 8 subversion 0)
configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi
uname='sunos fteporc-e10k-uk-t 5.8 generic_108528-09 sun4u sparc
sunw,ultra-enterprise-10000 '
config_args='-Dinstallbin=/opt/customer/local
-Dprefix=/opt/customer/local/perl58 -Dcc=gcc -Uinstallusrbinperl
-Dusethreads -Ui_c
rypt -Dlocincpth=/opt/customer/local/include /opt/local/include
/usr/local/include -Dloclibpth=/opt/customer/local/lib /opt/local/lib
/usr/local/lib -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -fno-strict-aliasing
-I/opt/customer/local/include -I/opt/local/include
-I/usr/local/include -D_
LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-D_REENTRANT -fno-strict-aliasing
-I/opt/customer/local/include -I/opt/local/include
-I/usr/local/include'
ccversion='', gccversion='2.95.1 19990816 (release)',
gccosandvers='solaris2.8'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/opt/customer/local/lib -L/opt/local/lib
-L/usr/local/lib '
libpth=/opt/customer/local/lib /opt/local/lib /usr/local/lib
/usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lrt -lpthread -lc
perllibs=-lsocket -lnsl -ldl -lm -lrt -lpthread -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/opt/customer/local/lib
-L/opt/local/lib -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Built under solaris
Compiled at Apr 1 2003 16:40:50
%ENV:
PERL5LIB="/export/home/simonf/siteperl"
PERL_CMD="/opt/customer/local/perl58/bin/perl"
@INC:
/opt/customer/local/perl58/lib/5.8.0/sun4-solaris-thread-multi
/opt/customer/local/perl58/lib/5.8.0
/opt/customer/local/perl58/lib/site_perl/5.8.0/sun4-solaris-thread-multi
/opt/customer/local/perl58/lib/site_perl/5.8.0
/opt/customer/local/perl58/lib/site_perl
.
------------------------------
Date: Thu, 03 Apr 2003 10:35:04 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl One-Liner
Message-Id: <3e8c0df9.452782557@news.cis.dfn.de>
On Wed, 02 Apr 2003 17:46:44 GMT, "Buck Turgidson"
<jc_va@hotmail.com> wrote:
>"Uri Guttman" <uri@stemsystems.com> wrote in message
>news:x7vfxwlrrg.fsf@mail.sysarch.com...
>> ok, how hard can this be? what is the only call of note in that code. i
>> see print but that is nothing special. hmmm, the only other term is
>> stat. what could that be? it can't be a sub since none were declared. it
>> must be a perl function!! this is fun! ok, now where do we find
>> information about perl functions? does usa today come to mind? no, you
>> think perldoc like any red-blooded perl hacker would do. and what option
>> of perldoc shows you information about individual builtin perl
>> functions? yes, you know this one. it is used in so many rtfm posts here
>> it should be burned into your retinas. yes, it is the -f option. so
>> let's put it all together and we get:
>>
>> perldoc -f stat
>Jeez, are you hyperventilating yet?
Be very careful about insulting Uri, who is giving you
good advice and trying to inject a little humour into it.
You are one jibe away from a hundred killfiles.
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: 3 Apr 2003 01:18:30 -0800
From: luca_milan@hotmail.com (Luca)
Subject: RegEx Help for convert url!
Message-Id: <5027603c.0304030118.4dac703d@posting.google.com>
Hi,
I have a really big problem, I want convert this type of url:
default.asp?ID_PAGINA=297&ID_MENU=456
into new static url: page,297,456,.html
page,[ID_PAGINA],[ID_MENU],.html
I need perform this replace over 1000 web pages (html code, href,
onclick, ecc...)...
Thx for any Help!
------------------------------
Date: Thu, 03 Apr 2003 11:24:17 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: RegEx Help for convert url!
Message-Id: <3E8BFDC1.4C5CD0CB@fujitsu-siemens.com>
Luca wrote:
> =
> Hi,
> =
> I have a really big problem, I want convert this type of url:
> =
> default.asp?ID_PAGINA=3D297&ID_MENU=3D456
> =
> into new static url: page,297,456,.html
> =
> page,[ID_PAGINA],[ID_MENU],.html
s/default\.asp\?ID_PAGINA=3D(\d+)\&ID_MENU=3D(\d+)/page,$1,$2,.html/g;
> I need perform this replace over 1000 web pages (html code, href,
> onclick, ecc...)...
> =
> Thx for any Help!
You're welcome,
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 3 Apr 2003 09:36:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: RegEx Help for convert url!
Message-Id: <b6gvba$9lb$2@mamenchi.zrz.TU-Berlin.DE>
Luca <luca_milan@hotmail.com> wrote in comp.lang.perl.misc:
> Hi,
>
> I have a really big problem, I want convert this type of url:
>
> default.asp?ID_PAGINA=297&ID_MENU=456
>
> into new static url: page,297,456,.html
>
> page,[ID_PAGINA],[ID_MENU],.html
>
> I need perform this replace over 1000 web pages (html code, href,
> onclick, ecc...)...
$_ = 'default.asp?ID_PAGINA=297&ID_MENU=456';
my $reformed = "page,$1,$2,.html" if /ID_PAGINA=(\d*).*ID_MENU=(\d*)/;
print "$_ -> $reformed\n";
How is the text "default.asp?ID_PAGINA=297&ID_MENU=456" embedded in
surrounding text? Isolating this part may well be the hardest problem
you face, but you say nothing about that.
Anno
------------------------------
Date: Thu, 03 Apr 2003 10:38:46 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: SMS
Message-Id: <3E8C0126.8020009@amtrak.co.uk>
BSD wrote:
> i want to send SMS message to my mobile using my Mobile_Service_Provider
> web page where I can enter my mobile phone no. and password and then i can
> compose a SMS message with Field to "..." subject "..." message"..." so can
> any one tell me which Perl module should I use to implememt this issue ?
>
search.cpan.org
sms
------------------------------
Date: Thu, 03 Apr 2003 08:43:00 GMT
From: "joe" <tunmaster@hotmail.com>
Subject: Re: strict, global vars and 'require'
Message-Id: <ouSia.1456234$Wr.54360575@Flipper>
It sure clears up a lot, thanks for that! But using the cgi-extension for a
'require'-script doesn't mather, right? Maybe it's regularly not done, but
it works fine for me. Or is it saver to rename them to some other extension?
"Brian McCauley" <nobull@mail.com> schreef in bericht
news:u965pwrfyg.fsf@wcl-l.bham.ac.uk...
> "joe" <tunmaster@hotmail.com> writes:
>
> > Just recently I started writing my scripts using the correct codes, that
is
> > I use the 'strict' function.
>
> You mean pragmatic module not function.
>
> > This function requires a variable to be declared using 'my varName'.
>
> No it does not. The my() function is used to declare lexically scoped
> variables. Lexically scoped variables are not associated with a
> package and only accessible withing the current lexical scope -
> i.e. in the same source file and before the next block-closing brace.
> They are not accessible via symbolic references and logically
> shouldn't be available via eval(STRING) - but they are.
>
> Most variables should be declared as lexically scoped but there are
> alternatives.
>
> The 'vars' module can be used to declare package variables. Declaring
> package variables is optional (even under strict) but you can't refer
> an undeclared package variable without using an explicit package
> prefix or a lexically scoped alias (see below). The decaration of a
> package variable is not lexically scoped and once a package variable
> has been declared it can re referred to without qualification in any
> file so long as the appropriate package directive is in effect.
>
> The our() function can be used to declare lexically scoped alaiases
> for package variables. This is generally the preferred way to access
> package variables. Note: some people think of our() as declaring
> package variables. Most of the time it is OK to think of it this way
> even though it's not strictly accurate.
>
> > But when I import a script via 'require plop.cgi',
>
> Why would you put the suffix '.cgi' on a file that's intended to be
> loaded via the Perl require() mechanism? When I see a file with a
> .cgi suffix I tend to assume it's designed to be called as an
> executable and to communicate using the CGI API.
>
> > this script doesn't see the vars declared in the main script!
> >
> > I've tried to use packages, but this won't do the the trick for me.
>
> How did you reach this concusion?
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Thu, 03 Apr 2003 09:01:15 GMT
From: "joe" <tunmaster@hotmail.com>
Subject: Re: strict, global vars and 'require'
Message-Id: <vLSia.1456827$Wr.54382769@Flipper>
great link, thank a lot!!!
"Tad McClellan" <tadmc@augustmail.com> schreef in bericht
news:slrnb8ng80.278.tadmc@magna.augustmail.com...
> joe <tunmaster@hotmail.com> wrote:
>
>
> > Just recently I started writing my scripts using the correct codes, that
is
> > I use the 'strict' function. This function requires a variable to be
> > declared using 'my varName'. But when I import a script via 'require
> > plop.cgi', this script doesn't see the vars declared in the main script!
> >
> > Can
> > anone help me out here...?!?
>
>
> "Coping with Scoping":
>
> http://perl.plover.com/FAQs/Namespaces.html
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Thu, 03 Apr 2003 10:32:50 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: strict, global vars and 'require'
Message-Id: <3e8c0c10.452293974@news.cis.dfn.de>
On Thu, 03 Apr 2003 08:43:00 GMT, "joe"
<tunmaster@hotmail.com> wrote:
Don't top-post. It *seriously* pisses off the regulars,
damages your reputation and reduces your chances of
having your questions answered by someone
with a clue.
If you don't know what top-posting is, read:
http://jargon.watson-net.com/jargon.asp?w=top%2Dpost
You should also read the posting guidelines that
are posted here every month, available at:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see
the "Netiquette Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
>It sure clears up a lot, thanks for that! But using the cgi-extension
>for a 'require'-script doesn't mather, right? Maybe it's regularly
>not done, but it works fine for me. Or is it saver to rename
>them to some other extension?
It works on a Unix system, because a Unix system doesn't
care about the filename extension. It is for humans and
Windows systems only.
But why label a file as being for CGI, when it's not? You
could go around labelling all your executables "program.doc"
and your C files, "something.pas" or whatever. Would
it be helpful? I think not.
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: Thu, 03 Apr 2003 10:14:31 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Which is better - hashes or subroutines
Message-Id: <b6gtn2$t20$1@news.dtag.de>
Matthew Braid wrote:
> Hi all,
>
> I've written a small package to handle multiple languages in a GUI
> (using perl/tk). It does this by loading a set of tags/values from a
> config file (in the form of PHRASENAME = text in whatever language).
> Use is similar to:
The fastest possible way should be to create the phrases as compile time
constants, so that they can be inlined during compilation like this:
(untested, but you'll get the idea)
BEGIN {
for (keys %phrases) {
*"Phrase::$_" = sub () { $phrases{$_} }
}
}
print Phrase::SOME_PHRASE; # some phrase is a key in %phrases. Its value
# will be inlined at compile time
Bye,
->malte
--
srand 108641088; print chr int rand 256 for qw<J A P H>
------------------------------
Date: Thu, 03 Apr 2003 10:25:15 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Which is better - hashes or subroutines
Message-Id: <b6gub5$46v$1@news.dtag.de>
Malte Ubl wrote:
> Matthew Braid wrote:
>
>> Hi all,
>>
>> I've written a small package to handle multiple languages in a GUI
>> (using perl/tk). It does this by loading a set of tags/values from a
>> config file (in the form of PHRASENAME = text in whatever language).
>> Use is similar to:
>
>
> The fastest possible way should be to create the phrases as compile time
> constants, so that they can be inlined during compilation like this:
>
> (untested, but you'll get the idea)
>
> BEGIN {
> for (keys %phrases) {
> *"Phrase::$_" = sub () { $phrases{$_} }
Since this is actually a closure, it might not be inlined, so you might
have to use eval here. Shouldnt be a problem, though,
->malte
------------------------------
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 4809
***************************************