[17567] in Perl-Users-Digest
Perl-Users Digest, Issue: 4987 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 29 11:05:32 2000
Date: Wed, 29 Nov 2000 08:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975513911-v9-i4987@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 29 Nov 2000 Volume: 9 Number: 4987
Today's topics:
Re: adduser <Per-fredrik.Pollnow@epk.ericsson.se>
compilation problems simbean@my-deja.com
Re: compilation problems simbean@my-deja.com
Re: Compile script to exe on many platforms <alian@alianwebserver.com>
Dates in perl sternr03@popmail.med.nyu.edu
Re: help with forking joekind@my-deja.com
Re: how do i direct compiler errors to a file-newbie simbean@my-deja.com
Re: how do i direct compiler errors to a file-newbie <roman.stawski@fr.adp.com>
Re: how do i direct compiler errors to a file-newbie <geoff-at-farmline-dot-com@127.0.0.1>
How do I install Net::Ftp module under NT <avril@ece.fr>
Re: How do I install Net::Ftp module under NT <alian@alianwebserver.com>
Re: How to find what is between n'th and the next tab? (Anno Siegel)
Re: Loading of modules? <jason@webfoundry.co.uk>
NOONE know anything at all????(was Re: Help needed on <Mikew@here.and.now>
Re: perl2exe <don@lclcan.com>
Re: perl2exe <hmacdonald@europarl.eu.int>
Re: perl2exe <alian@alianwebserver.com>
Re: proxy autoconfig <tony_curtis32@yahoo.com>
Re: Reading a csv file <iltzu@sci.invalid>
Re: Should { } always indicate a scope? <ren.maddox@tivoli.com>
Re: Skipping lines in a file (Anno Siegel)
Re: Skipping lines in a file (Flint Slacker)
Re: system() and backticks working intermittently on Tr <sb299@netzero.net>
Re: Unmatched Single Quote <iltzu@sci.invalid>
Re: use of Net::Telnet <madden@cms-stl.com>
Re: Why? <roman.stawski@fr.adp.com>
Re: Why? <ren.maddox@tivoli.com>
Re: working with lists of associative arrays <joe+usenet@sunstarsys.com>
Re: working with lists of associative arrays <ren.maddox@tivoli.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 29 Nov 2000 15:54:50 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: Re: adduser
Message-Id: <9034r8$hg$1@newstoo.ericsson.se>
Sorry about the bad spelling, tired :)
"Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se> wrote in
message news:90305e$k5v$1@newstoo.ericsson.se...
> Hi,
>
> I'm doing a litel program, I'm a newbie @ perl, so please help me.
>
> Ok this is what the program is going to do:
> First the user run the program and enter all the information I need, thats
> no problem..
> The problem begins here: when I got all the information I whant to crate
an
> account with his name and a random password.
> The name I now erlier from the program, I don't whant the user to enter
the
> password(the user gets an email with all the information and password
later
> in the program).
>
>
>
>
------------------------------
Date: Wed, 29 Nov 2000 15:01:01 GMT
From: simbean@my-deja.com
Subject: compilation problems
Message-Id: <9035n7$utt$1@nnrp1.deja.com>
Hi all,
a few days ago, I re-compiled perl 5.6.0 on a Winnt-pc and everything
was fine.
Just until today, when I realized that I forgot to enable threading. So
I enabled it in the makefile.mk (had to install the compiler and copy
the source again, because I deleted it after compilation) and compiled
once more.
It didn't work.
So I disabled threading just to see if it compiles without.
It didn't compile.
And since then I cannot get perl to compile!
It always throws some exceptions it (and me) cannot handle.
The latest error-message is:
"
cd ..\ext\Socket && \
..\..\miniperl -I..\..\lib Makefile.PL INSTALLDIRS=perl
Writing Makefile for Socket
cd ..\ext\Socket && d:\dmake\dmake.exe -S
gcc -c -g -O2 -DWIN32 -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -
fno-strict-aliasing -DPERL_MSVCRT_READFIX -g -O2 -
DVERSION=\"1.72\" -DXS_VERSION=\"1.72\" -I..\..\lib\CORE
Socket.c
Socket.c: In function `boot_Socket':
Socket.c:1224: incompatible type for argument 1 of `strcmp'
dmake.exe: Error code 1, while making 'Socket.o'
dmake.exe: Error code 255, while
making '..\lib\auto\Socket\Socket.dll'
"
and it drives me nuts!
I just cannot figure out what might be the problem. I have downloaded
various compilers, the latest dmake version and even the source for
perl 5.7.0 (just to make sure).
Anybody any ideas??
As I said, the platform is Winnt4.0, compiler ist gcc-2.95.2-msvcrt,
dmake is 4.1 and I want threading!!! :)
Errors are various, the above was the one when I left the office,
kicked the dog and threw my pc out of the window. In opposite order!
Thank you very much!
btw: sorry for my bad english, I am German! :)
Ciao,
SimBean.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 29 Nov 2000 15:12:15 GMT
From: simbean@my-deja.com
Subject: Re: compilation problems
Message-Id: <9036c9$vmn$1@nnrp1.deja.com>
Wow, I am replying to myself ... what would my doctor say?! :)
I was able to compile perl at last, but only with one specific
configuration.
All other configurations threw exceptions and didn't compile.
The following configuration worked FOR ME:
#USE_MULTI
#USE_ITHREADS
#USE_IMP_SYS
USE_5005THREADS
#USE_OBJECT
I think that are all the important variables. I didn't check to see if
I really have threading enabled but at least it compiles now...!
If anybody got any idea why the other configurations messed up, please
tell me.
Thank you.
Ciao,
René.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 29 Nov 2000 16:54:01 +0100
From: "Alain BARBET" <alian@alianwebserver.com>
Subject: Re: Compile script to exe on many platforms
Message-Id: <9038le$mb9$1@news2.isdnet.net>
Hi,
> I have a script that I want to compile to exe on different platform
(Unix
> and Windows). Is it possible?
Take a look at perl2exe:
http://www.indigostar.com/perl2exe.htm
HTH,
--
Alain BARBET
http://www.alianwebserver.com
------------------------------
Date: Wed, 29 Nov 2000 15:09:30 GMT
From: sternr03@popmail.med.nyu.edu
To: ricki.stern@med.nyu.edu
Subject: Dates in perl
Message-Id: <903673$vc7$1@nnrp1.deja.com>
I need to find out the number of days between two dates. One idea I
thought up for soing this is to use the localtime function and then
take out the yday and subtract one yday from the other.
Is there a better way to do this?
How do I pass a date such as 08/01/2000 into the localtime function
thanks
Ricki
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 29 Nov 2000 15:39:06 GMT
From: joekind@my-deja.com
Subject: Re: help with forking
Message-Id: <9037uq$10e$1@nnrp1.deja.com>
Spelling correction. I meant to say in the documentation blocks to read
# Here I want to wait until we...
(instead of # Here I want to want until we...)
In article <8vs6jn$jel$1@nnrp1.deja.com>,
joekind@my-deja.com wrote:
> Hi, Using LWP::UserAgent, I want to connect to 10 different sites but
> instead of waiting for each site to connect before moving on, I want
to
> connect to each site all at once. To do this I want to use forking.
I
> have tried many other techniques and I think in my case forking is the
> best thing to speed up my script.
> I want to do something like this:
>
> use LWP::UserAgent;
> for (1 .. 10) {
> unless(fork) {
> &getdata;
> exit;
> }
> $i++;
> }
> sub getdata {
> my $ua = new LWP::UserAgent;
> my $request = new HTTP::Request 'GET', $engurl;
> my $response = $ua->request ($request);
> $response_body[$i] = $response->content();
> }
>
> # Here I want to wait until we have a response from each site before
> # moving on and I want to be able to to read from each
> # $response_body[$i] variable and do some stuff with the contents of
> # the variables.
>
> Could someone help me do this. The big problems I have are
> 1) waiting for the response from each site before moving on because
> what usually happens is that because I'm not printing the contents of
> the response_body, it doesn't wait for any site to connect.
> 2) being able to do some further programming with the contents
> contained in the response variable.
>
> Thank-you in advance.
> I have been working at this a long time and it would really help if I
> could get this working.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 29 Nov 2000 15:24:44 GMT
From: simbean@my-deja.com
Subject: Re: how do i direct compiler errors to a file-newbie
Message-Id: <90373l$a4$1@nnrp1.deja.com>
Hi,
I don't know if this is what you want to do, but you can pipe the
stdout, stderr and stdin to a file in either windows and linux.
Compilation messages would be printed to a file (or files) via:
make 1>messages 2>error_messages
(or windows-like ;)
dmake 1>messages.txt 2>error_messages.txt
0: stdin
1: stdout
2: stderr
Hope that helps ...
Ciao,
SimBean.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 29 Nov 2000 16:09:34 +0100
From: Roman Stawski <roman.stawski@fr.adp.com>
Subject: Re: how do i direct compiler errors to a file-newbie
Message-Id: <3A251C2E.8A6FF2AC@fr.adp.com>
Geoff Winkless wrote:
>
> "Bart Lateur" <bart.lateur@skynet.be> wrote in message
> news:jcs92ts13damcgk8sp8muoujkva6hckark@4ax.com...
> : lightfoote@my-deja.com wrote:
> :
> : >using perl 5.5 compiler... ah how do i get the
> : >compiler errors messages to print to a file... currently they
> : >run off the screen....
> :
> : BEGIN {
> : open STDERR, ">errorlog.txt";
> : }
>
> For the -compiler- error messages?
>
> Geoff
You know what. It does work! Even for the -compiler- messages! Thanks Bart,
I never would've thought of that one!
--
Roman Stawski - ADPgsi
------------------------------
Date: Wed, 29 Nov 2000 15:49:48 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: how do i direct compiler errors to a file-newbie
Message-Id: <9038i9$bi1$1@soap.pipex.net>
"Roman Stawski" <roman.stawski@fr.adp.com> wrote in message
news:3A251C2E.8A6FF2AC@fr.adp.com...
: Geoff Winkless wrote:
: >
: > "Bart Lateur" <bart.lateur@skynet.be> wrote in message
: > news:jcs92ts13damcgk8sp8muoujkva6hckark@4ax.com...
: > : BEGIN {
: > : open STDERR, ">errorlog.txt";
: > : }
: > For the -compiler- error messages?
: You know what. It does work! Even for the -compiler- messages! Thanks
Bart,
: I never would've thought of that one!
Ugh. That's sick. It may work but it shouldn't, the idea of a compiler
redirecting its output based on the contents of an input file? ugh and ugh
again.
Geoff
------------------------------
Date: Wed, 29 Nov 2000 16:34:20 +0100
From: "François" <avril@ece.fr>
Subject: How do I install Net::Ftp module under NT
Message-Id: <9037lt$iv7$1@s1.read.news.oleane.net>
I have tried installed Net::Ftp module from CPAN and it doesn't work.
When I compiled my script, I have an error:
Can't locate object method "new" via package "Net::Ftp" at
d:\scripts\ftp\SFTP.P
L line 3.
That's my script:
#!e:\perl\bin\perl
use Net::Ftp;
$ftp = Net::Ftp->new("ftp.cai.com",Passive);
$ftp->login('anonymous','avril@ece.fr');
$ftp->cwd('./pub/Inoculan');
$ftp->get('il0084ij.exe', 'd:\temp');
$ftp->quit ();
I have made perl makefile.pl.
Any idea ?
I'm sorry for this newbie question.
Thanks for your answer.
------------------------------
Date: Wed, 29 Nov 2000 16:59:17 +0100
From: "Alain BARBET" <alian@alianwebserver.com>
Subject: Re: How do I install Net::Ftp module under NT
Message-Id: <9038va$4p3$1@news4.isdnet.net>
Hi,
> I have tried installed Net::Ftp module from CPAN and it doesn't work.
> When I compiled my script, I have an error:
> Can't locate object method "new" via package "Net::Ftp" at
> d:\scripts\ftp\SFTP.P
May be because it's Net::FTP, not Net::Ftp as you use ;-)
(2 times).
HTH,
--
Alain BARBET
http://www.alianwebserver.com
------------------------------
Date: 29 Nov 2000 14:48:24 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to find what is between n'th and the next tab?
Message-Id: <9034vo$m0m$1@lublin.zrz.tu-berlin.de>
Bart Lateur <bart.lateur@skynet.be> wrote in comp.lang.perl.misc:
>Anno Siegel wrote:
>
>>That is an interesting property of closures. It is hard to see,
>>however, how this can be realized without repeated compilation
>>of the regex.
>
>It needs to be compiled only once per column. So, if you want the 17th
>column of each record, you get one closure for this column, and call it
>for each line.
True, in principle only one translation per case is necessary. But I
have trouble imagining how the interpreter would keep track of cases
that have been dealt with.
Anno
------------------------------
Date: Wed, 29 Nov 2000 14:32:17 -0000
From: "Jason Timmins" <jason@webfoundry.co.uk>
Subject: Re: Loading of modules?
Message-Id: <975508290.10399.0.nnrp-02.9e981414@news.demon.co.uk>
"Dan Sugalski" <dan@tuatha.sidhe.org> wrote in message
news:5hRU5.75892$P82.8262174@news1.rdc1.ct.home.com...
> Jason Timmins <jason@webfoundry.co.uk> wrote:
> > Hi There,
>
> > Can anyone tell me where in the source for Perl 5.6.0 the interpreter
loads
> > modules from the file system?
>
> > I've found stuff called Perl_load_module but I was looking for a nice
fread
> > command.
>
> You're not going to find anything nearly that simple, alas. If nothing
else,
> the code in a .pm file needs to run through the parser and any executable
> code needs to be loaded by the OS' shared library loading system.
>
> You can check out the require opcode function for a start, and go from
there.
> It's got the code to handle loading in perl files from disk. The code to
> handle loading in shared libraries is in ext/DynaLoader, probably in the
> dl_dlopen.xs file. (There are a bunch of dl_*.xs files--which one gets
> used depends on what platform you build perl on, since loading up shared
> libraries is different on different OSes)
>
> I'll warn you, though--it's rather... interesting code.
Thanks. I'll have a look.
Do you happen to know if my assumption that the Perl interpreter loads the
whole .pl in one go and then proceeds to 'run' it, is correct? Or am I
barking up the wrong tree entirely and it loads lines at a time
interpreting/translating as it goes?
Is there an architectural overview of the interpreter on the web? I'm
interested in understand how it all works.
Cheers
Jason.
------------------------------
Date: Wed, 29 Nov 2000 15:12:17 +0000
From: MikeW <Mikew@here.and.now>
Subject: NOONE know anything at all????(was Re: Help needed on win32::tieregistry.
Message-Id: <3A251CD0.F1FB8F01@here.and.now>
MikeW wrote:
> Hi.
> Im trying to write a perl script that will change the cdrom drive
> letter on a windows 2000 system. Im using win32::tieregistry.
>
> The problem I am having is that, although i can change the DATA in the
> registry string..(HTLM\System\mounted\devices\\dosdevices\d: )
> denoting current drive letter for cdrom is the D: drive), I cannot
> work out how to rename the D: in the name to R: (for eg if I want the
> drive letter to be r:).
> I also have to change the delimiter because the '\dosdevices\D:' bit
> is just one single name, so..in my script I use '/' as a registry
> delimiter, and then reference the string as
> 'HKLM/system/MountedDevices/\DosDevices\D: (why DID miscrosoft use the
> '\' as a part of the key name anyway???)
> Its easy enough manually..you just right click on the key name, select
> 'rename' and change the d: to an r:..and it works.
> But using perl I am getting nowhere.
> anyone any ideas?..or could point me to a suitable win32:tieregistry
> primer?.(I find the help files that come with perl not very
> helpfull!.)
> many thanks
> Mike Warren.
Noone have any ideas??.
Even microsoft 'wer'nt sure, and they'd get back to me'...2 weeks ago.
Mike Warren.
------------------------------
Date: Wed, 29 Nov 2000 09:10:39 -0500
From: Don <don@lclcan.com>
Subject: Re: perl2exe
Message-Id: <3A250E5F.F1DDEA5E@lclcan.com>
http://www.indigostar.com/perl2exe.htm
harry macdonald wrote:
> Where can I find a perl2exe for Perl5.6 on NT
> Or has the method of doing this changed ?
>
> thanks for any info
------------------------------
Date: Wed, 29 Nov 2000 16:47:27 +0100
From: harry macdonald <hmacdonald@europarl.eu.int>
Subject: Re: perl2exe
Message-Id: <3A25250E.2B4777C2@europarl.eu.int>
I wonder if you can help with the sequel as well :-
I can happily generate the executable with out errors (I'm not using any
switches).
perl2exe.exe myfile.pl
But when I run the executable (myfile.exe) I get :-
"The procedure entry point GetPerlInterpreter could not be located in
the dynamic link library p2x560.dll
Can't load 'D:\TEMP/Process.dll' for module Win32::Process:
load_file:The specified procedure could not be found at
PERL2EXE_STORAGE/DynaLoader.pm line 118.
at get_url.pl line 2
Compilation failed in require at get_url.pl line 2.
BEGIN failed--compilation aborted at get_url.pl line 2.
—----------------------------------------------------
Any ideas ?
I do not have a registered version
I am using Active state Perl 5.6 for NT. Might this be a problem ?
Are there any known undocumented installation requirements ?
I saw in the news groups discussions of the need for Storable.pm
I downloaded http://www.activestate.com/PPMPackages/5.6/storable.ppd
but when I "ppm install Storable.ppd " as instructed I get
"Error installing package 'Storable.ppd': Read of ./ failed"
So I'm a bit stuck.
—----------------------------------------------------
p2x560.dll exists in my perl/bin directory
perl/bin is in the PATH.
The file D:\TEMP/Process.dll does not exist
The file perl/bin/DynaLoader.pm exists, but line 118 is a blank line,
and there are no occurrences of the string PERL2EXE_STORAGE
—----------------------------------------------------
Line 2 of myfile.pl program is a use statement :-
#########################################################################
# process automate regular url get (proxy and caching options)
#
#########################################################################
#Declaritives Section
#!perl
#Variables
#Modules
#use Win32::Internet;
use Win32::Process;
use Carp;
use Win32;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
------------------------------
Date: Wed, 29 Nov 2000 17:01:23 +0100
From: "Alain BARBET" <alian@alianwebserver.com>
Subject: Re: perl2exe
Message-Id: <90399a$mov$1@news2.isdnet.net>
Hi,
> I am using Active state Perl 5.6 for NT. Might this be a problem ?
No.
> I saw in the news groups discussions of the need for Storable.pm
> I downloaded http://www.activestate.com/PPMPackages/5.6/storable.ppd
> but when I "ppm install Storable.ppd " as instructed I get
> "Error installing package 'Storable.ppd': Read of ./ failed"
Just "ppm install Storable", no .ppd.
HTH,
--
Alain BARBET
http://www.alianwebserver.com
------------------------------
Date: 29 Nov 2000 08:35:01 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: proxy autoconfig
Message-Id: <87u28qalt6.fsf@limey.hpcc.uh.edu>
>> On Wed, 29 Nov 2000 05:47:43 GMT,
>> brett_wilson@my-deja.com said:
> Hi All, I have a quick question. I have a cgi script
> that is for two proxy servers where it looks at one , if
I presume you mean the CGI program is invoked through some
user action and then retrieves something else through the
proxy? Or performs a redirect to a proxy depeding on the
availability of that proxy?
> that server is down it jumps to the next server. see
> below
> PROXY w3proxy.netscape.com:8080; PROXY mozilla.netscape.com:8081
> What is the connection that is made to see if the first
> server is up?
perldoc lwpcook
You could try a HEAD with a timeout to see if the proxy is
responding. Or just ping the machine. Depends on what
you mean by "up".
hth
t
--
Eih bennek, eih blavek.
------------------------------
Date: 29 Nov 2000 15:36:08 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Reading a csv file
Message-Id: <975511089.27121@itz.pp.sci.fi>
In article <slrn928de2.br5.mgjv@verbruggen.comdyn.com.au>, Martien Verbruggen wrote:
>
>You can't honestly expect any CSV parser to allow invalid syntax. CSV
>is a defined file format. You can't just make something up that has
>commas, call it CSV, and then expect CSV_XS to parse it.
Why not? Just about everyone else has.
CSV files are a perfect example of the old saying about standards,
namely that the nice thing about them is that there are so many to
choose from. Some formats use backslash escapes or something similar,
most don't. Some allow newlines in quoted strings, some require them
to be preceded by some escape character, some want them as \n or
something else, and some just plain forbit them. Some allow lone
quotes in all fields, some only in non-quoted fields, some not at all.
And let's *not* get into discussing metadata. Please.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: 29 Nov 2000 08:58:15 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Should { } always indicate a scope?
Message-Id: <m3puje4ygo.fsf@dhcp11-177.support.tivoli.com>
Jeff Pinyan <jeffp@crusoe.net> writes:
> On Nov 28, Ren Maddox said:
>
> >"John Lin" <johnlin@chttl.com.tw> writes:
> >
> >> my $x = { 2 => my $a = 1 };
> >> print $x->{ my $b = 2 };
> >> print $a,$b;
> >>
> >> The $a,$b are still visible outside.
> >
> >$a and $b are special. See the documentation for strict:
>
> The {...} used for the subscript are synonymous with the [...] used for
> array subscripts:
Yes, of course. I was a bit over-lazy and didn't even bother to look
at the details -- I just had alarms going off over the use of $a and
$b as test cases for a scoping/strict situation.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 29 Nov 2000 14:22:18 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Skipping lines in a file
Message-Id: <9033eq$luj$1@lublin.zrz.tu-berlin.de>
[jeopardism rearranged]
Flint Slacker <flint@flintslacker.com> wrote in comp.lang.perl.misc:
>On Tue, 28 Nov 2000 19:12:55 GMT, J. Stone <jstone211@my-deja.com>
>wrote:
>
>>What is the most graceful way to skip a number of lines in a file?
>>Here is a code sample that shows how I currently accomplish this:
>>
>> while (<INFILE>){
>> chop;
>> if (m/PORTFOLIO TOTALS:/){
>> $line = <INFILE>;
>> $line = <INFILE>;
>> $line = <INFILE>;
>> .
>> .
>> .
>
>I like using labels myself....
>
>LOOP: while(<INFILE>) {
> chomp;
> next LOOP if(/pattern/); #don't process
> last LOOP if(/^$/); #exit
> push(@lines, $_); #good line
> ......
>}
This has little to do with the original problem. The original
poster wants to skip a number of lines after some pattern matches,
you skip only the matching lines. Why you quit the loop on an
empty line is your secret, this is nowhere specified. Finally,
there is no reason given why the "good lines" must be collected
in an array; presumably they can be processed immediately to save
some space.
Anno
------------------------------
Date: Wed, 29 Nov 2000 15:08:46 GMT
From: flint@flintslacker.com (Flint Slacker)
Subject: Re: Skipping lines in a file
Message-Id: <3a25198d.76138975@news.tcn.net>
My mistake... thank you Anno
$count = 0;
$process = 0;
while(<>) {
chomp;
if(/pattern/) { $process = 1; }
if($process) {
# do something with it
$count++;
if($count > $goodlines) { $process = 0; $count = 0; }
}
}
It's not graceful, but I think it will work.....
Flint
On Tue, 28 Nov 2000 19:50:07 GMT, flint@flintslacker.com (Flint
Slacker) wrote:
>
>I like using labels myself....
>
>LOOP: while(<INFILE>) {
> chomp;
> next LOOP if(/pattern/); #don't process
> last LOOP if(/^$/); #exit
> push(@lines, $_); #good line
> ......
>}
>
>Flint
>
>
>On Tue, 28 Nov 2000 19:12:55 GMT, J. Stone <jstone211@my-deja.com>
>wrote:
>
>>What is the most graceful way to skip a number of lines in a file?
>>Here is a code sample that shows how I currently accomplish this:
>>
>> while (<INFILE>){
>> chop;
>> if (m/PORTFOLIO TOTALS:/){
>> $line = <INFILE>;
>> $line = <INFILE>;
>> $line = <INFILE>;
>> .
>> .
>> .
>>
>>
>>Sent via Deja.com http://www.deja.com/
>>Before you buy.
------------------------------
Date: Wed, 29 Nov 2000 14:53:55 GMT
From: "Steve Bourgeois" <sb299@netzero.net>
Subject: Re: system() and backticks working intermittently on Tru64 UNIX
Message-Id: <7M8V5.42740$751.1323496@typhoon.ne.mediaone.net>
"Dan Wilga" <dwilgaREMOVE@mtholyoke.edu> wrote in message
news:dwilgaREMOVE-CD4EFE.14470728112000@news.mtholyoke.edu...
> In article <HSyU5.38432$751.1170768@typhoon.ne.mediaone.net>, "Steve
> Bourgeois" <sb299@netzero.net> wrote:
>
> > I have an application written in perl that makes various calls out to
the
> > OS with system() and backticks.
> >
> > The problem is that hosting out to the OS occasionally does nothing when
> > it is executed.
> >
> > For example, something like $results = `ps -ef |grep zz` will return a
NULL
> > string
>
> We had been running Apache 1.3.9 on Linux, and one of the people here was
> having intermittent problems with the $ENV{PATH} Apache was sending it.
>
> The immediate solution was to simply give the full path to the system
command
> being executed. The long-term fix was to update Apache.
>
> You might want to print out the contents of $ENV{PATH} to see if they are
> munged.
>
> Dan Wilga dwilgaREMOVE@mtholyoke.edu
> ** Remove the REMOVE in my address address to reply reply **
Dan,
Thanks for the response...
Unfortunately, it also happens where I have hard-coded the full path to the
OS utility
that I am using ( i.e. /usr/bin/mailx ). :(
Steve
------------------------------
Date: 29 Nov 2000 15:05:23 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Unmatched Single Quote
Message-Id: <975509755.23314@itz.pp.sci.fi>
In article <3a245a63@nexus.comcen.com.au>, Kiel Stirling wrote:
>
>I think you should use the function quotemeta
I think not, in this case. quotemeta() is meant for safely quoting
_regex_ metacharacters. SQL metacharacters, which the OP is having
problems with, are not the same thing at all.
>$unsafesqldata = $p->param('issuefld');
>my $safesqldata = quotemeta $unsafesqldata;
You mean:
my $safesqldata = $dbh->quote($unsafesqldata);
>see perldoc -f quotemeta
>http://www.perldoc.com/perl5.6/pod/func/quotemeta.html
That's always good advice. But after learning what quotemeta() does
and especially doesn't do, the OP would most likely find "perldoc DBI"
or http://search.cpan.org/doc/TIMB/DBI-1.14/DBI.pm more useful.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Wed, 29 Nov 2000 09:30:58 -0600
From: Michael Madden <madden@cms-stl.com>
Subject: Re: use of Net::Telnet
Message-Id: <3A252132.9F1C4A55@cms-stl.com>
Try the following examples at this page:
http://www.enstimac.fr/Perl/perl5.6.0/site_perl/5.6.0/Net/Telnet.html
Mike
Lex Hagen wrote:
>
> Hi,
>
> I'm really new to Perl. And have to use the Net::Telnet module, but
> don't really know how. Maybe someone can send me a short example on how
> to use the Net::Telnet module. (e.g. a piece of code that connects to a
> remote machine, loggs in, etc.)
> I'm going to run the program on a NT-machine and connect to a remote
> UNIX-machine.
>
> I would really, really appreciate it!
>
> Thanks in advance,
>
> Lex
------------------------------
Date: Wed, 29 Nov 2000 16:03:06 +0100
From: Roman Stawski <roman.stawski@fr.adp.com>
Subject: Re: Why?
Message-Id: <3A251AAA.CF1539B3@fr.adp.com>
John Boy Walton wrote:
>
> The following script wiped the contents of the file.
> I don't know why, as I understand it the print statement should go to
> <STDOUT> not <BOGUS>.
>
> #!E:/Millenium Programs/perl/bin/Perl -w
If you're on a DOS box, then this is a waste of time...
#!perl -w
works just fine, and is quicker to type. Since you used -w, how come
you forgot about use strict?
> $path = "C:/Program Files/G6FTP/";
> $file = $path."Users.ini";
> open BOGUS,"$file";
You don't need to quote $file! And aren't you missing a
or die "Can't open $file: $!"
clause at the end of that line?
> while ( defined( $line = <BOGUS> ) )
> {
> print $line;
> }
while (<BOGUS>)
{
print $_;
}
or even
print while <BOGUS>;
work just as well. Your test defined is superfluous since $line will
always be true for all lines read (including 'empty' ones) and be
false at the end of the file.
Pontificating apart, the script works fine for me. I have had similar
problems though in the past when I tried to read from a file that I
opened using something like
open BOGUS, ">$file" or die "Can't open $file: $!";
by mistake. Are you sure you don't have something like that?
--
Roman Stawski - ADPgsi
------------------------------
Date: 29 Nov 2000 09:19:26 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Why?
Message-Id: <m3hf4q4xhd.fsf@dhcp11-177.support.tivoli.com>
"John Boy Walton" <johngros@Spam.bigpond.net.au> writes:
> The following script wiped the contents of the file.
> I don't know why, as I understand it the print statement should go to
> <STDOUT> not <BOGUS>.
>
> #!E:/Millenium Programs/perl/bin/Perl -w
> $path = "C:/Program Files/G6FTP/";
> $file = $path."Users.ini";
> open BOGUS,"$file";
> while ( defined( $line = <BOGUS> ) )
> {
> print $line;
> }
I see nothing there that would modify the file. I suspect something
else happened.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 29 Nov 2000 09:23:22 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: working with lists of associative arrays
Message-Id: <m366l67t7p.fsf@mumonkan.sunstarsys.com>
pfister_@mindspring.com (jim crawford) writes:
> I'm having problems working with a list of associative arrays.
>
> I have a loop that fills the list like so:
> $n=0;
> while(<>)
> { chomp;
> if($_ eq "-") { $n++; next; }
> ($var, @val)=split(/=/);
> $data[$n]{$var}="@val";
> }
>
> I have functions that work with this list, but I tired of typing out
> $data[$_[0]]{"fieldname"} to access the data, and tried to create a
> temporary variable as a shortcut:
> $x=$data[$_[0]];
>
> Now... the intention is for the right side of this assignment to
> evaluate to a hash... but perl doesn't like
> %x=%data[$_[0]];
> because I "can't use subscript on associative array dereference".
$data[$_[0]] is a hashref- you can copy the contents of the hash
into %x via:
%x = %{$data[$_[0]]};
Keep in mind that %x is a copy, so changes to %x won't affect the
contents of $data[$_[0]]. If this is undesirable, you need to work
with the hashref directly like so:
$x = $data[$_[0]];
and use $$x or %$x wherever you would have used %x in your
later code.
As to the rest of your questions, someone more knowledgable
will have to address them. I tried and failed ;)
HTH
--
Joe Schaefer
------------------------------
Date: 29 Nov 2000 09:16:17 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: working with lists of associative arrays
Message-Id: <m3lmu24xmm.fsf@dhcp11-177.support.tivoli.com>
pfister_@mindspring.com (jim crawford) writes:
> I'm having problems working with a list of associative arrays.
First, review the relevant documentation a couple of times:
perlref(1)
perlreftut(1)
perldsc(1)
perllol(1)
> I have a loop that fills the list like so:
Right from the start you should get into the habit of using strict and
enabling warnings. It can *really* help with all sorts of problems,
not that this piece of code has any.
> $n=0;
> while(<>)
> { chomp;
> if($_ eq "-") { $n++; next; }
> ($var, @val)=split(/=/);
> $data[$n]{$var}="@val";
> }
Fine.
> I have functions that work with this list, but I tired of typing out
> $data[$_[0]]{"fieldname"} to access the data, and tried to create a
> temporary variable as a shortcut:
> $x=$data[$_[0]];
Also fine. I expect the stumbling block you are hitting is what to do
with $x to get at the data. You need to use $x->{fieldname} to do
that.
> Now... the intention is for the right side of this assignment to
> evaluate to a hash... but perl doesn't like
> %x=%data[$_[0]];
That syntax is a bit off (would be: %x = %{$data[$_[0]]}), but you
don't want to do that anyway as it makes a *copy* of the hash.
> because I "can't use subscript on associative array dereference".
>
> This gives me the impression that in, this expression, %data
> represents a hash named data. As in (%data)[$_[0]]. Like % is an
> operator that binds more closely than [].
Yes, exactly -- perlref(1) discusses this under "Using References".
> Clearly the expression $data[$_[0]]{"fieldname"} isn't indexing into
> the scalar "$data", given that it works.
>
> This gives me the impression that I really have only the vaguest idea
> what the variable prefixes represent and how they affect the code.
> I've probably gotten this far on sheer luck and some overly-friendly
> DWIM on the part of the interpreter.
I agree. Read the referenced documentation a couple of times until you
feel more comfortable with what's going on.
> I've done some research, and I haven't been able to find a good
> explanation anywhere of what's actually going on. I'm afraid to look
> at the perl source.
No need to look at the perl source -- the documentation goes over all
of this in detail.
> Another tangible problem, possibly related for all I know, is that
> this doesn't work:
> sub sortentries #($field)
> { @data=sort { $a{$_[0]} cmp $b{$_[0]} } @data;
> }
An array, like @data, can only contain scalars. You are treating $a
and $b as if they were hashes. As above, you need to dereference them
(they are hash *references*) with the arrow operator ( -> ):
sub sortentries #($field)
{ @data=sort { $a->{$_[0]} cmp $b->{$_[0]} } @data;
}
(Though operating on @data directly doesn't seem very friendly, but
that is another issue altogether...)
> while this does:
> sub sortentries #($field)
> { @data=sort { deref($a, $_[0]) cmp deref($b, $_[0]) } @data;
> }
>
> sub deref #(%hash, $index)
> { return $_[0]{$_[1]};
> }
>
> I'm completely at a loss as to why.
The second method works because the syntax $_[0]{$_[1]} automatically
dereferences -- it is the same as $_[0]->{$_[1]}.
> Please, enlighten me!
I hope I have given you a good start, but the documentation is the
real source of enlightenment!
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4987
**************************************