[25699] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7940 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 4 06:06:19 2005

Date: Mon, 4 Apr 2005 03: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           Mon, 4 Apr 2005     Volume: 10 Number: 7940

Today's topics:
    Re: Generate random arrays? <dzluk8fsxsw0001@sneakemail.com>
    Re: Help with a script.. <noreply@gunnar.cc>
    Re: Help with a script.. <felix.geerinckx@gmail.com>
        Illegal Seek - Any Hints codefixer@gmail.com
    Re: Illegal Seek - Any Hints <joe@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 4 Apr 2005 09:25:59 +0200
From: "Jonas Nilsson" <dzluk8fsxsw0001@sneakemail.com>
Subject: Re: Generate random arrays?
Message-Id: <d2qq4h$hkk$1@news.island.liu.se>

"BCC" <bcc@abcz.com> wrote in message
news:Ax04e.1155$qD2.113@newssvr14.news.prodigy.com...
> Hi,  I have a matrix that is 100x100x100, and wish to generate a list of
>   1000 randomly chosen non-repeating x,y,z coordinates within the space.
>
> I can generate a list of non-repeating single digits using rand(), but
> Im not sure how to take it to the next level...
>

Try this:

use strict;

# Usage generatate_non_repeating_coordinates (Dimensions, size, number of
coordinates, offset of axis (0 if left out));

my $list=generatate_non_repeating_coordinates(3,100,1000,1);
# or maybe:
my $list=generatate_non_repeating_coordinates(3,100,1000);

for (0..$#{$list}) {
 print "@{$list->[$_]}\n";
}

sub generatate_non_repeating_coordinates {
 my ($dim,$size,$number)=@_;
 die "Not enough space!" if ($size**$dim<$number);
 my $offset=$_[3] or 0;
 my @points;
 my %tmp;
 while ($number) {
  my $p=[map {$offset+int rand $size} (1..$dim)];
  unless ($tmp{"@{$p}"}++) {
   $number--;
   push @points,$p;
  }
 }
 return \@points;
}

/jN




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

Date: Mon, 04 Apr 2005 09:12:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help with a script..
Message-Id: <3bc7oeF6fhjfhU1@individual.net>

A. Sinan Unur wrote:
> clearguy02@yahoo.com wrote in news:1112576321.475302.71500
> @z14g2000cwz.googlegroups.com:
>> 
>>  $finalDate = sprintf ("20%02d-%02d-%02d %02d:%02d:00\n", $3,
>> $months{$2}, $1, $4, $5);
> 
> As I noted before, there is a Y2.1K bug in there. When doing the right 
> thing is just as easy as doing the wrong thing, why not do the right 
> thing?

What's "the right thing" when converting a 'DD-Mon-YY' date string?

If it's a bug at all, isn't it rather a Y(-)x.yK bug?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Mon, 04 Apr 2005 07:28:44 GMT
From: "Felix Geerinckx" <felix.geerinckx@gmail.com>
Subject: Re: Help with a script..
Message-Id: <xn0e0lj3e1r1u3000@news.easynews.com>

On 04/04/2005, A. Sinan Unur wrote:

> clearguy02@yahoo.com wrote in news:1112576321.475302.71500
> @z14g2000cwz.googlegroups.com:
> 
> >   $finalDate = sprintf ("20%02d-%02d-%02d %02d:%02d:00\n", $3,
> > $months{$2}, $1, $4, $5);
> 
> As I noted before, there is a Y2.1K bug in there. When doing the
> right thing is just as easy as doing the wrong thing, why not do the
> right thing?
> 

It's more than a Y2.1K bug: 

    $shortyear = '04';

could mean any of 

    $longyear = '1904'; 
    $longyear = '2004'; 
    $longyear = '2104';

etc.

So doing the right thing is not as easy as some years ago, when we said
e.g.

   $longyear = ($shortyear gt '50' ? '19' : '20') . $shortyear;

-- 
felix


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

Date: 3 Apr 2005 21:27:40 -0700
From: codefixer@gmail.com
Subject: Illegal Seek - Any Hints
Message-Id: <1112588860.741946.114520@f14g2000cwb.googlegroups.com>

Hi,

I have a script in which I have " do $test" where $test refers to a
different perl script, say foo.pl

In foo.pl when the control is trying to execute my$result =
qx/\.\/test"/ I am getting an error saying Illegal seek. (All other
statements execute just fine).

 I browsed through some past messages here but still couldn't find
anything that works.

Any hints on what I coud do ? Is their a way to diagnose this "illegal
seek" message further ????


Thanks for your help.



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

Date: Sun, 03 Apr 2005 22:31:37 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Illegal Seek - Any Hints
Message-Id: <T4GdnTDiYPChTM3fRVn-og@comcast.com>

codefixer@gmail.com wrote:

> I have a script in which I have " do $test" where $test refers to a
> different perl script, say foo.pl
> 
> In foo.pl when the control is trying to execute my$result =
> qx/\.\/test"/ I am getting an error saying Illegal seek. (All other
> statements execute just fine).

You need to copy-and-paste the actual error message and the actual
statement in question.  Re-typing the line is prone to typographical
errors, which obviously happened in this case.

That qx statement is all messed up.  Lose the \ and change delimiters:

   my $result = qx{./test};	# Using alternate delimiters
   my $result = `./test`;	# Or using the simple syntax

 From your description, it sounds like you are running ./test from
the command line, which invokes foo.pl, which executes ./test again.

"Illegal seek" has no meaning to us unless you include:
   *) The name of the file where the error was detected,
   *) The line number of the statement that failed,
   *) And copy-and-paste the line in question.

And
   use strict;
   use warnings;
   use diagnostics;

		-Joe


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

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 7940
***************************************


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