[19876] in Perl-Users-Digest
Perl-Users Digest, Issue: 2071 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 5 14:05:41 2001
Date: Mon, 5 Nov 2001 11: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: <1004987110-v10-i2071@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 5 Nov 2001 Volume: 10 Number: 2071
Today's topics:
a good perl editor - know one?? <pauls@cascadelinear.com>
Re: a good perl editor - know one?? (Marc Bissonnette)
Re: a good perl editor - know one?? <djberge@qwest.com>
Can you help optimize this?? <robsjobs@hotmail.com>
Re: Can you help optimize this?? <tony_curtis32@yahoo.com>
Re: Can you help optimize this?? <robsjobs@hotmail.com>
Re: Can you help optimize this?? (Eric Bohlman)
Re: cannot access value of $hash{key}, but graphical de <mjcarman@home.com>
Cookies again <msisto@chat.carleton.ca>
Grep on Last Line Only <jc_va@hotmail.com>
Re: Help with a tough algorithm (Mark Jason Dominus)
mod_perl - a last man standing-problem (Ralf Inceoglu)
Re: Need help with character substitution <pauls@cascadelinear.com>
Re: Need help: Looping mailer using too many resources <newsgroup_mike@ultrafusion.co.uk>
Re: Need help: Looping mailer using too many resources <newsgroup_mike@ultrafusion.co.uk>
Re: Need help: Looping mailer using too many resources (Marc Bissonnette)
Re: Need help: Looping mailer using too many resources (Marc Bissonnette)
Re: Need help: Looping mailer using too many resources <newsgroup_mike@ultrafusion.co.uk>
Newbie needing assistance in setting up server for Perl <robin@cboss.com>
Re: Question on File uploading. (Mark Jason Dominus)
Re: Serial Port control under Win32::SerialPort <ned@bike-nomad.com>
Re: Sorting an array - help please <mjcarman@home.com>
Re: Sorting an array - help please <plain@englishtec.freeserve.co.uk>
Re: Tracing ["non-interactive debugging"] like in REXX? (Peter Scott)
Re: Tracing ["non-interactive debugging"] like in REXX? <edgue@web.de>
Re: Using Perl to set Unix environmental variables (Malcolm Dew-Jones)
Re: XML::Records (was Re: XML parsing) <bart.lateur@skynet.be>
Re: XML::Records (was Re: XML parsing) (Eric Bohlman)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 05 Nov 2001 09:21:54 -0800
From: Paul Spitalny <pauls@cascadelinear.com>
Subject: a good perl editor - know one??
Message-Id: <3BE6CAB2.647FD684@cascadelinear.com>
Hi,
Anyone know of a text editor (For a windows platform) specifically
targeted to PERL that has features like color coding of key works and
other nice development aids?
Thanks
Paul
------------------------------
Date: Mon, 05 Nov 2001 18:05:38 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: a good perl editor - know one??
Message-Id: <Xns91508622CC9D4dragnetinternalysisc@207.35.177.134>
Paul Spitalny <pauls@cascadelinear.com> wrote in
news:3BE6CAB2.647FD684@cascadelinear.com:
> Hi,
> Anyone know of a text editor (For a windows platform) specifically
> targeted to PERL that has features like color coding of key works and
> other nice development aids?
UltraEdit, hands down, is IMNSHO, the best text editor there is, with color
coding of key words, excellent regex functions, and a host of other
features. IIRC, there is a 30 day trial and then it's only US$30 or so to
register. Well worth it (I've been using it about four years)
http://www.ultraedit.com
--
----------------------------
Marc Bissonnette
InternAlysis
Intelligence in Internet Communications
http://www.internalysis.com
------------------------------
Date: Mon, 5 Nov 2001 12:53:49 -0600
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Re: a good perl editor - know one??
Message-Id: <2bBF7.438$Wj3.114922@news.uswest.net>
"Paul Spitalny" <pauls@cascadelinear.com> wrote in message
news:3BE6CAB2.647FD684@cascadelinear.com...
> Hi,
> Anyone know of a text editor (For a windows platform) specifically
> targeted to PERL that has features like color coding of key works and
> other nice development aids?
>
> Thanks
>
> Paul
PerlBuilder 2.0 is pretty nice. Fancier features than UltraEdit, but costs
much more.
Regards,
Mr. Sunblade
------------------------------
Date: Mon, 05 Nov 2001 18:18:39 GMT
From: "Rob" <robsjobs@hotmail.com>
Subject: Can you help optimize this??
Message-Id: <3KAF7.17026$zK1.5798745@typhoon.tampabay.rr.com>
I realize that index is a horrible function for speed. Here is what my
program looks like (more pseudo than code, FYI)
$array_of_abrev[0]="PA";
$array_of_abrev[1]="PN";
$array_of_abrev[3]="PR";
$array_of_abrev[4]="PT";
$list_of_cust_ids[0]="A95412";
$cust_config{$list_of_cust_ids[0]}= "AB,AC,AF,GR,PR";
Now.. When my code does it's work, this is the logic:
foreach $cust (@list_of_cust_ids) {
foreach $abrev (@array_of_abrev) {
if (index($cust_config{$cust},$abrev) > -1) {
#PROCESS THE DATA
}
}
}
The goal is to only do the work when (in the example above,) the third
iteration of $abrev for $cust ("PR") exists within $cust_config{$cust} and
index returns "12" because "PR" begins at the 12th char in the string
"AB,AC,AF,GR,PR".
I realize the index function is a pig but I need to know that PR exists so I
can do my other work.
Thanks for your suggestions.
Rob
------------------------------
Date: Mon, 05 Nov 2001 12:21:56 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Can you help optimize this??
Message-Id: <87snbtqdrv.fsf@limey.hpcc.uh.edu>
>> On Mon, 05 Nov 2001 18:18:39 GMT,
>> "Rob" <robsjobs@hotmail.com> said:
> ...
Can you explain this again in English please? (I'm not
being snide, it really makes much more sense to actually
describe the problem, than describe a vague attempt at
solving a problem without the original intent and
context.)
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: Mon, 05 Nov 2001 18:42:49 GMT
From: "Rob" <robsjobs@hotmail.com>
Subject: Re: Can you help optimize this??
Message-Id: <J4BF7.17108$zK1.5824838@typhoon.tampabay.rr.com>
"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87snbtqdrv.fsf@limey.hpcc.uh.edu...
> >> On Mon, 05 Nov 2001 18:18:39 GMT, "Rob" <robsjobs@hotmail.com> said:
> ...
>
> Can you explain this again in English please? (I'm not
> being snide, it really makes much more sense to actually
> describe the problem, than describe a vague attempt at
> solving a problem without the original intent and
> context.)
I have a list of products by abreviation PA, PN, PR, PT. I have a list of
customers with ID's such as A95412. Each customer purchases products so for
a particular customer "A95412" I have a list of purchased products
"AB,AC,AF,GR,PR" when my program runs, foreach customer, then foreach
abreviation, if the abreviation exists within the list of purchased products
for the customer I need to process the order.
How do I optomize the routine that matches the occurance of the product "PR"
within the string "AB,AC,AF,GR,PR"? Using index works but is a pig.
Thanks.
------------------------------
Date: 5 Nov 2001 19:01:57 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Can you help optimize this??
Message-Id: <9s6nn5$7vj$1@bob.news.rcn.net>
Rob <robsjobs@hotmail.com> wrote:
> I have a list of products by abreviation PA, PN, PR, PT. I have a list of
> customers with ID's such as A95412. Each customer purchases products so for
> a particular customer "A95412" I have a list of purchased products
> "AB,AC,AF,GR,PR" when my program runs, foreach customer, then foreach
> abreviation, if the abreviation exists within the list of purchased products
^^^^^^
> for the customer I need to process the order.
When you see the word "exists," think "I need a hash somewhere."
Also, your logic strikes me as a little inside out. Wouldn't it be
simpler to go through each customer's list of purchased products,
processing them as needed, rather than going through the whole list of
available products and seeing if the customer ordered each of them? It
should also be much faster, assuming that each customer only purchases a
fraction of the available products. Once you decide on the nesting
structure of the processing, pick data structures that will make it easy.
------------------------------
Date: Mon, 05 Nov 2001 09:12:57 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: cannot access value of $hash{key}, but graphical debugger says it is there...
Message-Id: <3BE6AC79.80F274EE@home.com>
Bernhard wrote:
>
> my code looks something like that:
>
> 1: my %testhash(test1 => 1, test2 => 2,);
Syntax error. This should be
my %testhash = (test1 => 1, test2 => 2,);
> 2: my $test;
> 3: $test = $testhash{'test2'};
> [...]
>
> i am really confused now, because i cannot see, why this does
> not work;
> $testhash{'test2'} tells me that there is stored the value 1,
That's a problem, because it should be '2' based on what you've shown
us.
> but $test says me: undef, but why;
I don't know, the bit above works once you get rid of the syntax error.
The problem must be in part of the program you didn't show us. :/
-mjc
------------------------------
Date: 5 Nov 2001 18:11:46 GMT
From: "Marianne Sisto" <msisto@chat.carleton.ca>
Subject: Cookies again
Message-Id: <9s6kp2$16m$1@bertrand.ccs.carleton.ca>
Hi, thanks for the previous information. However, I need to store for each
user, a list of courses. I have these
courses stored in an array. How can I store the data from an array into a
cookie?
Thank you
------------------------------
Date: Mon, 5 Nov 2001 19:02:25 +0000 (UTC)
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: Grep on Last Line Only
Message-Id: <b6da963eb9462b867278b8b578c34160.38849@mygate.mailgate.org>
I have a directory of files, and I want to find where the last line is blank,
i.e. just contains a carriage return.
I know I can search for ^$, but is there a way to limit it to flag only the
last line of a file?
--
Posted from [65.193.99.4]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Mon, 05 Nov 2001 16:18:22 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Help with a tough algorithm
Message-Id: <3be6bbcd.638b$9b@news.op.net>
In article <slrn9u1pun.qd3.trammell@haqq.el-swifto.com>,
John J. Trammell <trammell@haqq.hypersloth.invalid> wrote:
>On 31 Oct 2001 20:12:13 -0800, Tommy Butler wrote:
>> I'm trying to get a six-character string *in stepped sequence*
>> from the array of possible unique six-character strings for the
>> character class of [a-zA-Z0-9_].
>
>Booya!
>
>#!/usr/bin/perl -lp
>BEGIN {use integer;@f=('A'..'Z','a'..'z',0..9,"_");
>sub x{!(caller(5))&&($_[0]%@f,x($_[0]/@f))}}
>s/$_/reverse map($f[$_],x($_))/e;
Yow! 62523502209 lines of printed output. I know *I'm* scared.
Try this:
sub make_strings {
my @alphabet = split //, shift();
my $length = shift;
my @odometer = (0) x $length;
my $FINISHED = 0;
return sub {
return if $FINISHED;
my $string = join '', @alphabet[@odometer];
my $i;
for ($i = $#odometer; $i >= 0; --$i) {
++$odometer[$i];
if ($odometer[$i] > $#alphabet) {
$odometer[$i] = 0;
} else {
last;
}
}
if ($i < 0) {
$FINISHED = 1;
}
return $string;
}
}
This function manufactures an iterator object:
my $obj = make_strings('abcd', 3); # 3 is the length
The iterator object will produce a different string each time you call it:
my $next_string = $obj->(); # that's how you get the next string
for (1.. 10) {
print $obj->(); # print ten more strings
}
# get all the rest of the strings
while (defined(my $s = $obj->())) {
# do something with $s
}
Since you can't possibly use 62.5 billion strings, this is the only
method that makes sense. Any method that tries to generate all the
62523502209 strings in advance is doomed.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 5 Nov 2001 10:51:24 -0800
From: ralf@pps.de (Ralf Inceoglu)
Subject: mod_perl - a last man standing-problem
Message-Id: <cd4f0a13.0111051051.7b61748b@posting.google.com>
Hello
I' set up an apache (1.3.20) with mod_perl (1.26) and other modules, then
created a script which uses Apache::Session::File and everything worked
fine. But when i copied and modified the script for some other purpose, i
got the problem that only one of them can run. Every script alone does
fine, but when the 2nd script is called, the first one get hurt regardless
which of them is first. Get hurt means that some requsts for the first
script may get solved, depending on which httpd is met and which of
them has seen the second script. It looks like one httpd can hold only
one mod-perl-script.
I've read a lot FAQs which telling me that the required libs are read only
once, but they are testet threadsafe (as can be with perl). I also tried
different paths for them as recommended, but that dosn't help anyway.
Can anyone help me with that "last man standing" problem ? I don't want to
use different servers for each job, and i want to use the same libs for
each job, because all purposes are in one project.
Regards
Ralf Inceoglu
------------------------------
Date: Mon, 05 Nov 2001 09:19:55 -0800
From: Paul Spitalny <pauls@cascadelinear.com>
Subject: Re: Need help with character substitution
Message-Id: <3BE6CA3B.4940671C@cascadelinear.com>
Paul Spitalny wrote:
> Hi ,
> I have a file with a bunch of lines of text like this:
> i12.i35.i57
> I want to substitute all instances of "i" with and "xi" like so:
> xi12.xi35.xi57
>
> I know I need to do something like the following, but it won't work:
>
> $line = s/i/xi/g;
>
> the problem is that the x is a pattern match for 0 or more of something.
>
> So, what is the correct syntax?
>
> I also have a similar problem where some lines of my files have a dot
> "." that needs to be changed into another character but the dot matches
> any character except newline. So, it is a very similar problem where I
> want to match to a particular character that Perl happens to use as a
> regular expression match.
>
> Need help!
>
> Thanks,
>
> Paul
Thanks guys,
I appreciate your help!
------------------------------
Date: Mon, 05 Nov 2001 16:54:44 GMT
From: "Mike Mackay [Ultrafusion]" <newsgroup_mike@ultrafusion.co.uk>
Subject: Re: Need help: Looping mailer using too many resources
Message-Id: <ovzF7.1704$Yk5.202402@news1.cableinet.net>
Hi,
With Sendmail you could try placing the messages in a queue as 'Mark
Jason Dominus' suggested. The code to do this when implementing Sendmail is
the following on open a connection :
open(MAIL,"|$mailprog -oi -t -odq")") || &CgiError ("Sendmail Error: $!");
Quote from FAQ :
The -oi option prevents sendmail from interpreting a line consisting of
a single dot as "end of message". The -t option says to use the headers
to decide who to send the message to, and -odq says to put the message
into the queue. This last option means your message won't be immediately
delivered, so leave it out if you want immediate delivery.
HTH,
Mike Mackay.
------------------------------
Date: Mon, 05 Nov 2001 16:56:36 GMT
From: "Mike Mackay [Ultrafusion]" <newsgroup_mike@ultrafusion.co.uk>
Subject: Re: Need help: Looping mailer using too many resources
Message-Id: <8xzF7.1711$Yk5.203099@news1.cableinet.net>
Oops, sorry there's an Error in that code, it should show as follows :
open(MAIL,"|$mailprog -oi -t -odq") || &CgiError ("Sendmail Error: $!");
Sorry about that!!
Mike Mackay
------------------------------
Date: Mon, 05 Nov 2001 16:56:34 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: Need help: Looping mailer using too many resources
Message-Id: <Xns91507A71E7036dragnetinternalysisc@207.35.177.134>
mjd@plover.com (Mark Jason Dominus) wrote in
news:3be6b54e.616f$1bb@news.op.net:
>
> You're trying to run 2000 copies of the mailer at the same time. It
> is not too surprising that the machine is crashing.
>
> I suggest that you put code into the loop to moderate the number of
> messages you send at once. You might try having your program sleep
> for a few seconds after every ten or twenty messages.
>
>>while (<RMAIL>) {
>> ...
>> close (MAIL);
> if (++$num_sent % 10 == 0) {
> sleep 3;
> }
>>}
Ahhh!! Thank you! It is running smoothly, even as I type this and storing
sent addresses in the WSENT file for progress.
Thank you very much, again!
--
----------------------------
Marc Bissonnette
InternAlysis
Intelligence in Internet Communications
http://www.internalysis.com
------------------------------
Date: Mon, 05 Nov 2001 17:00:09 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: Need help: Looping mailer using too many resources
Message-Id: <Xns91507B0C0C435dragnetinternalysisc@207.35.177.134>
"Mike Mackay [Ultrafusion]" <newsgroup_mike@ultrafusion.co.uk> wrote in
news:ovzF7.1704$Yk5.202402@news1.cableinet.net:
> Hi,
> With Sendmail you could try placing the messages in a queue as
> 'Mark
> Jason Dominus' suggested. The code to do this when implementing
> Sendmail is the following on open a connection :
>
> open(MAIL,"|$mailprog -oi -t -odq")") || &CgiError ("Sendmail Error:
> $!");
>
> Quote from FAQ :
> The -oi option prevents sendmail from interpreting a line
> consisting of a single dot as "end of message". The -t option says
> to use the headers to decide who to send the message to, and -odq
> says to put the message into the queue. This last option means your
> message won't be immediately delivered, so leave it out if you want
> immediate delivery.
Thanks for the code tip; If I may ask another question, especially since
I'm not a sendmail expert: What happens when the mail is sent to the queue?
I mean, I know it's sent eventually, but is the timing of processing the
queue something that is set in sendmail.conf (or whatever it's
configuration file is). Does sendmail deal with it's queue more efficiently
on it's own, rather than having me feed it mail one at a time?
If there is a FAQ that is more efficient for me to brush up on, I'd be
happy to pore through it :)
--
----------------------------
Marc Bissonnette
InternAlysis
Intelligence in Internet Communications
http://www.internalysis.com
------------------------------
Date: Mon, 05 Nov 2001 18:19:19 GMT
From: "Mike Mackay [Ultrafusion]" <newsgroup_mike@ultrafusion.co.uk>
Subject: Re: Need help: Looping mailer using too many resources
Message-Id: <HKAF7.2038$Yk5.251077@news1.cableinet.net>
I personally don't know an awful lot about the ins & outs of Sendmail
however, If you're wanting to read up all about it you could visit the
following wesbite :
http://www.sendmail.org/
Theres lots of FAQ's and other information. Alternatively there is also a
newsgroup devoted to the subject, noteably found here :
comp.mail.sendmail
Glad you've sorted your problem out :-)
Mike Mackay
------------------------------
Date: Mon, 5 Nov 2001 13:59:29 -0500
From: "-=bina" <robin@cboss.com>
Subject: Newbie needing assistance in setting up server for PerlScripts capability
Message-Id: <1004986027.468258@unix.cboss.com>
I'm new to PerlScripts -- we do everything in ASP -- but I have a valued
client interested in using Perl for their website.
Using a WindowsNT v4 Server with IISv4 -- how does one go about supporting
such scripts?? I went to www.perl.com and downloaded the latest source code
distribution: stable.zip.
After unzipping the file -- I can't quite narrow down exactly how to
configure it to work with IIS to allow my client to operate with
PerlScripts.
I have Windows2000 Advanced Servers with IISv5 too in case the site would
need setup on a different server???
Any guidance in this matter would be most appreciated.
Thanks!!
-=bina
------------------------------
Date: Mon, 05 Nov 2001 16:26:55 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Question on File uploading.
Message-Id: <3be6bdcf.6452$17b@news.op.net>
In article <bc7d7750.0111050133.170d188b@posting.google.com>,
Jason Kelley <loophole64@home.com> wrote:
>I'm trying to upload a file through a form that several input fields,
>including the file input. I don't want to use CGI.pm for efficiency
>reasons.
Good luck.
>What is the format of $upload_data? I would expect it to be something
>like:
>
>team1=clodhoppers&team2=boppy&map=firefields&FileInfoHere...
>
>But that doesn't seem to be the case. Does the file info come first?
>And where exactly is the file name in relation to the file data? Any
>info to help me understand this would be appreciated. Thanks.
Detailed information is available at:
http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc1867.html
You will need to read (and understand) this if you want to reimplement
file upload.
An alternative is to look into CGI.pm and see how the file upload is
handled there and either copy the code from CGI.pm or reimplement it
yourself.
I will be very interested to hear if your implementation is more
'efficient' than the CGI.pm implementation.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Mon, 05 Nov 2001 10:38:49 -0800
From: Ned Konz <ned@bike-nomad.com>
Subject: Re: Serial Port control under Win32::SerialPort
Message-Id: <tudmvtgvjhuc4a@corp.supernews.com>
David wrote:
> Thanks for the response. From what I understand the
> $PortObj->rts_active(Yes) call only returns the status of the API
> call, it does not set the state of the bit.
Which API do you think it calls?
> As for $ModemStatus = $PortObj->modemlines;
> if ($ModemStatus & $PortObj->MS_RLSD_ON) { print "carrier
> detected"; }
>
> I'm not sure what $PortObj->modemlines does - I'm not using a modem,
> so I guess I need to understand that before I can use it. If I look at
> what $PortObj->MS_RLSD_ON returns - it's always 128 which seems
> incorrect as I don't always have the carrier signal high.
The modem control and status lines (DCD, RTS, DTR, etc.) don't care whether
or not you have a modem. modemlines() returns the state of the modemlines,
and you just mask the bit(s) you need.
Of course MS_RLSD_ON always returns a 128; it's a bitmask constant that you
just bitwise-AND with the modemlines() return value, as I showed.
------------------------------
Date: Mon, 05 Nov 2001 09:34:46 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Sorting an array - help please
Message-Id: <3BE6B196.581ABC62@home.com>
fred56 wrote:
>
> sub main {
You must be a C transplant. You don't need a 'main' subroutine in Perl.
> open(DATA, "< $file") or die "Can't open $file: $!";
Checking the status of open(), good! But are you aware that DATA is a
special file handle in Perl? What you're doing isn't harmful, but it may
be confusing to some people.
> @tabledata=split(/\s*\¶\s*/, $_);
>
> ($second_del,$third_del,$fourth_del,$fifth_del,$sixth_del,$eighth_del)
> = @tabledata[1,2,3,4,5,7];
Why the numeric names? This is cleaner:
my @del = @tabledata[1..4, 5, 7];
Of course, there's no need for the temporary array:
my @del = (split(/\s*\¶\s*/, $_))[1..4, 5, 7];
> what i want to be able to do is sort the array based on the third
> field of the @tabledata
Sort what array? The only one I see is @tabledata, and you can't sort an
array by a single element.
> iv nearly finished reading learning perl but the book does not go
> into that much detail in regards to the sort function or if it does
> i haven't read that part yet
Never fear, the FAQ can help. Type 'perldoc -q sort' at a command line.
perlfaq4 "How do I sort an array by (anything)?" should have all the
help you need. (If it doesn't, the good folks here can help.)
-mjc
------------------------------
Date: Mon, 05 Nov 2001 18:08:47 +0000
From: fred56 <plain@englishtec.freeserve.co.uk>
Subject: Re: Sorting an array - help please
Message-Id: <i3lduts44pfnsbdga7bebk6dfupoc3sb94@4ax.com>
On Mon, 05 Nov 2001 09:34:46 -0600, Michael Carman <mjcarman@home.com>
wrote:
>fred56 wrote:
>>
>> sub main {
>
>You must be a C transplant. You don't need a 'main' subroutine in Perl.
>
>> open(DATA, "< $file") or die "Can't open $file: $!";
>
>Checking the status of open(), good! But are you aware that DATA is a
>special file handle in Perl? What you're doing isn't harmful, but it may
>be confusing to some people.
>
>> @tabledata=split(/\s*\¶\s*/, $_);
>>
>> ($second_del,$third_del,$fourth_del,$fifth_del,$sixth_del,$eighth_del)
>> = @tabledata[1,2,3,4,5,7];
>
>Why the numeric names? This is cleaner:
> my @del = @tabledata[1..4, 5, 7];
>
>Of course, there's no need for the temporary array:
> my @del = (split(/\s*\¶\s*/, $_))[1..4, 5, 7];
>
>> what i want to be able to do is sort the array based on the third
>> field of the @tabledata
>
>Sort what array? The only one I see is @tabledata, and you can't sort an
>array by a single element.
>
>> iv nearly finished reading learning perl but the book does not go
>> into that much detail in regards to the sort function or if it does
>> i haven't read that part yet
>
>Never fear, the FAQ can help. Type 'perldoc -q sort' at a command line.
>
>perlfaq4 "How do I sort an array by (anything)?" should have all the
>help you need. (If it doesn't, the good folks here can help.)
>
>-mjc
Thanks didn't solve my problem but it did make me realise im going
about it the wrong way which is just as good thanks.
------------------------------
Date: Mon, 05 Nov 2001 16:19:24 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Tracing ["non-interactive debugging"] like in REXX?
Message-Id: <g_yF7.64123$Gh2.19478011@news2.rdc1.bc.home.com>
In article <3BDD0F15.6C97D997@web.de>,
Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de> writes:
>Problem solved:
>
>perldoc B::Concise
>
>is what I am looking for ...
>hopefully it will run with Perl on OS/2 ....
Eh? B::Concise provides a static analysis of a program's parse tree, it
doesn't run it and hence can't possibly provide what you were looking for.
--
Peter Scott
http://www.perldebugged.com
------------------------------
Date: Mon, 05 Nov 2001 17:50:15 +0100
From: Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de>
Subject: Re: Tracing ["non-interactive debugging"] like in REXX?
Message-Id: <3BE6C347.2B44E987@web.de>
Peter Scott wrote:
> Eh? B::Concise provides a static analysis of a program's parse tree, it
> doesn't run it and hence can't possibly provide what you were looking for.
Shame on me; you are so right.
Lessons learned: never ever do test like "perl -MO=Concise sum.pl 1 2"
and think: "thats it, cause 1, 2 and 3 appear in the output".
Thank you for pointing out that!
------------------------------
Date: 5 Nov 2001 09:32:58 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Using Perl to set Unix environmental variables
Message-Id: <3be6cd4a@news.victoria.tc.ca>
Tal Cohen (tncohen@avaya.com) wrote:
: Hi,
: I want to create a Perl script that will set the Unix
: environmental variables. I tried the %ENV hash, but it will only set
: the variable for the current and subsequent processes (children). I
: tried having Perl do an exec "source <some_script_name>" when the
: <some_script_name> file had a setenv command in it. I also tried this
: with system instead of exec.
: Any ideas?
The perl script must output the text of the shell commands that will
control your environment, and you must ask the shell to use those commands
via a source or possibly eval statement. It might be easiest to use a
shell function as a wrapper.
in bash
perl set-env.pl > tmp.sh
. ./tmp.sh # source the commands
I think you can use the eval command as follows (but can't check right
now)
eval `perl set-env.pl`
( The perl script would output lines such as
VAR1="the value of var1"
cd the/dir/we/want
# etc etc etc
)
--
Want to access the command line of your CGI account? Need to debug your
installed CGI scripts? Transfer and edit files right from your browser?
What you need is "ispy.cgi" - visit http://nisoftware.com/ispy.cgi
------------------------------
Date: Mon, 05 Nov 2001 17:02:12 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: XML::Records (was Re: XML parsing)
Message-Id: <jjgdut4aqe7jbvq90n3fl0j2isj8voh0uj@4ax.com>
Eric Bohlman wrote:
>I'm working on XML::Pull, which is eventually going to supercede
>XML::Records and XML::TokeParser.
But I *like* XML::TokeParser. ;-) The conciseness by which the method
get_simple_tree is written, is extremely nice. (BTW shouldn't this have
been called get_easy_tree? Because what it returns is probably
compatible with XML::Parser::EasyTree... ;-)
Oh, I found a bug in it. You should drop the dependency on $top. Because
now, if your XML looks like:
<foo id="a123">
<included>This is included</included>
<foo>here it ends</foo>
<ignored>This drops off</ignored>
</foo>
with $p->set_records('foo'), then $p->get_simple_tree returns:
$VAR1 = {
'attrib' => { 'id' => 'a123' },
'content' => [
{ 'content' => '
', 'type' => 't' },
{ 'attrib' => {}, 'content' => [
{ 'content' => 'This is included',
'type' => 't' } ],
'type' => 'e', 'name' => 'included' },
{ 'content' => '
', 'type' => 't' },
{'attrib' => {}, 'content' => [
{ 'content' => 'here it ends',
'type' => 't' }
],
'type' => 'e', 'name' => 'foo' }
],
'type' => 'e', 'name' => 'foo'
};
In short: you can't have embedded tags with the same name as the top
level record tag.
To fix that, replace
elsif ($type eq 'E') {
$curlist=pop @$lists;
last if $token->[1] eq $top;
}
with
elsif ($type eq 'E') {
$curlist=pop @$lists;
@$lists or last;
}
and drop all other code using $top.
--
Bart.
------------------------------
Date: 5 Nov 2001 18:32:56 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: XML::Records (was Re: XML parsing)
Message-Id: <9s6m0o$4eh$1@bob.news.rcn.net>
Bart Lateur <bart.lateur@skynet.be> wrote:
> But I *like* XML::TokeParser. ;-) The conciseness by which the method
> get_simple_tree is written, is extremely nice. (BTW shouldn't this have
> been called get_easy_tree? Because what it returns is probably
> compatible with XML::Parser::EasyTree... ;-)
Actually, it's now deprecated as it's better to use drive_SAX() on an
XML::Handler::EasyTree object (from XML::Handler::Trees).
> Oh, I found a bug in it. You should drop the dependency on $top. Because
> now, if your XML looks like:
Fixed. drive_SAX() had the same problem, which was also fixed. 0.12 is
now available from my site and making its way through CPAN.
------------------------------
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 2071
***************************************