473,466 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Perl code for spiltting numerical value from a input file

2 New Member
can any one give a code for spilitting a numerical value randomly from a input file.....
Feb 11 '08 #1
5 1076
eWish
971 Recognized Expert Contributor
What have you tried? We need some effort here...

--Kevin
Feb 11 '08 #2
KevinADC
4,059 Recognized Expert Specialist
What have you tried? We need some effort here...

--Kevin

Yes, and an example of whatever the hell-o that vague requirement actually means would be helpful too.
Feb 11 '08 #3
Kelicula
176 Recognized Expert New Member
Here ya go!!

Expand|Select|Wrap|Line Numbers
  1.  
  2. #!/usr/bin/perl -T
  3.  
  4. my $inputfile = '/dir/file.txt';
  5.  
  6. $input = $inputfile =~ s/\d*/$1/;
  7. @input = split(//,$input);
  8.  
  9. $result = $input[int(rand($#input))]
  10.  
  11. # $result is now a random "split" number from an input file !! heheheee.... :)
  12.  
  13.  
That's what you get.

Sorry guys, I'm in a mood... hehehee
Feb 11 '08 #4
numberwhun
3,509 Recognized Expert Moderator Specialist
Really man! Can't you see that the Kevin's were trying to get the OP to provide the code that they have been trying? This is a learning forum, not a code writing service. Of course, you just gave him the answer to what could have been school work.

Please do not do that again, it completely undermines our efforts to have the OPs learn from their questions.

Regards,

MODERATOR
Feb 11 '08 #5
Kelicula
176 Recognized Expert New Member
Really man! Can't you see that the Kevin's were trying to get the OP to provide the code that they have been trying? This is a learning forum, not a code writing service. Of course, you just gave him the answer to what could have been school work.

Please do not do that again, it completely undermines our efforts to have the OPs learn from their questions.

Regards,

MODERATOR

I apologize.
Did you look at the code?

All it does is see if there are any 0-9's present within the "name" of a file.
If so it omit's everything but them.
And splits them into an array, and returns a random one of them

So you see it: "can any one give a code for spilitting a numerical value randomly from a input file".

I was trying to prove to him that with such a vague question, you'll get a vague (most likely not effective) answer.

(It probably doesn't even work)

But I knew when I posted it, that it may be out of line.
Making fun of OP's.

For that I apologize.

Won't happen again.
Feb 11 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Andries | last post by:
Hello there, I hope someone can help me. This is my problem: I have a list of thousands and thousands of the next lines: ----------------------------------------------------------------------...
7
by: Piotr Turkowski | last post by:
Hi! I've got some code in Perl and I have to have it in C, but my knowlege of Perl is < 0 :-(, so I need your help. here's the code. Thanks in advance. decrypt.pl #!/usr/local/bin/perl...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
21
by: Mick1000 | last post by:
Hi all, I am new to perl and this forum. I am trying to setup a mailing list subscription functionality for customers to receive a periodic newsletter from me. My perl program grabs the html form...
6
by: Paulchen | last post by:
Hello, I have found a perl script and need to "translate" this to PHP. I try to do it step by step and the first part of it is this function (the whole script is found at...
1
by: jasper123 | last post by:
Hello, I am developing a cgi-perl script that takes some value from a html form as input and stores them in a data file. I have a program called "irr" in my server, it is executed just by typing irr...
66
by: happyse27 | last post by:
Hi All, my html code is sno 1) and perl code is sno 2). a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.