Sponsored Content
Top Forums Shell Programming and Scripting Random NUmbers Generation with out repetation Post 302261583 by Konerak on Tuesday 25th of November 2008 05:35:21 AM
Old 11-25-2008
I'll even write it in perl for him if he can convince me it's not homework. But you learn a lot more from trying yourself (and having your mistakes corrected) than reading other peoples code.

There's lots of "other peoples code" on the web, too Smilie
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Random numbers without repetition

Is anyone know some scripts to generate random number without repetition using bash; for example generate 10 different random numbers. Thanks (8 Replies)
Discussion started by: asal_email
8 Replies

2. Programming

Random number generation

Hi...How can I generate random numbers between a given range ...preferably between 1 and 100...in UNIX C programming...? I tried out functions like rand(),drand48() etc but didnt get satisfactory results... Thanks a lot in advance.......... (1 Reply)
Discussion started by: tej.buch
1 Replies

3. UNIX for Dummies Questions & Answers

Random number generation in ksh

I need to generate a random number in ksh everytime I run the script ,the range should be from 100 to 24800,I could use $RANDOM but I seem to have no control over the range of numbers ,could you please suggest some way I could implement this .Thanks. Mervin (2 Replies)
Discussion started by: mervin2006
2 Replies

4. Shell Programming and Scripting

Random numbers from 0 to 1000

Hello All, I want to make a simple script which generate random number from 0 to 1000. and simply display it. Plz HELP!!!!!! Regards, Waqas Ahmed (2 Replies)
Discussion started by: wakhan
2 Replies

5. Shell Programming and Scripting

random number generation in ksh

i tried to use $random function in unix i simply typed print $random at shell and it returnted no value is there any function in korn shell that i can use to generate random number help is appreciated (2 Replies)
Discussion started by: er_zeeshan05
2 Replies

6. Shell Programming and Scripting

Random Numbers - Perl

Hi Guys I have a script to find Ranomd numbers. But I want to make the file to produce more random. Could u guys help me plz. In this Script I have the code that generates random in for loop and the range I have specified in my %chromlength input and out put will be like this chrno start end... (3 Replies)
Discussion started by: repinementer
3 Replies

7. Shell Programming and Scripting

Random word generation with AWK

Hi - I have a word GTTCAGAGTTCTACAGTCCGACGAT I need to extract all the possible "chunks" of 7 or above letter "words" from this. SO, my out put should be GTTCAGA TTCAGAG TCAGAGT CAGAGTTCT TCCGACGAT CAGTCCGACG etc. How can I do that with awk or any other language? I have no... (2 Replies)
Discussion started by: polsum
2 Replies

8. Homework & Coursework Questions

Random numbers

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! Write a shell script that will take the sum of two random number? Ex: Random n1 +Random n2 = result i tries to write it but i had some dufficulties ... (3 Replies)
Discussion started by: renegade755
3 Replies

9. AIX

Random password generation

Hello, I have created a script to generate a random password on Linux/Solaris, but I simply cannot use it on my AIX VMs since Bash isn't installed on them. I need a password that is randomly created with the following... (12 Replies)
Discussion started by: gfroute
12 Replies
PadWalker(3pm)						User Contributed Perl Documentation					    PadWalker(3pm)

NAME
PadWalker - play with other peoples' lexical variables SYNOPSIS
use PadWalker qw(peek_my peek_our peek_sub closed_over); ... DESCRIPTION
PadWalker is a module which allows you to inspect (and even change!) lexical variables in any subroutine which called you. It will only show those variables which are in scope at the point of the call. PadWalker is particularly useful for debugging. It's even used by Perl's built-in debugger. (It can also be used for evil, of course.) I wouldn't recommend using PadWalker directly in production code, but it's your call. Some of the modules that use PadWalker internally are certainly safe for and useful in production. peek_my LEVEL peek_our LEVEL The LEVEL argument is interpreted just like the argument to "caller". So peek_my(0) returns a reference to a hash of all the "my" variables that are currently in scope; peek_my(1) returns a reference to a hash of all the "my" variables that are in scope at the point where the current sub was called, and so on. "peek_our" works in the same way, except that it lists the "our" variables rather than the "my" variables. The hash associates each variable name with a reference to its value. The variable names include the sigil, so the variable $x is represented by the string '$x'. For example: my $x = 12; my $h = peek_my(0); ${$h->{'$x'}}++; print $x; # prints 13 Or a more complex example: sub increment_my_x { my $h = peek_my(1); ${$h->{'$x'}}++; } my $x=5; increment_my_x; print $x; # prints 6 peek_sub SUB The "peek_sub" routine takes a coderef as its argument, and returns a hash of the "my" variables used in that sub. The values will usually be undefined unless the sub is in use (i.e. in the call-chain) at the time. On the other hand: my $x = "Hello!"; my $r = peek_sub(sub {$x})->{'$x'}; print "$$r "; # prints 'Hello!' If the sub defines several "my" variables with the same name, you'll get the last one. I don't know of any use for "peek_sub" that isn't broken as a result of this, and it will probably be deprecated in a future version in favour of some alternative interface. closed_over SUB "closed_over" is similar to "peek_sub", except that it only lists the "my" variables which are used in the subroutine but defined outside: in other words, the variables which it closes over. This does have reasonable uses: see Data::Dump::Streamer, for example (a future version of which may in fact use "closed_over"). set_closed_over SUB, HASH_REF "set_closed_over" reassigns the pad variables that are closed over by the subroutine. The second argument is a hash of references, much like the one returned from "closed_over". var_name LEVEL, VAR_REF var_name SUB, VAR_REF "var_name(sub, var_ref)" returns the name of the variable referred to by "var_ref", provided it is a "my" variable used in the sub. The "sub" parameter can be either a CODE reference or a number. If it's a number, it's treated the same way as the argument to "peek_my". For example, my $foo; print var_name(0, $foo); # prints '$foo' sub my_name { return var_name(1, shift); } print my_name($foo); # ditto AUTHOR
Robin Houston <robin@cpan.org> With contributions from Richard Soberberg, Jesse Luehrs and Yuval Kogman, bug-spotting from Peter Scott, Dave Mitchell and Goro Fuji, and suggestions from demerphq. SEE ALSO
Devel::LexAlias, Devel::Caller, Sub::Parameters COPYRIGHT
Copyright (c) 2000-2009, Robin Houston. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.14.2 2012-06-26 PadWalker(3pm)
All times are GMT -4. The time now is 11:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy