[28451] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9815 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 7 00:05:50 2006

Date: Fri, 6 Oct 2006 21:05:05 -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           Fri, 6 Oct 2006     Volume: 10 Number: 9815

Today's topics:
        backreference oddity <buzzinfly@web.de>
    Re: backreference oddity <1usa@llenroc.ude.invalid>
    Re: backreference oddity anno4000@radom.zrz.tu-berlin.de
    Re: backreference oddity <eric-amick@comcast.net>
    Re: backreference oddity <see.sig@rochester.rr.com>
    Re: backreference oddity <1usa@llenroc.ude.invalid>
    Re: Can perl test for .mp3 file? <itfred@cdw.com>
    Re: Can perl test for .mp3 file? <theaney@gmail.com>
    Re: Dealing with a STRANGE API anno4000@radom.zrz.tu-berlin.de
    Re: FAQ 5.2 (Was: inserting lines) <Jim@Gibson.org>
    Re: LWP and Unicode <benmorrow@tiscali.co.uk>
    Re: My first socket question xhoster@gmail.com
    Re: newbie cspan example question ToddAndMargo@gbis.com
    Re: newbie cspan example question ToddAndMargo@gbis.com
    Re: newbie structure question ToddAndMargo@gbis.com
    Re: Unique in-depth problem <1usa@llenroc.ude.invalid>
    Re: Unit-testing and mock objects <benmorrow@tiscali.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 6 Oct 2006 15:36:48 -0700
From: "poncenby" <buzzinfly@web.de>
Subject: backreference oddity
Message-Id: <1160174207.982360.94590@m73g2000cwd.googlegroups.com>

i have a file which has lines of text with fields separated by a space.
some of the fields are prefixed with a number and a space, like the
line below...

bar1 bar2 XX 10 bar3tooten
foo1 foo2 XX 15 foo3uptofifteen

as you can see, the numbers (10 and 15) are the length of the field
after the number.
so i want to use these numbers as length specifier to match the field
after the number, with a regex like either of these:

/(.+)\s(.+)\sXX\s([0-9)+)\s(.{$3})/
/(.+)\s(.+)\sXX\s([0-9)+)\s(.{\3})/

both regexs will make the program fall over when attempting to print
$4.

i've figured out a solution with a regex over two lines but am curious
why this doesn't work.

thanks in advance

poncenby



------------------------------

Date: Fri, 06 Oct 2006 22:50:13 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: backreference oddity
Message-Id: <Xns9854BF9E7547Basu1cornelledu@24.24.2.166>

"poncenby" <buzzinfly@web.de> wrote in
news:1160174207.982360.94590@m73g2000cwd.googlegroups.com: 

> i have a file which has lines of text with fields separated by a
> space. some of the fields are prefixed with a number and a space, like
> the line below...
> 
> bar1 bar2 XX 10 bar3tooten
> foo1 foo2 XX 15 foo3uptofifteen
> 
> as you can see, the numbers (10 and 15) are the length of the field
> after the number.
> so i want to use these numbers as length specifier to match the field
> after the number, with a regex like either of these:
> 
> /(.+)\s(.+)\sXX\s([0-9)+)\s(.{$3})/

You can't used the capture variable here, but your problem is ...

> /(.+)\s(.+)\sXX\s([0-9)+)\s(.{\3})/

Ahem ... Did you read the error message? Without any testing, I can see 
that you should havve [0-9]+ rather than the [0-9)+ you used above.

Have you read the posting guidelines yet? You should always post a short 
but complete script that illustrates the problem, so others can try it 
with the minimum of effort.

Sinan

Sinan


------------------------------

Date: 7 Oct 2006 00:02:13 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: backreference oddity
Message-Id: <4oo944FfedpeU1@news.dfncis.de>

poncenby <buzzinfly@web.de> wrote in comp.lang.perl.misc:
> i have a file which has lines of text with fields separated by a space.
> some of the fields are prefixed with a number and a space, like the
> line below...
> 
> bar1 bar2 XX 10 bar3tooten
> foo1 foo2 XX 15 foo3uptofifteen
> 
> as you can see, the numbers (10 and 15) are the length of the field
> after the number.
> so i want to use these numbers as length specifier to match the field
> after the number, with a regex like either of these:
> 
> /(.+)\s(.+)\sXX\s([0-9)+)\s(.{$3})/
> /(.+)\s(.+)\sXX\s([0-9)+)\s(.{\3})/
> 
> both regexs will make the program fall over when attempting to print
> $4.

Earlier than that, as has been noted.

> 
> i've figured out a solution with a regex over two lines but am curious
> why this doesn't work.

If a regex gets that big it's time to try something else.  The
pack/unpack functions have a template that can deal with an embedded
length field.  The following code shows how.

We first use split() to retrieve the three blank-separated variables
and the rest of the line.  The rest starts with the length-delimited
field.  We can use unpack to split off the length-delimited part
(the 'a3/a' template does that) and capture whatever is left over
after that ('a*').  I have added some extra noise at the line ends
to show that the length field is interpreted correctly.  See
"perldoc -f pack" for the details.

    while ( <DATA> ) {
        chomp;
        my ( $one, $two, $three, $rest) = split ' ', $_, 4;
        my $four;
        ( $four, $rest) = unpack 'a3/a a*', $rest;
        print "$one, $two, $three, $four, $rest\n";
    }

    __DATA__
    bar1 bar2 XX 10 bar3tooten+some
    foo1 foo2 XX 15 foo3uptofifteen+more

Anno


------------------------------

Date: Fri, 06 Oct 2006 20:58:20 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: backreference oddity
Message-Id: <ngudi2l4cb9pd39m8gr114p3d97e5fjq1t@4ax.com>

On Fri, 06 Oct 2006 22:50:13 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:

>> /(.+)\s(.+)\sXX\s([0-9)+)\s(.{\3})/
>
>Ahem ... Did you read the error message? Without any testing, I can see 
>that you should havve [0-9]+ rather than the [0-9)+ you used above.

Maybe this is version-dependent, but that won't do what the OP wants
even after fixing the syntax error with [0-9). Repeat counts in curly
brackets have to be constants. Try this and see what I mean:

perl -Mre=debug -e "/(.+)\s(.{\1})/"
-- 
Eric Amick
Columbia, MD


------------------------------

Date: Sat, 07 Oct 2006 02:28:01 GMT
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: backreference oddity
Message-Id: <RgEVg.3346$484.2859@twister.nyroc.rr.com>

poncenby wrote:
> i have a file which has lines of text with fields separated by a space.
> some of the fields are prefixed with a number and a space, like the
> line below...
> 
> bar1 bar2 XX 10 bar3tooten
> foo1 foo2 XX 15 foo3uptofifteen
> 
> as you can see, the numbers (10 and 15) are the length of the field
> after the number.
> so i want to use these numbers as length specifier to match the field
> after the number, with a regex like either of these:
> 
> /(.+)\s(.+)\sXX\s([0-9)+)\s(.{$3})/
]-----------------------^
> /(.+)\s(.+)\sXX\s([0-9)+)\s(.{\3})/
]-----------------------^
> 
> both regexs will make the program fall over when attempting to print
> $4.
> 
> i've figured out a solution with a regex over two lines but am curious
> why this doesn't work.

Doesn't work because of the syntax error.  And because the contents of 
the {...} construction have to be literal digits or digits,digits .

For a one-liner, try something like:

use strict;
use warnings;
my $v;
while(<DATA>){
   chomp;
   s/^(.+)\s(.+)\sXX\s(\d+)\s(.*)/$v=substr($4,0,$3);"$1 $2 XX $3 $4";/e;
   print "line:$_:\nv:$v:\n";
}
__END__
bar1 bar2 XX 10 bar3tootenblahblahblah
foo1 foo2 XX 15 foo3uptofifteenyadayadayada

(Data was padded to illustrate that it works.)  The second expression in 
the replacement expression is present so the value of the replacement 
string is the same as the original string so the "matched" variable is 
preserved in the substitution.  Also, I anchored the start so it won't 
match starting partway through a line.  Generates:

D:\junk>perl junk574.pl
line:bar1 bar2 XX 10 bar3tootenblahblahblah:
v:bar3tooten:
line:foo1 foo2 XX 15 foo3uptofifteenyadayadayada:
v:foo3uptofifteen:

D:\junk>
 ...
> poncenby
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


------------------------------

Date: Sat, 07 Oct 2006 03:03:08 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: backreference oddity
Message-Id: <Xns9854EA7F4F5C6asu1cornelledu@24.24.2.166>

Eric Amick <eric-amick@comcast.net> wrote in 
news:ngudi2l4cb9pd39m8gr114p3d97e5fjq1t@4ax.com:

> On Fri, 06 Oct 2006 22:50:13 GMT, "A. Sinan Unur"
> <1usa@llenroc.ude.invalid> wrote:
> 
>>> /(.+)\s(.+)\sXX\s([0-9)+)\s(.{\3})/
>>
>>Ahem ... Did you read the error message? Without any testing, I can see 
>>that you should havve [0-9]+ rather than the [0-9)+ you used above.
> 
> Repeat counts in curly brackets have to be constants.

I knew that, of course ;-)

Thanks for the correction. I focused on the most obvious error and missed 
the other one.

Sinan


------------------------------

Date: Fri, 06 Oct 2006 19:50:01 -0400
From: Fred <itfred@cdw.com>
Subject: Re: Can perl test for .mp3 file?
Message-Id: <quGdnSCeD-I0drvYnZ2dnUVZ_oidnZ2d@giganews.com>

On Fri, 06 Oct 2006 16:32:10 +0000, John Bokma wrote:
>> I just fond that if I pass an .mp3 file, an empty
>> text file, or a directory, to File::Type, it always
>> returns a MIME type of application/octet-stream.
> 
> Are you sure this is File::Type, and not File::MimeInfo? I have no 
> experience with the modules, but read the documentation (fast). I read 
> that File::MimeInfo doesn't use magic, but (surprise!) 
> File::MimeInfo::Magic does.
> 
> Also, IIRC, File::Type does use magic, but like I said, all from a quick 
> glance at the documentation.


I'm using File::MimeInfo which works well.

-Thanks




------------------------------

Date: Fri, 06 Oct 2006 21:54:21 -0400
From: Tim Heaney <theaney@gmail.com>
Subject: Re: Can perl test for .mp3 file?
Message-Id: <m3ac4899gy.fsf@calvin.watterson>

Fred <itfred@cdw.com> writes:
>
> I just fond that if I pass an .mp3 file, an empty
> text file, or a directory, to File::Type, it always
> returns a MIME type of application/octet-stream.

It seems to work okay to me.

  $ perl -MFile::Type -le 'print File::Type->new->checktype_filename(shift)' foo.mp3
  audio/mp3

I found that File::MMagic can't identify an MP3 using its own
internal methods

  $ perl -MFile::MMagic -le 'print File::MMagic->new->checktype_filename(shift)' foo.mp3

but it can with a magic file.

  $ perl -MFile::MMagic -le 'print File::MMagic->new("/usr/share/file/magic.mime")->checktype_filename(shift)' foo.mp3 
  audio/mpeg

The XS version works with its own internal method

  $ perl -MFile::MMagic::XS -le 'print File::MMagic::XS->new->get_mime(shift)' foo.mp3
  audio/mpeg

or with a magic file.

  $ perl -MFile::MMagic::XS -le 'print File::MMagic::XS->new("/usr/share/file/magic.mime")->get_mime(shift)' foo.mp3
  audio/mpeg

Similarly, the File::MimeInfo module works without magic

  $ perl -MFile::MimeInfo -le 'print mimetype shift' foo.mp3
  audio/mpeg

or with it.

  $ perl -MFile::MimeInfo::Magic -le 'print mimetype shift' foo.mp3
  audio/mpeg

So all of the suggestions seem to work.

Tim


------------------------------

Date: 6 Oct 2006 23:12:19 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Dealing with a STRANGE API
Message-Id: <4oo66jFfbbjlU1@news.dfncis.de>

Ignoramus7272  <ignoramus7272@NOSPAM.7272.invalid> wrote in comp.lang.perl.misc:
> I am using PayPal API class 
> 
> Business::PayPal::API::TransactionSearch
> 
> It uses some very weird code

Indeed.  Snipped.

> that is, it returns a hash when there is error, and a list reference
> when there is not. 
> 
> I am bewildered, just how can I get this result into one variable and
> then figure out if I am dealing with success (so that I can print
> results from the list reference), or failure (so that I can print a
> hash element error message).
> 
> Any idea? I tried obvious things like setting a scalar to the result
> of this function, and could not.

Untested:

    my @mystery = $obj->meth_from_hell( ...);

    if ( @mystery == 1 ) {
        my @array = @{ $mystery[ 0] };
        # normal processing
    } else {
        my %hash = @mystery;
        # error
    }

The distinction is reliable because the hash returns an even number of 
scalars.

You shouldn't have to do this.

Anno


------------------------------

Date: 6 Oct 2006 15:50:34 -0700
From: "Jim Gibson" <Jim@Gibson.org>
Subject: Re: FAQ 5.2 (Was: inserting lines)
Message-Id: <1160175034.433263.23020@h48g2000cwc.googlegroups.com>



On Oct 4, 1:10 pm, brian d  foy <brian.d....@gmail.com> wrote:
> In article <031020061558043174%jgib...@mail.arc.nasa.gov>, Jim Gibson
>
> <jgib...@mail.arc.nasa.gov> wrote:
> > I recently complained about the lack of alternate approaches to theFAQ
> > "How do I change one line in a file/delete a line in a file/insert a
> > line in the middle of a file/append to the beginning of a file?"Hmmm...., I must have missed that. I didn't see anything in Google
> Groups from you in response to previous postings to this answer, and it
> looks like you've never posted to perlfaq-workers. I won't see
> complaints unless they show up as responses to the autoposter or in
> perlfaq-workers, so I won't be able to do anything about them otherwise.

It wasn't in reponse to the periodic FAQ posting. It was in a response
to the poster of the "inserting lines" thread. I automatically started
to point him to the FAQ when I noticed the terse and mostly non-helpful
(to a self-described beginner) answer about Tie::File.

>
> Anyway, here's the new answer. I moved the one liner stuff to the end
> so I could explain the basic process before I got to the special
> features (because hey, if they are asking the question, they aren't
> just missing the knowledge about -p :)

Thanks. It is much better (I consider my work done here :)



------------------------------

Date: Fri, 6 Oct 2006 17:37:55 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: LWP and Unicode
Message-Id: <3cdiv3-dh7.ln1@osiris.mauzo.dyndns.org>


Quoth "Dale" <dale.gerdemann@googlemail.com>:
> Mumia W. (reading news) wrote:
> > 403 Forbidden
> 
> Whoops! I'm sure you managed to recreate the website yourself. But just
> in case:
> 
> http://www.sfs.uni-tuebingen.de/~dg/fooo.html
> 
> The contents are:
> 
> %D1%86 a ц
> 
> Sorry again for violating the newsgroup charter by using Unicode here.
> But sometime there ought to be a discussion of why the newsgroup has
> such a charter. Perl allows programs to be written with Unicode, but
> such programs cannot be discussed here. Does this make sense?

It's not a question of this group's charter, it applies generally on
Usenet. There is no header in a Usenet article that specifies a charset,
so no way to use anything other than the default ASCII.

I agree in principle: some form of charset header should be added, or
the charset should simply be specified to be UTF8. But until it is,
please refrain from using it.

Ben

-- 
#!/bin/sh
quine="echo 'eval \$quine' >> \$0; echo quined"
eval $quine
#                                                 [benmorrow@tiscali.co.uk]


------------------------------

Date: 06 Oct 2006 22:49:31 GMT
From: xhoster@gmail.com
Subject: Re: My first socket question
Message-Id: <20061006185139.372$8O@newsreader.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Mon, 02 Oct 2006 10:02:07 -0700, Jim Gibson
> <jgibson@mail.arc.nasa.gov> wrote:
>
> >> >>   while (1) {
> >> >>       $cnt++;
> >> >>       $val=rand;  # these are the important calculations!!
> >> >>       next unless $sel->can_read(0.2);
> >> >
> >> >Why the 0.2?  If the main task is $cnt++ and $val=rand, then it
> >> >should be spending most of it's time there and not waiting for
> >> >someone to make a connection that quite likely will not come within
> >> >any given 0.2 anyway.
> >
> >The benefit of using a timeout to can_read to control program execution
> >and timing is better responsiveness. If you use sleep (or select) to
> >pause the program when it has nothing to do but wait for clients, you
> >cannot respond to the client until the timeout to sleep has expired. If
> >you use a timeout parameter for can_read, you can respond immediately.
> >After the client has been serviced, the program can decide to perform
> >some calculations or call can_read again, perhaps with a shorter
> >timeout this time.
>
> So, all in all, is it better to time out or not?

It is better to use the one that is most appropriate, whichever that one
is for the case at hand. :)

> IIUC your answer is
> affirmative, whereas xhoster's one is negative. Since you both are
> much more knowledgeable than I am... I'm quite lost. (Although I must
> say that what I got thus far is fine for me now, but I want to learn
> more for the future.)

I tend to use either a zero timeout or an infinite timeout, and rarely
anything other than those two.  I'm not saying there are no good reasons to
use a positive finite timeout, just that those reasons don't arise in the
type of work that I usually do.

In a simple server you could say "I have nothing to do until either a new
client connects or one of these 12 already open connections sends a
request" then you stuff those 13 things (12 client socket, one listen
socket) into a select, and block indefinitely on that.  After all, you have
nothing to else to do.

Or, if the server has some low priority clean-up work it could be doing
while it waits for one of those 12+1 things to happen, then you would stick
them into a select and use a 0 time out, doing a little bit of clean-up
between each unsuccessful select call.  You do have to be careful that it
is only a little bit of clean-up.  (Or sometimes it isn't clean-up work to
do, but the real guts of the job, and the clients are nothing more than
some nosy person who wants to check in every now and then, like what I
originally thought you had.)

Where I do sometimes end up using a timeout is when I want to wait
indefinitely, but not everything I want to wait for can be stuffed into a
select.  For example, if I want to wait for either one of these 10 sockets
to be become readable, or for the file "foo" to come into existence.  Since
select can't check for file existence, I'd end up doing something like
this:

wait_for($select_handle, "foo");

sub wait_for {
  my @x;
  while(1) {
    push @x, $_[1] if -e $_[1];
    push @x, ($_[0]->can_read(@x ? 0 : 0.5);
    return @x if @x;
  };
};

Where the 0.5 would be ajusted higher if I was willing to wait longer
before noticing that the file showed up, and lower if I was willing to burn
more CPU in a polling loop.  (But really, it would be better to get the
process which creates the file to "post" this process when it is done,
by using a socket, that way you can stuff the semaphore socket into the
select and then go back to blocking indefinitely.

>
> >usually inserted. Using the timeout of select is a good method of
> >sleeping while remaining responsive.
>
> So, again, all in all you recommend doing so, don't you? Are there two
> schools of thought in this respect?

Well, it depends on what you want to do.  I would argue that as long as
everything you want to respond to can be stuffed into one select, then
you don't need a timeout in order to remain responsive.  It is only when
you wish to repond to other things not in the select that you need a
timeout.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: 6 Oct 2006 18:41:02 -0700
From: ToddAndMargo@gbis.com
Subject: Re: newbie cspan example question
Message-Id: <1160185262.926028.183180@k70g2000cwa.googlegroups.com>


Mirco Wahab wrote:
> Thus spoke ToddAndMargo@gbis.com (on 2006-10-06 02:02):
> >     I have been looking at:
> >           http://search.cpan.org/~ugansert/Paw-0.54/Paw/Popup.pm
> >
> >                  @butt=('Okay', 'Cancel');
> >                  $text=('Do you really want to continue ?');
> >                  $pu=Popup::new(height=>20, width=>20,
> >                         buttons=>\@butt, text=>\$text);
> >
> > Having run the example and being told that something important
> > was missing (Popup::new) I though I had better ask the following
> > questions:
>
> 'paw' seems to be an old SuSE-related package
> for drawing text shapes and stuff on top of
> the unix 'curses' library. You need to have
> that installed.
>
> The 'paw'-documentation doesn't seem to help
> much, its not longer maintained and I guess
> nobody uses it much (could be wrong here).
>
> The 'modules' you need, which are mostly
> given in the 'paw'-examples, must be
> installed before to your Perl-system
> by the 'cpan' script.
>
>  $> cpan
>
> will first brag about itself, ask
> you some things and will allow you,
> finally, to install things:
>
> #[CPAN]> install Paw
>
> the CPAN-programm will then try to load the
> module from one of the internet archives
> and install it on your computer. Do this
> with all the modules you need.
>
> Then you can use the Paw module and its
> descendents by including it on top of
> your script file:
>
> -----[myfile.pl]----------
>
>   use Curses;
>   use Paw;
>   use Paw::Button;
>   use Paw::Box;
>   use Paw::Window;
>   ...
>
>  # enter your Paw-related code here
>
>
> The 'use' statements will load the
> Paw-Modules (if you installed them before)
> and the Rest of your program will know now
> what to do if it stumbles upon:
>
>       ...
>       @butt=('Okay', 'Cancel');
>       $text=('Do you really want to continue ?');
>       $pu=Popup::new(height=>20, width=>20,
>                      buttons=>\@butt, text=>\$text);
>       ...
>
>
> In the end, it turns out the Perl-Module
> System (CPAN) is one of the best
> "Software-Block" providing systems
> in existence.
>
> Regards
>
> Mirco

Thank you!

The cpan script sounds a lot like YUM.  And, the "use" statement is on
the same 
lines as Modula2's use of external modules.  :-)



------------------------------

Date: 6 Oct 2006 18:46:42 -0700
From: ToddAndMargo@gbis.com
Subject: Re: newbie cspan example question
Message-Id: <1160185602.673152.38750@m73g2000cwd.googlegroups.com>


> Possibly going through a few tutorials will get you up to speed
> faster than posting a question every time something doesn't work.

too dumb a moment to know where to look.  Have stinkin' deadline
too.  :')

>
>   http://www.perlmonks.org/index.pl?node=Tutorials

Great link!  Thank you.



------------------------------

Date: 6 Oct 2006 18:38:09 -0700
From: ToddAndMargo@gbis.com
Subject: Re: newbie structure question
Message-Id: <1160185088.944615.117970@i3g2000cwc.googlegroups.com>


> At the bottom line, you won't get around using:
>
> - /packages/ (like 'objects') for the reusable stuff,
> - /subroutines/ for splitting up the task into independent chunks,
> - /data structures/ like arrays and hash maps for keeping the
>   model you work with,
> - /variables/ of course to make things going,
>
> ... as in most other programming languages. You
> can also map your style to most of the different
> programming paradigms:
>
>   http://en.wikipedia.org/wiki/Programming_paradigm


Thank you!

> What exactly did you do before?

    a) make my declarations (which variable did what, etc.),
    b) write all my modules and functions, and
    c) in the body, place my code. 

-T



------------------------------

Date: Fri, 06 Oct 2006 22:35:10 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Unique in-depth problem
Message-Id: <Xns9854BD110D627asu1cornelledu@24.24.2.166>

Tad McClellan <tadmc@augustmail.com> wrote in 
news:slrneidah8.228.tadmc@magna.augustmail.com:

> Idgarad <idgarad@gmail.com> wrote:
> 
>> I need to work with, manage, and render a timeline. The problem? The
>> dates range, in years, from 0 to 1452652!! 
> 
> 
> I wonder how you determined the age of the universe to a resolution
> of only 1 year.
> 
>:-)

Actually, he claims to be able to distinguish events by day during that 
entire duration as he wants the thing to zoom to any individual day during 
that period. Quite impressive. I have a sneaking suspicion someone will 
claim this year was the warmest in the past 1452652 years.

Sinan


------------------------------

Date: Fri, 6 Oct 2006 23:55:32 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Unit-testing and mock objects
Message-Id: <4g3jv3-ogv.ln1@osiris.mauzo.dyndns.org>


Quoth "jmv" <eugene.morozov@gmail.com>:
> Hello,
> I have a problem creating mock objects for the unit tests. I'm writing
> a unit tests for the rather old proprietary OO application that has all
> sort of code smells.
> 
> The code I want to test looks like this:
[snip]
> 
> I want to override the runCommand method from Corp::System module. I've
> found only one way to do it. In my unit test module I write:
[snip]
> 
> Is there more elegant and flexible method for testing such classes
> without refactoring them? In any case, tests should exist before
> refactoring.

A search on CPAN for 'mock' reveals Test::MockModule. Is this the sort
of thing you mean?

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                           Heraclitus
  benmorrow@tiscali.co.uk


------------------------------

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 V10 Issue 9815
***************************************


home help back first fref pref prev next nref lref last post