[22376] in Perl-Users-Digest
Perl-Users Digest, Issue: 4597 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 20 21:05:53 2003
Date: Thu, 20 Feb 2003 18: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, 20 Feb 2003 Volume: 10 Number: 4597
Today's topics:
Re: /^-?(?:\d+(?:\.\d*)?\d+)$/ <remccart@uiuc.edu.spam>
Re: /^-?(?:\d+(?:\.\d*)?\d+)$/ <abigail@abigail.nl>
Re: A regex to shorten up this command line <abigail@abigail.nl>
Re: Also religious: brackets <david@port80.com>
Re: Also religious: brackets <abigail@abigail.nl>
Re: array of hash trouble (Anno Siegel)
Get Public IP Address of Linux Machine <jc_va@hotmail.com>
Re: Get Public IP Address of Linux Machine (Walter Roberson)
Re: Get Public IP Address of Linux Machine <crgutierNO@SPAMdcc.uchile.cl>
Re: Get Public IP Address of Linux Machine <jc_va@hotmail.com>
Re: Get Public IP Address of Linux Machine <abigail@abigail.nl>
Re: Get Public IP Address of Linux Machine <jeff@vpservices.com>
Re: Having problems writing a tar file. Correction <bwalton@rochester.rr.com>
Re: How do I get the current date? <abigail@abigail.nl>
Re: How do I get the current date? <abigail@abigail.nl>
Re: Newbie Q re form to mail script FormProcessorPro (Tad McClellan)
Re: Newbie Q re form to mail script FormProcessorPro <notworking@all.com>
Re: Newbie Q re form to mail script FormProcessorPro <notworking@all.com>
Re: Passing Hard Referance down more than one Sub <krahnj@acm.org>
Perl Compiler? <mail@annuna.com>
Re: Problem with buffering on non-blocking socket under <news@wildgooses.com>
Re: Report physical RAM of a remote PC <newsfeed2@boog.co.uk>
Re: Report physical RAM of a remote PC <abigail@abigail.nl>
Re: storing regex vars into array and not $1 $2 etc <abigail@abigail.nl>
Re: Switch order of sprintf conversions <noreply@gunnar.cc>
Re: Switch order of sprintf conversions <uri@stemsystems.com>
Re: Switch order of sprintf conversions (Jay Tilton)
Re: UNIX: creating a command line alias (Walter Roberson)
Re: use DBI; <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 Feb 2003 19:52:09 -0600
From: Ryan McCarthy <remccart@uiuc.edu.spam>
Subject: Re: /^-?(?:\d+(?:\.\d*)?\d+)$/
Message-Id: <dzf5a.1012$o7.12725@vixen.cso.uiuc.edu>
Uri Guttman wrote:
>>>>>>"RM" == Ryan McCarthy <remccart@uiuc.edu.spam> writes:
>
>
> RM> Can somebody provide me some insight as to why the following matches
> RM> numbers like 25, 25.0, 5.0 but NOT '5'? Thanks!
>
> RM> /^-?(?:\d+(?:\.\d*)?\d+)$/
> ^^^ ^^^
>
> each of those matches at least 1 digit so single digit numbers will
> never be matched
So how would I make it match both .7 and 5?
------------------------------
Date: 21 Feb 2003 02:01:21 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: /^-?(?:\d+(?:\.\d*)?\d+)$/
Message-Id: <slrnb5b23g.jl9.abigail@alexandra.abigail.nl>
Ryan McCarthy (remccart@uiuc.edu.spam) wrote on MMMCDLXI September
MCMXCIII in <URL:news:dzf5a.1012$o7.12725@vixen.cso.uiuc.edu>:
$$ Uri Guttman wrote:
$$ >>>>>>"RM" == Ryan McCarthy <remccart@uiuc.edu.spam> writes:
$$ >
$$ >
$$ > RM> Can somebody provide me some insight as to why the following matches
$$ > RM> numbers like 25, 25.0, 5.0 but NOT '5'? Thanks!
$$ >
$$ > RM> /^-?(?:\d+(?:\.\d*)?\d+)$/
$$ > ^^^ ^^^
$$ >
$$ > each of those matches at least 1 digit so single digit numbers will
$$ > never be matched
$$
$$ So how would I make it match both .7 and 5?
use Regexp::Common;
/^$RE{num}{real}$/
Abigail
--
sub J::FETCH{Just }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
sub P::FETCH{Perl }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}
------------------------------
Date: 20 Feb 2003 23:57:40 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: A regex to shorten up this command line
Message-Id: <slrnb5aqrk.jl9.abigail@alexandra.abigail.nl>
Peter Shankey (oxmard.Rules@ab.ab) wrote on MMMCDLX September MCMXCIII in
<URL:news:9YScnfoeuuT1t8ijXTWcqg@comcast.com>:
<> c:\wip\perl>perl -v
<>
<> This is perl, v5.8.0 built for MSWin32-x86-multi-thread
<> (with 1 registered patch, see perl -V for more detail)
<>
<>
<> After I RTFM a bit I came up with this:
<>
<> perl -ne "if (/A_String/){$seen{$i}++;}END {print $seen{$i}}"
<> load_customers.sql
<>
<> However is there a way to shorten this up a bit. Something like
<>
<> perl -ne "some_regex/A_String/" load_customers.sql
<>
<> that would print out the number of lines matched in the file?
Sometimes, specially with one liners, the shortest way of doing
the task is by not using perl:
grep -c A_String load_customers.sql
Abigail
--
perl -Mstrict='}); print "Just another Perl Hacker"; ({' -le1
------------------------------
Date: Thu, 20 Feb 2003 23:13:40 +0000
From: David Scholefield <david@port80.com>
Subject: Re: Also religious: brackets
Message-Id: <BA7B11A4.52D%david@port80.com>
On 20/2/03 5:54 pm, in article
ba162549.0302200954.2bae920a@posting.google.com, "Kevin Cline"
<kcline17@hotmail.com> wrote:
> Benjamin Goldberg <goldbb2@earthlink.net> wrote in message
> news:<3E541C12.91543E0B@earthlink.net>...
>> Sandman wrote:
>>>
>>> How do you use brackets in your code in loops or if statements? Here
>>> are some versions I can come up with:
>> [snip]
>>> Any other variations you prefer? I am a #1 guy myself, but use #2 if
>>> the do's are one-liners.
>>
>> If the two branches are single expressions, then I sometimes prefer to
>> use ?: instead of if(){}else{}.
>>
>> Also, while I normally use something like your #1, I put the spaces a
>> bit differently:
>>
>> if( statement ) {
>> ... do ...
>> } else {
>> ... do ...
>> }
>
>>
>> [Note the lack of a space between the 'if' and the '(', the space after
>> the '(', the space before the ')', and the space between the ')' and
>> the '{'.]
>
> We noticed. I think this style is poor because it is contrary
> to the standard practice when typesetting text or mathematics.
> When typesetting, an opening parenthesis never followed by a space,
> nor is a closing parenthesis preceded by a space. We have centuries
> of practice doing this. Writing code differently just slows the
> reader.
>
>
>>
>> Sometimes, 'statement' is really lengthy... I'll sometimes write code
>> as:
>>
>> if( statement1 &&
>> statement2 &&
>> statement3
>> ) ...
>
> Breaking statements before operators makes it easier to see the
> structure of the code as one scans along the left margin.
> Breaking lines before operators is standard practice
> in mathematical typesetting, and I see no reason
> why code should be treated differently.
This is the bizarrest thing, and I've never really agreed with
this, indenting code for all multi-line constructs seems more
natural (to me!) when it matches the conditional/loop/whatever
statement, i.e.
if (condition)
{
do something;
and do something else;
and maybe some more;
}
else
{
here is the alternative;
}
Here the parenthesis of the compound statement is clearly in-line
with the reason you're doing it because it is at the same level
of indentation
Everyone likes something different, but this seems completely
natural!
------------------------------
Date: 21 Feb 2003 00:14:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Also religious: brackets
Message-Id: <slrnb5arqc.jl9.abigail@alexandra.abigail.nl>
Ryan Shondell (shondell@cis.ohio-state.edu) wrote on MMMCDLX September
MCMXCIII in <URL:news:xcw8ywaooll.fsf@psi.cis.ohio-state.edu>:
** Malte Ubl <ubl@schaffhausen.de> writes:
**
** > Ryan Shondell wrote:
** > > "Peter Cooper" <newsfeed2@boog.co.uk> writes:
** > >
** >
** > >>>One-liners goes like this;
** > >>>
** > >>> do if ( statement );
** > >>
** > >>If I have a 'debug' or verbose switch in a program I tend to
** > >>implement it like so:
** > >>
** > >>$debug && print $variable;
** > > Wow, that's almost a carbon-copy example of what perlstyle says _not_
** >
** > > to do, because it hides the main point of the statement.
** >
** > No it doesn't, because here you got the very import C<$debug> as the
** > first word on the line. I prefer the written C<and> though.
**
** The part from perlstyle that I am refering to is:
**
But giving any authority to 'perlstyle' contradicts 'perlstyle' itself:
Larry has his reasons for each of these things, but he
doesn't claim that everyone else's mind works the same as
his does.
Abigail
--
$_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
. "\162\1548\110\141\143\153\145\162\0128\177" and &japh;
sub japh {print "@_" and return if pop; split /\d/ and &japh}
------------------------------
Date: 20 Feb 2003 23:08:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: array of hash trouble
Message-Id: <b33n5b$31t$1@mamenchi.zrz.TU-Berlin.DE>
Morpheus <daddyefsacks@yahoo.com> wrote in comp.lang.perl.misc:
> Hello all,
>
> I have a data structure built like this:
>
> push @all_data, { DAY => $day,
> TIME => $time,
> CHAN_NUM => $chan_num,
> CHANNEL => $chan_name
> DATA => [ @data ]
> };
>
> First of all the reason I am using an array of hash is because I need
> to sory the data in CHAN_NUM, DAY, TIME order after all the data from
> a file has been read in. I do that by:
>
> @all_data = sort {
> $a->{CHAN_NUM} <=> $b->{CHAN_NUM}
> ||
> $sort_day_hash{$a->{DAY}} <=>
> $sort_day_hash{$b->{DAY}}
> ||
> $sort_time_hash{$a->{TIME}} <=>
> $sort_time_hash{$b->{TIME}}
> } @all_data;
>
> That all works fine, my problem is after the data is sorted I need to
> be able to easily find all the data for a particular channel (CHANNEL
> from the hash) from anywhere in the array of hash and I'm not sure how
> to do this without iterating through the entire array of hash
> everytime. Optimally I think I would want to have a hash of array or
> something like that where the hash key is CHANNEL and the array holds
> all the data. So anyway I was wondering if there is anyway to easily
> convert this array of hash to a hash of array without having to
> iterate through the thing with a for loop.
So you want both, direct access to the data through the CHANNEL key
and sorted access through a list. You will need an auxiliary data
structure to do this.
With minimal change to the program as it is now, you could add an
auxiliary hash that stores, for each channel, the index into @all_data
where the data can be found.
my %aux; # for want of a better name
@aux{ map $_->{ CHANNEL}, @all_data} = 0 .. $#all_data;
should build it, though I haven't tested. It does iterate over
@all_data, but only once, not for each access.
To access the data for a channel $ch, do "$all_data[ $aux{ $ch}]".
This leaves all the rest of the program intact.
Your original Idea to make the primary data structure a hash keyed
on channels can be similarly realized, but would require larger changes
in existing code. In that case, you'd use an auxiliary array of hash
keys (channels), that point to the hash entry in sorted order.
There are also modules on CPAN that combine sorted access and keyed
access (and hide the auxiliary data structure), usually in the form
of a tied hash.
> And also in general if
> anyone sees a better approach to my problem. This is my first actual
> perl program so any advice is welcome and my first actual post here so
> sorry if I did anything wrong :)
You did very well, with your code as well as with your question.
Anno
------------------------------
Date: Fri, 21 Feb 2003 00:50:47 GMT
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: Get Public IP Address of Linux Machine
Message-Id: <HJe5a.40178$P1.2708832@news1.east.cox.net>
I am beating my brains out on this one. I have a linux machine behind a
cable router. Using things like ifconfig will only give me the internal
network address. I want to get the actual public intenet address. Are
there any perl one-liners that can do this?
------------------------------
Date: 21 Feb 2003 00:58:21 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Get Public IP Address of Linux Machine
Message-Id: <b33tjd$8r7$1@canopus.cc.umanitoba.ca>
In article <HJe5a.40178$P1.2708832@news1.east.cox.net>,
Buck Turgidson <jc_va@hotmail.com> wrote:
:I am beating my brains out on this one. I have a linux machine behind a
:cable router. Using things like ifconfig will only give me the internal
:network address. I want to get the actual public intenet address. Are
:there any perl one-liners that can do this?
Tricky. The linux machine doesn't really -have- a public IP address
in that case: the public IP address belongs to the cable router.
You could work on the possibility of sending a packet to a remote machine
that just happens to reply with your address as a text string, but you
probably aren't going to be able to get that to work in one line.
Probably the most direct route would be to do an SNMP query onto
your cable router and have it tell you the external IP.
--
Admit it -- you peeked ahead to find out how this message ends!
------------------------------
Date: Fri, 21 Feb 2003 00:11:21 +0000 (UTC)
From: Cristian Gutierrez <crgutierNO@SPAMdcc.uchile.cl>
Subject: Re: Get Public IP Address of Linux Machine
Message-Id: <b33qr9$mm3$1@helcaraxe.dcc.uchile.cl>
Buck Turgidson posteo' asi':
> I am beating my brains out on this one. I have a linux machine behind a
> cable router. Using things like ifconfig will only give me the internal
> network address. I want to get the actual public intenet address. Are
> there any perl one-liners that can do this?
perl -e 'system "wget -O /dev/stdout http://www.whatismyip.com/" '
Or.. you could just skip the perl wrapper *:^)
--
Cristian Gutierrez Linux user #298162
crgutier[@]dcc.uchile.cl http://www.dcc.uchile.cl/~crgutier
Customer Support is like Teaching Kindergarten. All day long, you sit
and read to people who can't do it for themselves.
-- Scott perlman@cgicafe.com
------------------------------
Date: Fri, 21 Feb 2003 01:15:27 GMT
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: Re: Get Public IP Address of Linux Machine
Message-Id: <P4f5a.40328$P1.2718919@news1.east.cox.net>
Yes, this is a tough nut to crack.
The most promising thing so far is using lynx to call my router config
page, but I am having trouble with the user/pass.
------------------------------
Date: 21 Feb 2003 01:50:41 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Get Public IP Address of Linux Machine
Message-Id: <slrnb5b1fh.jl9.abigail@alexandra.abigail.nl>
Buck Turgidson (jc_va@hotmail.com) wrote on MMMCDLXI September MCMXCIII
in <URL:news:HJe5a.40178$P1.2708832@news1.east.cox.net>:
}} I am beating my brains out on this one. I have a linux machine behind a
}} cable router. Using things like ifconfig will only give me the internal
}} network address. I want to get the actual public intenet address. Are
}} there any perl one-liners that can do this?
It seems like you are behind a NAT box. Not only is this question
not solvable (we'd need to know more about the setup), the answer
is likely to not be of much use. If you're being NATted by your
ISP, I doubt the ISP is forwarding any ports to your box - you're
likely sharing the "external IP address" with several others.
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: Thu, 20 Feb 2003 17:59:59 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Get Public IP Address of Linux Machine
Message-Id: <3E55881F.2060103@vpservices.com>
Cristian Gutierrez wrote:
> Buck Turgidson posteo' asi':
>
>>I am beating my brains out on this one. I have a linux machine behind a
>>cable router. Using things like ifconfig will only give me the internal
>>network address. I want to get the actual public intenet address. Are
>>there any perl one-liners that can do this?
>>
>
> perl -e 'system "wget -O /dev/stdout http://www.whatismyip.com/" '
>
> Or.. you could just skip the perl wrapper *:^)
Or make it pure perl (paste back into a one-liner):
perl -MLWP::Simple -e
'$_=get("http://www.whatismyip.com");/ip is (\S+)/;print $1'
--
Jeff
------------------------------
Date: Thu, 20 Feb 2003 23:26:28 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Having problems writing a tar file. Correction
Message-Id: <3E55640D.5030603@rochester.rr.com>
Justin A. Graham wrote:
> Bob Walton wrote:
>
>> Justin A. Graham wrote:
...
>>
>> Are you sure? Your snippet works fine for me when I fill it out. The
>> resulting TAR file can be interpreted as basically what you claim in
>> either of your notes: all your files concatendated together (with a
>> bit of binary gibberish, mostly null bytes, inbetween; or, if you
>> happen to examine the end of the file, you might conclude it was all
>> null bytes. The file is actually a perfectly valid TAR file, though.
>> HTH.
>>
>
>
> I should probably add that I am testing this on my windows development
> machine, where the archiving will occur. Perhaps there is something
> funky with the windows implementation of archive::tar
>
> Justin
>
I did mine on Windoze 98SE with AS Perl build 633. The resulting TAR
file could be opened, extracted from etc by WinZip.
--
Bob Walton
------------------------------
Date: 20 Feb 2003 23:41:39 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How do I get the current date?
Message-Id: <slrnb5aptj.jl9.abigail@alexandra.abigail.nl>
Steffen Beyer (Steffen.Beyer@de.bosch.com) wrote on MMMCDLX September
MCMXCIII in <URL:news:b32h3e$6pl$1@ns2.fe.internet.bosch.com>:
??
?? "Tintin" <me@privacy.net> wrote in message
?? news:b32g6a$1dthq0$1@ID-172104.news.dfncis.de...
?? >
?? > "Abigail" <abigail@abigail.nl> wrote in message
?? > news:slrnb583h5.1ea.abigail@alexandra.abigail.nl...
?? > > Hmmm. There is no "the ISO date format". The ISO standard dealing with
?? > > dates defines a whole army of allowed formats.
?? >
?? > OK. ISO 8601
??
?? And even though ISO 8601 also defines several possible variations,
?? they all have in common the order year-month-day (or somesuch
?? sensible order) which makes them easily sortable, which was the
?? point in question in the first place. :-)
Actually, they don't. DDDD-DDD is an allowed format, meaning year and
day of the year. Days may also be left off, DDDD-DD means a month in a
certain year. But both the century and the dash may be left off, giving
you DDDD. And there's DDDDWDD and DDDDWDDD, the first one pointing to
a week in a certain year, the latter to a day in a week in a certain year.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: 20 Feb 2003 23:48:19 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How do I get the current date?
Message-Id: <slrnb5aqa3.jl9.abigail@alexandra.abigail.nl>
Steffen Beyer (Steffen.Beyer@de.bosch.com) wrote on MMMCDLX September
MCMXCIII in <URL:news:b32hfn$712$1@ns2.fe.internet.bosch.com>:
{}
{} "John W. Krahn" <krahnj@acm.org> wrote in message
{} news:3E53FB7A.EB02001E@acm.org...
{} > "Justin A. Graham" wrote:
{} > >
{} > > I want to write a script that zip up files, and names the archive
{} > > file-month-day-year.zip
{} > >
{} > > How do I get the current date in a perl script?
{} >
{} > use POSIX qw(strftime);
{} >
{} > my $file = strftime( 'file-%m-%d-%Y.zip', localtime );
{} >
{} >
{} > John
{} > --
{} > use Perl;
{} > program
{} > fulfillment
{}
{} Without the penalty for loading an additional module,
{} how about this:
{}
{} my @now = localtime();
{} $now[4]++;
{} $now[5] += 1900;
{} my $file = sprintf("file-%04d%02d%02d.zip", @now[5,4,3]);
Well, that would do year, month, day, wouldn't it? The request was
about month, day, year.
{} And yes, this has a Y10K bug (sort of). ;-)
What makes you think there's a Y10K bug?
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: Thu, 20 Feb 2003 16:19:29 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <slrnb5al3h.4ue.tadmc@magna.augustmail.com>
Helgi Briem <helgi@decode.is> wrote:
> On Thu, 20 Feb 2003 15:36:28 -0000, Trilby
><notworking@all.com> wrote:
[snip: gimme gimme gimme ]
> *plonk*
>
> Leave us, moron.
I never saw the moron's posts. If you put
Score:: -9000
X-No-Archive: yes
in your scorefile, then you wouldn't have either.
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 Feb 2003 00:45:30 -0000
From: Trilby <notworking@all.com>
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <MPG.18bf8706780071e09896e7@news.iol.ie>
While busily concocting a devastating reply anno4000@lublin.zrz.tu-
berlin.de retorted
> Trilby <notworking@all.com> wrote in comp.lang.perl.misc:
> > While busily concocting a devastating reply anno4000@lublin.zrz.tu-
> > berlin.de retorted
> > > You asked what you *think* is a simple question. What you did ask
> > > is for somebody to debug your script. Since you didn't give any
> > > information, the request to study the package was implicit.
> >
> > Bullshit. A simple question.
>
> No question is simple when a fool asks it.
>
> Anno
>
And certainly not when an ignorant and unhelpful troll reads it. You are
a real enhancement for this group and it's generosity towards visitors.
Trilby
------------------------------
Date: Fri, 21 Feb 2003 00:48:31 -0000
From: Trilby <notworking@all.com>
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <MPG.18bf87baf9c57dd49896e8@news.iol.ie>
While busily concocting a devastating reply tiltonj@erols.com retorted
> Trilby <notworking@all.com> wrote:
>
> : While busily concocting a devastating reply tiltonj@erols.com retorted
> : > Do I take it that there is no 'obvious' solution ?
> : >
> : > No idea. It may be obvious to someone familiar with the package,
> : > which Perl programmers are evidently not. Not many will go to the
> : > trouble of acquiring and studying a package to debug somebody else's
> : > hangup. Not for free, anyway.
> :
> : Jeeez I just asked a simple question, mate.
>
> I am not your mate.
>
> : I didn't ask anyone to 'study a package' or debug someone else's
> : script.
>
> A physician may be asked an apparently simple question. "Why does my
> foot hurt?" He will take x-rays or run blood tests to diagnose the
> illness accurately. These are his tools, and he will use them whether
> asked to or not.
>
> Program analysis and debugging skill are the programmer's tools.
> Their use is integral to the task. A request to use them is implicit.
> A request not to use them is baffling.
>
> : No need to the sarcasm.
>
> There was no sarcasm. Just facts.
>
> Supporting software requires familiarity. Becoming familiar requires
> work. Work doesn't happen without some reward or benefit.
>
> If the software looks useful or interesting to a programmer, the work
> may carry its own benefit, and he might give informal support.
>
> But this software does not seem at first glance to be especially
> useful or interesting to a programmer. The only thing left to
> motivate him is to pay for his services.
>
> The author/vendor's support services will give better short-term
> value.
>
> : > Best guess, and it's a real WAG, is there's some CRLF mistranslation
> : > going on when the template is uploaded onto the server.
> : >
> : And that was so difficult, was it ?
>
> Was that a thank you?
>
> You're welcome.
>
>
For what ? a gush of patronising and self serving bullshit ?
Get a life and stop trying to impress your betters.
Trilby
------------------------------
Date: Thu, 20 Feb 2003 23:39:30 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Passing Hard Referance down more than one Sub
Message-Id: <3E5566DB.C70529A3@acm.org>
Tom wrote:
>
> Sorry for such a basic question but I have been trying to send a referance
> to an array thru more than one subroutine and I am failing.
> I use say i.e. $referance = \@array1 then call the first subroutine but when
> the first subrountne calls the next and then say I do a
> print "----> @$referance[0]\n\r"; I get ----> and no values from
> inside the array.
You need to dereference the array element properly;
print "----> $referance->[0]\n";
perldoc perlreftut
perldoc perlref
perldoc perlsub
perldoc perldata
perldoc perldsc
perldoc perllol
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 20 Feb 2003 17:43:50 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Perl Compiler?
Message-Id: <3E556836.4030509@annuna.com>
Is there a perl compilier and linker if so can I get an address.
------------------------------
Date: Fri, 21 Feb 2003 00:23:11 GMT
From: "Ed W" <news@wildgooses.com>
Subject: Re: Problem with buffering on non-blocking socket under win32
Message-Id: <Pje5a.1343856$TJ.189512@post-02.news.easynews.com>
Thanks for another very informative answer.
This is starting to look very much like an OS specific question actually.
Under linux (perl 5.6.1, Redhat 7.2) your test code reports "only wrote xxx
bytes", ie it goes down that code branch. However, it only does that if I
have "$remote->blocking(0)" in the code! (As you suggested)
Under Win32 (Win2K and XP) the code never goes down that branch, even if I
add the proper lines to turn off connection blocking on win32 (ioctl stuff).
Basically I can write until about 8K of data then "->can_write" returns
false. However, only can_write returns false, I can happily carry on
stuffing data into the socket if I want, and it accepts all the bytes, ie
"$n == length($buf)" ALWAYS
In fact if I fiddle with the 0x1000 number and make it obscene like several
MB, then under Linux it accepts 65532 bytes (ie $n == 65532) and can_write
returns false, but under Win32 "$n = total", ie several MB and can_write
returns false - however, even then I can continue to stuff data in and it
goes somewhere.
Just to put this in perspective I made len($buf) to be 100MB and the whole
lot got swallowed on Win32. Task manager showed that the perl.exe process
was consuming 120 odd MB (hence I guessed that perl was buffering rather
than the OS)
> Hmm, are you *sure* that your socket is non-blocking? What is the
> return status of $socket->blocking(0)? If it's false, then you aren't
> blocking as you think you are.
I think this is a crucial point. Perhaps there are different sorts of
blocking on Win32...?
I appreciate any insight here.
To be clear the problem is how to NOT accept too much data from one socket
while piping a possibly tweaked version of the data to another socket (ie a
proxy). I am receiving data from a mail program (Outlook Express, etc) and
want to avoid timeout problems, the pipe I am feeding it into does about 300
bytes per sec and so it would be extremely easy to accept too much data.
[a loop which feeds data in x KB chunks, checking for "can_write", clearly
works, but is clunky - any better ideas?]
Thanks all
Ed
------------------------------
Date: Thu, 20 Feb 2003 23:40:29 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: Report physical RAM of a remote PC
Message-Id: <JId5a.3168$jy1.25872@newsfep4-glfd.server.ntli.net>
> Why output an HTML MIME header, when you aren't using valid HTML
Because the output wouldn't appear in your browser otherwise (whether it needs
to or not in this case is immaterial). Most non-module HTML output from Perl
scripts is invalid. Be shocked if you see someone actually specify a doctype ;-)
Pete
------------------------------
Date: 21 Feb 2003 01:56:08 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Report physical RAM of a remote PC
Message-Id: <slrnb5b1po.jl9.abigail@alexandra.abigail.nl>
SAPBasis2003 (sapbasis2003@netscape.net) wrote on MMMCDLX September
MCMXCIII in <URL:news:3E5481FD.10600@netscape.net>:
() How can I report the RAM of a remote PC?
() Does anybody have a sample code to do this?
If the remote PC is running Microsoft Windows, you could try sending
it an email with an Outlook virus in it.
Abigail
--
perl -wlpe '}$_=$.;{' file # Count the number of lines.
------------------------------
Date: 21 Feb 2003 00:08:09 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: storing regex vars into array and not $1 $2 etc
Message-Id: <slrnb5arf9.jl9.abigail@alexandra.abigail.nl>
Brian McCauley (nobull@mail.com) wrote on MMMCDLX September MCMXCIII in
<URL:news:u9r8a2etpm.fsf@wcl-l.bham.ac.uk>:
||
|| Never pass $1 et al to functions. They interact in a most unfortunate
|| way with the @_ mechanism.
And so do literals. One should be aware of the limitations one has
when passing read-only stuff to functions. Giving the advice to
people not to pass $1 and friend to functions is silly.
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: Thu, 20 Feb 2003 23:19:14 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Switch order of sprintf conversions
Message-Id: <Snd5a.11540$FF4.631931@newsb.telia.net>
Anno Siegel wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
>
>>I'm using a gettext like approach for making it easy to translate a Perl
>>program to non-English languages, and the sprintf function is often used
>>for the purpose:
>>
>> $string = gettext("There Is %s Than %s Way To Do It");
>> $more = gettext("More");
>> $one = gettext("One");
>> print sprintf($string, $more, $one);
>>
>>Right now the program is translated into Chinese, and the translator has
>>reported a need to have the value of $one printed *before* the value of
>>$more. I understand from the gettext documentation that if it had been a
>>C program, $string could have been assigned (the equivalent of) "There
>>Is %2$s Than %1$s Way To Do It".
>>
>>Is there a way in Perl to achieve the same thing?
>
> Where is the gettext() function coming from? Are you using a module
> from CPAN? What does its documentation say?
I'm using (a slightly modified version of) the CPAN module
Locale::PGetText
http://search.cpan.org/author/MSHOYHER/Locale-PGetText-0.16/
It's a rather trivial module, and its documentation doesn't say anything
that could help solving this problem.
My question is about the Perl function sprintf, i.e. I'm wondering if
there is any possibility to affect the order in which the conversions
appear in the string returned by sprintf.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 20 Feb 2003 23:41:48 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Switch order of sprintf conversions
Message-Id: <x7ptpmo6ys.fsf@mail.sysarch.com>
>>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
GH> My question is about the Perl function sprintf, i.e. I'm wondering if
GH> there is any possibility to affect the order in which the conversions
GH> appear in the string returned by sprintf.
the simplest method is to provide a different format string for
different languages. this is how many internatialized systems work. you
have a list of formats indexed by a key/number for each language. the
formatting code is passed that key along with the sprintf args. it
fetches the format and sprintf's it.
if multiple languages can share the same format string then you can have
a default list of formats and only fill in the ones that need to be
special for any given language.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Thu, 20 Feb 2003 23:49:33 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Switch order of sprintf conversions
Message-Id: <3e556884.61087713@news.erols.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
: $string = gettext("There Is %s Than %s Way To Do It");
: $more = gettext("More");
: $one = gettext("One");
: print sprintf($string, $more, $one);
:
: Right now the program is translated into Chinese, and the translator has
: reported a need to have the value of $one printed *before* the value of
: $more. I understand from the gettext documentation that if it had been a
: C program, $string could have been assigned (the equivalent of) "There
: Is %2$s Than %1$s Way To Do It".
:
: Is there a way in Perl to achieve the same thing?
Yup.
Do the same thing you would in C.
------------------------------
Date: 20 Feb 2003 23:12:13 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: UNIX: creating a command line alias
Message-Id: <b33ncd$64i$1@canopus.cc.umanitoba.ca>
In article <b33eno$19a$1@test-nntp.agere.com>,
Joe Hasting <hasting@agere.com> wrote:
:I would like a PERL program to create a UNIX command line alias. I tried
:using system, exec, and the ticks, but it seems that when the process for
:the PERL program is complete, it does not leave the alias. Is there a way
:to fork this process so that the alias remains after the PERL program
:completes?
"UNIX command line alias" does not really exist. Command line aliases
are a property of the shell you are using, and you don't mention which
shell that is.
In the sh family (sh, ksh), there is no way to export an alias into
a higher shell level.
One way to handle a situation such as this (and we're way out of
Perl's jurisdiction here), is to have the sh/ksh user "dot"
a filename e.g.,
. /usr/etc/set_aliases
then if there is some reason the aliases really must be created
dynamically, make the given file a named pipe, and have a daemon
running in a loop waiting for the pipe to be openned and writing the
appropriate commands to it (which will then be executed in the user's
shell.) But this is, of course, a hack, and as long as you can
get the user to dot the given file, you might as well have the given
file be a shell script that builds the aliases more directly.
--
Positrons can be described as electrons traveling backwards in time.
Certainly many Usenet arguments about the past become clearer when they
are re-interpreted as uncertainty about the future.
-- Walter Roberson
------------------------------
Date: 20 Feb 2003 23:54:29 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: use DBI;
Message-Id: <slrnb5aqll.jl9.abigail@alexandra.abigail.nl>
Helgi Briem (helgi@decode.is) wrote on MMMCDLX September MCMXCIII in
<URL:news:3e54a44e.1115921720@news.cis.dfn.de>:
&& On 19 Feb 2003 19:52:59 GMT, Abigail <abigail@abigail.nl>
&& wrote:
&&
&& >;; Do you use exit(0) a lot? And if so, what for?
&& >
&& >What is 'a lot'? I sometimes use 'exit' at a point where it would
&& >reach the end of the file anyway. And sometimes, even an 'exit 0'.
&& >Sometimes I don't. I do the same in shell scripts. Why? Just because
&& >something I feel like doing so.
&&
&& So you would approve if people stuck random things
&& in their code here and there that didn't do anything?
No, but what does that have to do with 'exit'? I haven't encountered
a Perl in which 'exit' doesn't do anything.
Abigail
--
($;,$_,$|,$\)=("\@\x7Fy~*kde~box*Zoxf*Bkiaox"," "x25,1,"\r");
{vec($_=>1+$"=>$^F<<$^F)=ord($/^substr$;=>$"=int rand 24=>1);
print&&select$,,$,,$,,$|/($|+tr/ //c);redo if y/ //>$^F**2};
------------------------------
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 4597
***************************************