[30525] in Perl-Users-Digest
Perl-Users Digest, Issue: 1768 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 5 00:09:45 2008
Date: Mon, 4 Aug 2008 21:09:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 4 Aug 2008 Volume: 11 Number: 1768
Today's topics:
Re: bidding advice for a contract <joost@zeekat.nl>
Re: bidding advice for a contract <joost@zeekat.nl>
Re: bidding advice for a contract (Jens Thoms Toerring)
Re: bidding advice for a contract <cartercc@gmail.com>
Re: bidding advice for a contract <ben@morrow.me.uk>
Re: bidding advice for a contract <cartercc@gmail.com>
Re: CLPM - a help group? <tadmc@seesig.invalid>
Re: CLPM - a help group? <cartercc@gmail.com>
Re: Extracting bits out of huge numbers <blabla@dungeon.de>
Re: FAQ 4.61 How can I always keep my hash sorted? <jurgenex@hotmail.com>
Re: FAQ 4.61 How can I always keep my hash sorted? <ben@morrow.me.uk>
I have something funky going on with the controlling te <cdalten@gmail.com>
Sort using reference to subroutine name? <heinvandenheuvel@gmail.com>
Re: Sort using reference to subroutine name? <ben@morrow.me.uk>
Re: Trying to use my own module directory, but Perl doe <usenet@davidfilmer.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 05 Aug 2008 01:04:40 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: bidding advice for a contract
Message-Id: <87od48qt4n.fsf@zeekat.nl>
cartercc <cartercc@gmail.com> writes:
> On Aug 4, 3:37 pm, Joost Diepenmaat <jo...@zeekat.nl> wrote:
>> > They want a fixed price bid. (Did I mention that?)
>>
>> Don't decide on a fixed price now.
>
> You and I both know that this is bidding on a pig in a poke, but they
> are used to giving fixed price bids and this is what they want. I have
> spent about two hours with them, and they are totally closed to the
> idea of paying by the hour or component.
Ok... Triple your estimates.
>> Anyway, this kind of project will probably take quite a bit of time to
>> investigate before you can give a decent estimate. Get a
>> non-disclosure contract, sign it, give them a couple of hours of
>> investigation time. If it takes more than a day to figure out
>> (especially if the total project won't take more than a week or so)
>> make them pay for the rest of the time spent investigation.
>>
>> All of this is assuming they're actually trustworthy. Your description
>> sound fishy.
>
> This is a big player in a small but critical industry. There aren't
> many who build electronics to put into aircraft, missles, spacecraft,
> and bombs, which is why I don't want to mention names.
>
> We both know what's going to happen, but I am strongly motivated to
> give them what they need and I want to be able to do it reasonably and
> legitimately.
So they're big and they know how to deal with contractors. If they
won't even give you a real insight in what needs to be done before you
have to give an estimate, you're being played. Just sign a
non-disclosure agreement, investigate, and decide after that. Or raise
your estimate even more.
Personally, I wouldn't feel comfortable making any kind of fixed-price
deal unless I really knew what I was getting in to. Especially not if
the kind of people I was dealing with were obviously more experienced
at playing that game and the stakes were high (for whatever you'd
consider high). IOW: if it came to this, I'd give it a pass.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Tue, 05 Aug 2008 01:12:14 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: bidding advice for a contract
Message-Id: <87hca0qss1.fsf@zeekat.nl>
Just some more ramblings from me...
cartercc <cartercc@gmail.com> writes:
> On Aug 4, 3:37 pm, Joost Diepenmaat <jo...@zeekat.nl> wrote:
>> > They want a fixed price bid. (Did I mention that?)
>>
>> Don't decide on a fixed price now.
>
> You and I both know that this is bidding on a pig in a poke, but they
> are used to giving fixed price bids and this is what they want. I have
> spent about two hours with them, and they are totally closed to the
> idea of paying by the hour or component.
I didn't say that: I said: "Don't decide on a fixed price *now*"
>> Anyway, this kind of project will probably take quite a bit of time to
>> investigate before you can give a decent estimate. Get a
>> non-disclosure contract, sign it, give them a couple of hours of
>> investigation time. If it takes more than a day to figure out
>> (especially if the total project won't take more than a week or so)
>> make them pay for the rest of the time spent investigation.
>>
>> All of this is assuming they're actually trustworthy. Your description
>> sound fishy.
>
> This is a big player in a small but critical industry. There aren't
> many who build electronics to put into aircraft, missles, spacecraft,
> and bombs, which is why I don't want to mention names.
>
> We both know what's going to happen, but I am strongly motivated to
> give them what they need and I want to be able to do it reasonably and
> legitimately.
You *can't* know what needs to be done, because they won't tell
you. All you need is some time to figure out what needs to be done, so
you can then make a decent estimate. What I'm saying is that if the
time it takes you to make a decent estimate is large compared to the
time it'll take you to do the job you've got 2 options:
1. estimate really high and then add at least 50%
2. investigate first, but have them pay for the investigation if it
takes more than a day (which shouldn't cost more than 10% of the
total)
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: 4 Aug 2008 23:21:30 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: bidding advice for a contract
Message-Id: <6fph7qFcmm0mU1@mid.uni-berlin.de>
cartercc <cartercc@gmail.com> wrote:
> I have been solicited to make a bid for a database project. The
> company is small but has been around for 20 years or so, and the owner
> has made a name in EE. The people (potential clients) are not idiots,
> and the company is a highly regarded company with a long history that
> manufactures electronic components for aircraft, missles, etc., and
> deals with NASA, the USAF, DARPA, as well as defense contractors. I
> want to do the work, not only because I could use the money, but
> because of the reputation of the company.
> They have specified a database to track (1) purchasing, (2)
> manufacturing, (3) inventory control, (4) user specified enhancements,
> and (5) full documentation, and have specified a contract end date of
> September 24, 2008 by whch all work would be finished and the project
> would be delivered. They will not have their requirements
> specification until August 13, and based on my previous conversations,
> their requirements documents will probably be less than a page in
> length with very general, ambiguous specifications.
So you're supposed to bid for a project for which you won't get
any exact specifications before you bid on it and for which you
then have about six weeks of time to finish?
> They haven't decided whether to used Access on Windows or a networked
> enabled application with MySQL on Linux, but they want it to integrate
> with their existing software. Unfortunately, their existing software
> doesn't seem to be open source and they don't know whether thay can
> furnish any sort of API to tie into their existing applications. I
> probably won't know what to integrate with until I actually am awarded
> the contract, so I am ignorant at this point.
> They want a fixed price bid. (Did I mention that?)
So, again, you won't know what you're supposed to do before you've
got the contract? Read again what you wrote: you don't know what
database is going to be used. They didn't really decide yet about
anything at all, but they want it integrated into their existing
software, but they don't have any useful information about what
their existing software is. The requirements include 'user speci-
fied enhancements" (whatever that is and whoever decides about
that). And you're going to be bound by the contract to submit
final results on a fixed date merely six weeks later on a fixed
price.
> I intend to furnish a fixed price bid based on their specification,
> detailing the tables and queries, the user interfaces, and the modules
> I expect to build according to their specifications. I know that this
> probably will not last the first week, but I don't want to be locked
> in to a low price because of the failure of the client to detail all
> the requirements up front.
Again: they won't tell you what exactly they want (or what
"probably will not last the first week" else means?), but you
have got to promise that you will deliver it on time?
From what you write it looks as if this company has some expe-
rienced engineers. Would you really expect this kind of non-
existent "specifications" from real engineers? What it looks
like what you're dealing with is a bunch of absolutely clueless
beancounters. They don't know what they want, but they want it
cheap and yesterday. What do you expect out of this? A T-shirt
with "I got duped by company XYZ"?
Make them treat you as a professional. Tell them that you can't
make a bid unless you know exactly what you're bidding on. Make
them give you enough time for coming up with an estimate of how
much work it will entail. Don't make promises on things you can't
forsee.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Mon, 4 Aug 2008 17:21:31 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: bidding advice for a contract
Message-Id: <9525188e-6e33-4485-a4bc-a2ba64e2b8f5@8g2000hse.googlegroups.com>
On Aug 4, 7:21 pm, j...@toerring.de (Jens Thoms Toerring) wrote:
> So you're supposed to bid for a project for which you won't get
> any exact specifications before you bid on it and for which you
> then have about six weeks of time to finish?
Yep.
> So, again, you won't know what you're supposed to do before you've
> got the contract? Read again what you wrote: you don't know what
> database is going to be used. They didn't really decide yet about
> anything at all, but they want it integrated into their existing
> software, but they don't have any useful information about what
> their existing software is. The requirements include 'user speci-
> fied enhancements" (whatever that is and whoever decides about
> that). And you're going to be bound by the contract to submit
> final results on a fixed date merely six weeks later on a fixed
> price.
Yep.
> Again: they won't tell you what exactly they want (or what
> "probably will not last the first week" else means?), but you
> have got to promise that you will deliver it on time?
Yep.
> From what you write it looks as if this company has some expe-
> rienced engineers. Would you really expect this kind of non-
> existent "specifications" from real engineers?
Nope.
> What it looks
> like what you're dealing with is a bunch of absolutely clueless
> beancounters. They don't know what they want, but they want it
> cheap and yesterday. What do you expect out of this? A T-shirt
> with "I got duped by company XYZ"?
Yeah, the president of the company (whom I've not met) is a PhD and a
former EE professor at a respected engineering school who has done
very well with his business. They sure has hell wouldn't build an
electronic component this way. They'd build, test, build, test, and
continue until they had it right. You may have picked up on something
that I was not willing to see.
> Make them treat you as a professional. Tell them that you can't
> make a bid unless you know exactly what you're bidding on. Make
> them give you enough time for coming up with an estimate of how
> much work it will entail. Don't make promises on things you can't
> forsee.
That's right. The thing is, I'd really like to have the opportunity to
do the work, and they really need someone (like me) who knows how to
build something that would be really useful.
They have promised some specifications. I may give them a fixed price
for a fixed product based on their specifications and see how that
works.
Time for a story. I'm just completing a project at work. The main
script generates a data file used for the preparation of about 1500
contracts for temporary employees five times a year. I started off
with a nice little script, which over time has turned into a real
monster. A couple of weeks after I wrote the initial script, I was
informed that about 20 offices based payment on different factors with
different gradients, some used hours, some used piecework, some used
levels of experiences, many used combinations of these, some used flat
rates, etc. After coding the logic for all of this, the function was
three times as long as the original code. And that was just the start.
One of the main things was a job combo, where one project was given
two names. My script generates a contract for every job, so issuing
two contracts for one job was a BIG mistake. After discussion, I asked
whether these combos ever occured in anything other than pairs. I was
given an absolutely ironclad assurance that these combos only occured
in pairs, so I spend almost two full days rewriting the script, and
it was not a trivial effort. Friday afternoon, I finished. Saturday
morning I got an email. Guess what? There was a TRIPLE! And my script
trashed the third part of the job. So I had the pleasure of trying to
handle it Saturday.
Now, my nice, clean script is a nightmare. I can't read it and
understand what I've done. Make a little change here, a little change
there, by the way we also need you to do this, and over a period of
time you have a real mess. It wouldn't take long to clean up, but I'm
tired of it, a little disgusted, and my boss can't understand why I
would want to clean up code that nobody will ever see. So, it will be
a mess for the guy who has to modify it when things change. With my
luck, that would probably be me.
CC
------------------------------
Date: Tue, 5 Aug 2008 02:25:06 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: bidding advice for a contract
Message-Id: <iomkm5-fu51.ln1@osiris.mauzo.dyndns.org>
Quoth cartercc <cartercc@gmail.com>:
>
> One of the main things was a job combo, where one project was given
> two names. My script generates a contract for every job, so issuing
> two contracts for one job was a BIG mistake. After discussion, I asked
> whether these combos ever occured in anything other than pairs. I was
> given an absolutely ironclad assurance that these combos only occured
> in pairs, so I spend almost two full days rewriting the script, and
> it was not a trivial effort. Friday afternoon, I finished. Saturday
> morning I got an email. Guess what? There was a TRIPLE! And my script
> trashed the third part of the job. So I had the pleasure of trying to
> handle it Saturday.
Heh. There are only three numbers in computing: 0, 1, and infinity.
Unless it only makes sense for there to be one of something, assume
there may be an arbitrary number.
Oh, and of course: the user is *always* lying. :)
Ben
--
I must not fear. Fear is the mind-killer. I will face my fear and
I will let it pass through me. When the fear is gone there will be
nothing. Only I will remain.
ben@morrow.me.uk Frank Herbert, 'Dune'
------------------------------
Date: Mon, 4 Aug 2008 19:43:47 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: bidding advice for a contract
Message-Id: <0d1997d3-28f2-478a-8ebe-9fc0c8ba1830@f36g2000hsa.googlegroups.com>
On Aug 4, 9:25 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Heh. There are only three numbers in computing: 0, 1, and infinity.
> Unless it only makes sense for there to be one of something, assume
> there may be an arbitrary number.
After a lot of thought and several false starts, I used a hash with
the key of the primary section and the value of the secondary. Nice
and easy, if the number of the primary section matches a key, I modify
both the primary section and the secondary section. Works great!
Now I guess I ~could~ fix it so I get array refs or hash refs for each
key, but MY fix was to count the section numbers, generate an error
file for all sections where the value was anything other than a 0 (a
single section) or 2 (a double section), and send an email to the
person responsible for data entry with the errored out sections. It's
her error, after all.
> Oh, and of course: the user is *always* lying. :)
I prefer to think that the user believes that the developer is a
magician or sorcerer so the user doesn't have to worry about things
like consistent data. Or, in the case of my contract question, minor
details like requirements. ;-)
CC
------------------------------
Date: Mon, 4 Aug 2008 20:36:09 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: CLPM - a help group?
Message-Id: <slrng9fbk9.93a.tadmc@tadmc30.sbcglobal.net>
sln@netherlands.com <sln@netherlands.com> wrote:
> How far back are the posts saved?
Saved where, exactly?
There is no "central" server on Usenet.
Each Usenet servers retains articles for as long as their
individual news administrators have configured them to be kept.
You need to direct that question at whomever you are getting
your news feed from, as they are the only ones who know the answer.
See also:
"How the Usenet News Protocols Work"
http://people.dsv.su.se/~jpalme/e-mail-book/usenet-news.html
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Mon, 4 Aug 2008 19:59:48 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: CLPM - a help group?
Message-Id: <db3f214e-cd34-4f36-a908-849468749eca@27g2000hsf.googlegroups.com>
On Aug 2, 7:09 pm, brian d foy <brian.d....@gmail.com> wrote:
> People post the thoughtful stuff in blogs now, so you don't see much of
> that in usenet anymore.
I've had the bad experience several times now of seeing news groups
trashed and driving people away. It seems like a good idea to have a
general discussion area for topics, but there seems to be a Gresham's
law for usenet -- over time the bad posters kill the group.
The reason I don't like blogs is because I haven't found a way to do a
centralized search. You can find a blog anywhere, or not. At least
with the usenet heirarchy you can pretty quickly narrow down your
interest group.
Maybe the success of usenet is killing it. With a small group of
people mostly knowledgable and mostly interested you find people like
Larry Wall, or Randel Schwartz, or brian d foy participating. With
greater numbers of people futzing the signal to noise ratio, it gets a
lot harder.
> clpm is what it is, despite what anyone tries to make it. If that works
> for you, great. If it doesn't, there's not much chance of making it
> into something else.
I have found c.l.p.m. a helpful resource, and I try to give something
back occasionally as payment for what I have received. There is
certainly a place for groups like this, and I'm wishing for a long and
successful run. Even if I have my doubts.
CC
------------------------------
Date: Mon, 4 Aug 2008 17:02:17 -0700 (PDT)
From: hofer <blabla@dungeon.de>
Subject: Re: Extracting bits out of huge numbers
Message-Id: <98a34bf5-11a0-49e7-b74e-918d641d92b9@t54g2000hsg.googlegroups.com>
Hi,
Just some update:
The solution, that works without any additional perl modules and that
will benefit from Math::BigInt::GMP if it is installed is:
use Math::BigInt lib => 'GMP';
# extract bits via a shift operations follwed by a bit wise and
sub extbits { #/*{{{*/
my ($val,$msb,$lsb) = @_; # $val must be Math::BigInt;
my $mask = Math::BigInt->bone()->blsft($msb-$lsb+1)->bsub(1);
return $val->copy->brsft($lsb)->band($mask);
} #/*}}}*/
following example runs now for me in 15 seconds if Math::BigInt::GMP
doesn't exist and in 10 secodns if it does.
my $v1 = Math::BigInt->new("0x".( "76543210"x6));
print $v1->as_hex(),"\n";
my $v2;
for(my $i=0;$i<300;$i++){
for(my $j = 0; $j < 64;$j++){
$v2 = extbits($v1,$j+66,$j+50);
print($v2->as_hex(),"\n") if($i==0);
}
}
The other option I found is the CPAN module
Bit::Vector
I didn't try how fast it is for arithmetics, but for bit field
extraction /
copying / concatenation it's rather quick (run time 1 s)
Disadvantage / advantage:
The max size (in bits) for a bit vector has to be set during the
vector creation.
use Bit::Vector;
ub extbitsbv { #
my($v,$from,$to) = @_;
my $len = $from-$to+1;
my $v2 = Bit::Vector->new($len);
$v2->Interval_Copy($v,0,$to,$len);
return $v2;
} #
my $v1 = Bit::Vector->new_Hex(32*6,"76543210"x6);
my $v2;
print $v1->to_Hex(),"\n";
for(my $i=0;$i<300;$i++){
for(my $j = 0; $j < 64;$j++){
$v2 = extbitsbv($v1,$j+66,$j+50);
print($v2->to_Hex(),"\n") if($i==0);
}
}
bye
H
On Jul 29, 8:28 am, hofer <bla...@dungeon.de> wrote:
> Hi,
>
> I'd like to work with huge integers (> 64 bit precision)
>
> Thus I can't use ordinary perl integers.
>
> I thought Math::BigInt wouldn't be a too bad choice.
>
> It's easy enough go create BigInts.
> my $a = Math::BigInt->new("0x7777666655544443333222211110000");
> my $b = Math::BigInt->new("0x1111111111111111111111111111111");
>
> Calculating with them is also fine:
> $a->badd($b); # $a = $a + $b
>
> Now I would like to extract certain bits out of this huge number:
>
> Example Bits 16 bis 12 should result in 0b00001 == 0x1 == 1
> Bits 17 bis 12 should result in 0b100001 == 0x21 == 33
>
> So far I see two ways of doing this conversion.
>
> However I'm not really appealed by either solution.
>
> Do you know anything faster / better or even another CPAN module?
>
> # extract bits out of binary string
> sub extbits { #
> my ($val,$msb,$lsb) = @_; # $val must be Math::BigInt;
> my $asbinstr = $val->as_bin(); # nun als binaer string
> my $withoutprefix = substr($asbinstr,2); # fuehrendes '0b'
> entfernen
> my $substr = substr($withoutprefix,-$msb-1,$msb-$lsb+1); # den
> substring extrahieren
> $substr = 0 if $substr eq ""; # sollte mindestens einen character
> enthalten
> my $result = Mat::BigInt->new("0b".$substr); # zurueck in
> Math::BigInt verwandeln
> return $result;
>
> } #
>
> # extract bits via shifts operations follwed by a bit wise and
> sub extbits { #/*{{{*/
> my ($val,$msb,$lsb) = @_; # $val must be Math::BigInt;
> my $mask = Math::BigInt->new(1); # create a 1
> $mask->blsft($msb-$lsb+1); # 2 ^ (number of bits to extract)
> $mask->bsub(1); # now we have a mask
> my $tmp = $val->copy->brsft($lsb); # shift input value to the
> right
> return $tmp->band($mask);
>
> } #/*}}}*/
>
> Thanks in advance for any other suggestions
> like rewriting the function to accelerate it or using another module.
>
> bye
>
> H
------------------------------
Date: Tue, 05 Aug 2008 02:42:28 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: FAQ 4.61 How can I always keep my hash sorted?
Message-Id: <jaff9412r63lheec1h83lqtr0hca1vsgup@4ax.com>
Ted Zlatanov <tzz@lifelogs.com> wrote:
>On Sun, 03 Aug 2008 23:03:46 GMT Jürgen Exner <jurgenex@hotmail.com> wrote:
>JE> If you want a sorted hash, then you don't want a hash but some other
>JE> data structure.
>
>It's funny, however, that Perl pretends a hash is a list in many places,
>e.g.
>
>%hash = ( 1 => 2 );
Well, not really. It is a notation for a hash. Just like in mathematics
you denote the elements of a set in a linear order because that is the
only reasonable way to write them.
The real question is, do the the two notiations
%hash = ( 1 => 'foo', 2 => 'bar');
and
%hash = ( 2 => 'bar', 1 => 'foo',);
define the same hash or two different hashes?
>I'm sure this is a little confusing to beginners.
>
>If there was a useful order for a hash, it would be the insertion order,
>since that's not available in any other way (unless, of course, you keep
>track of it manually inside each value).
Which comes to the question I mentioned above. Those two hashes are
identical. Therefore the insertion order would be a non-deterministic
function. Not sure you want that in a language definition.
jue
------------------------------
Date: Tue, 5 Aug 2008 04:39:31 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 4.61 How can I always keep my hash sorted?
Message-Id: <jkukm5-it91.ln1@osiris.mauzo.dyndns.org>
Quoth Jürgen Exner <jurgenex@hotmail.com>:
> Ted Zlatanov <tzz@lifelogs.com> wrote:
> >
> >If there was a useful order for a hash, it would be the insertion order,
> >since that's not available in any other way (unless, of course, you keep
> >track of it manually inside each value).
>
> Which comes to the question I mentioned above. Those two hashes are
> identical. Therefore the insertion order would be a non-deterministic
> function. Not sure you want that in a language definition.
I think you're being a little over-literal, here. A hashtable is one
datastructure that provides a key->value mapping; there are others, such
as alists and btrees, that *do* have a well-defined order (insertion
order and sorted-key order, respectively).
The fact Perl's hashes are built as hashtables is an implementation
detail: there's nothing in the interface (assignment, lookup, 'keys',
'values', 'each') that says they have to be built that way. ('keys',
'values' and 'each' provide no guarantee about order; they do not
guarantee a random order. Under the wrong circumstances with a perl
before 5.8.1 you will in fact get a thoroughly *non*-random order.)
'tie' is provided so you can create a hash that is built any way you
like, and with the appropriate application of XS and magic you can even
make it as efficient as the builtin hashes.
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
Date: Mon, 4 Aug 2008 19:14:10 -0700 (PDT)
From: grocery_stocker <cdalten@gmail.com>
Subject: I have something funky going on with the controlling terminal
Message-Id: <42e55ee6-2d26-450a-afa9-b31c36d46b2d@f36g2000hsa.googlegroups.com>
I was trying to write an auto responder on a local BBS. However, when
I have perl send the BBS respond command to the BBS, I get "Input not
a tty". I'm assuming this is because of the BBS text editor that sits
on top of the BBS or what not.
m-net% more post.pl
#!/usr/bin/perl
use strict;
use warnings;
open my $out, '|-', 'bbs'
or die "cannot open pipe to bbs: $!";
print $out "read 18\n";
print $out "respond\n"; #the respond command
close $out
or die "cannot close pipe to bbs: $!";
m-net% ./post.pl
YAPP 3.1.1 Copyright (c)1995 Armidale Software
Registered to: Arbornet
Welcome to the
August General Conference
Fairwitness: jerryr
7 newresponse items and 12 brandnew items
First item 1, last 29
Item 18 entered Sat, Aug 2, 2008 (11:30) by no (cdalten)
rapunzel has a larger schlong than Chuck Martin
I'm just saying.
4 responses total.
#1 mickey deee (mickeyd) Sat, Aug 2, 2008 (11:45):
And who would know better than Chad who has a bigger schlong :)
Chucky says 'hi'
#2 lar (lar) Sat, Aug 2, 2008 (22:42):
He says "come back over to grex where I can pwn you again"
#3 Short but Funky (furs) Sun, Aug 3, 2008 (13:09):
re 1
no, he know's how big Chuck Martin's dick is because it's constantly
in
his ass.
#4 Sarah (rapunzel) Mon, Aug 4, 2008 (11:05):
which one is chuck martin again?
go me and my schlong!
gate: Input not a tty
Response aborted! Returning to current item.
Stopping.
Now leaving August General...
m-net%
I was thinking that maybe I could somehow redirect something to /dev/
tty. Ideas?
------------------------------
Date: Mon, 4 Aug 2008 20:18:09 -0700 (PDT)
From: "Hein, Nashua NH" <heinvandenheuvel@gmail.com>
Subject: Sort using reference to subroutine name?
Message-Id: <ca69ba65-b7e9-4c0a-a386-ce71feffaccc@27g2000hsf.googlegroups.com>
I have function which I'd like to call telling it how to sort some
arrays.
I'd like to do something like:
my $sort_by_x_ref = sub { return ($x{$b} <=> $x{$a})};
my $sort_by_y_ref = sub { return ($y{$b} <=> $y{$a})}
sub print_sorted {
my $sort_function = $_[0]->();
print "Sorted $_[1]\n";
foreach (sort {$sort_function} keys %some_array) {
:
print...
:
}
&print_sorted ( $sort_by_x_ref, "by X");
&print_sorted ( $sort_by_y_ref, "by Y" );
That does not work. {&$sort_function}, and just $sort_function do not
seem to work either.
Can this be done? What is the syntax?
My workaround is boring:
sub print_sorted {
print "Sorted $_[1]\n";
foreach (sort {($_[0]) ? $x{$b} <=> $x{$a} : $y{$b} <=> $y{$a} } keys
%some_array) {
:
print...
:
}
&print_sorted ( 1, "by X");
&print_sorted ( 0, "by Y" );
Please advice,
Hein.
------------------------------
Date: Tue, 5 Aug 2008 04:49:12 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Sort using reference to subroutine name?
Message-Id: <o6vkm5-it91.ln1@osiris.mauzo.dyndns.org>
Quoth "Hein, Nashua NH" <heinvandenheuvel@gmail.com>:
>
> I have function which I'd like to call telling it how to sort some
> arrays.
> I'd like to do something like:
>
> my $sort_by_x_ref = sub { return ($x{$b} <=> $x{$a})};
> my $sort_by_y_ref = sub { return ($y{$b} <=> $y{$a})}
>
> sub print_sorted {
> my $sort_function = $_[0]->();
Why are you doing this? (What did you think it would do for you?) I'm
fairly sure you just want
my $sort_function = $_[0];
here.
> print "Sorted $_[1]\n";
> foreach (sort {$sort_function} keys %some_array) {
foreach (sort $sort_function keys %some_array) {
except %some_array isn't an array, it's a hash. Using a block
{$sort_function} will attempt to sort with a sub that returns
$sort_function every time, which is unlikely to be successful.
Note that the sort function will need to be compiled into the package
that is current when 'sort' is called (or you could use the
($$)-prototyped variant, but that's both slow and obscure) as otherwise
$a and $b won't work.
I'm not quite sure why you're doing this: why not just pass a ref to the
hash to sort by, and then use something like
my $sort_by = $_[0];
sort { $sort_by->{$a} <=> $sort_by{$b} } ...;
?
> &print_sorted ( $sort_by_x_ref, "by X");
> &print_sorted ( $sort_by_y_ref, "by Y" );
Don't call subs with & unless you know what it does, and what it does is
what you want (hint: it probably isn't).
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: Mon, 4 Aug 2008 16:24:06 -0700 (PDT)
From: David Filmer <usenet@davidfilmer.com>
Subject: Re: Trying to use my own module directory, but Perl doesn't see @EXPORT
Message-Id: <f41d2277-7ea5-4b4f-ba26-627774f2e310@p10g2000prf.googlegroups.com>
On Aug 4, 5:52=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> Works for me:
> [snip]
Well, geez, Peter, it works for me too! I dunno what I did wrong last
night.
Thanks (and also to Gunnar who proposed the solution that I messed
up).
Cheers!
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 1768
***************************************