Sponsored Content
Top Forums Shell Programming and Scripting problem to read data in array Post 302379551 by patrick87 on Friday 11th of December 2009 04:10:51 AM
Old 12-11-2009
problem to read data in array

My input is a long list of data start with "#":
Code:
#read_1
123456898787987

#read_2
54645646540646406

#read_3
4654564654316
.
.

I got a bit confusing about how to set all in an array first. And then when I run a program name "statistic_program", it will read the array in scalar and do it one by one continuously.
I got think to use "While Read Array Do Done", just I not sure how to let the "statistic_program", run the input file data one by one.
Below is the perl script that I just try.
Code:
#!/usr/bin/perl
use strict;
use warnings;
open(FILE,"<INPUT_FILE.txt");
my($file)=<FILE>;
my@lines=split('#',$file);
foreach my $data (@lines){
system "/statistic_program $data >> output.txt"}
exit 0;

Unfortunately, the perl script can't work nice as well Smilie
Thanks for any suggestion and advice.

Last edited by patrick87; 12-11-2009 at 06:04 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to read the data from an excel sheet and use those data as variable in the unix c

I have 3 columns in an excel sheet. c1 c2 c3 EIP_ACCOUNT SMALL_TS_01 select A.* from acc; All the above 3 col shoud be passed a variable in the unix code. 1.How to read an excel file 2.How to pass these data as variable to the unic script (1 Reply)
Discussion started by: Anne Grace
1 Replies

2. Shell Programming and Scripting

how to read a var value into array

Hi I need to read a value of the variable into array so each character/digit will become an array element,for example: A=147921231432545436547568678679870 The resulting array should hold each digit as an element. Thanks a lot for any help -A (7 Replies)
Discussion started by: aoussenko
7 Replies

3. Shell Programming and Scripting

Read array from a file

Hi I've a config file like: file1 #comment k_array: 1 2 3 4 5 n_array: 7 8 9 0 11 I'd like to write a script that read it and store k_array and n_array in 2 arrays. I mean the script should be able to use both as array. I've tried to use awk as (only for one array): ... (5 Replies)
Discussion started by: Dedalus
5 Replies

4. AIX

Tape drive problem - no process to read data written to a pipe

Hi Everyone, The machine I'm working on is an AIX 5.3 LPAR running on a P650. oslevel -r shows 5300-08. I'm trying to take a backup to a SCSI tape drive, which has been working up until this point. I know of nothing that has changed recently to cause this problem. But when I try to take a... (0 Replies)
Discussion started by: need2bageek
0 Replies

5. Programming

Problem with read data from serial device

I have problem with C programming. I want to send & receive data through serial communication. I send data(command) to device to get data from device but when receive data, it can't get altogether of data. It get only some data. What should I do to get altogether of data? If all of... (7 Replies)
Discussion started by: noppon_s
7 Replies

6. Shell Programming and Scripting

Array; while read line do problem

Hi - I don't understand why the following script isn't working. I want to read the contents of a while loop into an array, but it looks like the array is destroyed once the while loop is finished. Can anybody help? someFile: PC_1 wf_test1 Test PC_2 wf_test2 Test PC_3 wf_test3 Test Script:... (3 Replies)
Discussion started by: lt1776
3 Replies

7. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

8. Shell Programming and Scripting

Read file and get the data then put it in array

Hi, I have a file called "readfile" it contains below parameters #cat readfile word=/abc=225,/abc/cba=150 three=12 four=45 five=/xyz/yza likewise multiple line. From the above file, I have to read "word" output should be like, /abc /abc/cba these values need to be put in... (3 Replies)
Discussion started by: munna_dude
3 Replies

9. Programming

C++ how would you read this file into an array.

here is the pesudo file. REREREEEEEERRRREER SOMEStrinG1234 RERRRR EEERRRREER SOMEStrinG1224 REREREEEREERRR REE SOMEStrinG1214 REREREREREREREEEER SOMEStrinG1204 RERE EEEEEERRRRRRR SOMEStrinG1294 REREEREEE ERRRREER SOMEStrinG1284 REREREEEEEERR REER here is my attempted code #include... (3 Replies)
Discussion started by: briandanielz
3 Replies

10. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies
Acme::Brainfuck(3)					User Contributed Perl Documentation					Acme::Brainfuck(3)

NAME
Acme::Brainfuck - Embed Brainfuck in your perl code SYNOPSIS
#!/usr/bin/env perl use Acme::Brainfuck; print 'Hello world!', chr ++++++++++. ; DESCRIPTION
Brainfuck is about the tiniest Turing-complete programming language you can get. A language is Turing-complete if it can model the opera- tions of a Turing machine--an abstract model of a computer defined by the British mathematician Alan Turing in 1936. A Turing machine con- sists only of an endless sequence of memory cells and a pointer to one particular memory cell. Yet it is theoretically capable of perform- ing any computation. With this module, you can embed Brainfuck instructions delimited by whitespace into your perl code. It will be trans- lated into Perl as parsed. Brainfuck has just just 8 instructions (well more in this implementation, see "Extensions to ANSI Brainfuck" below.) which are as follows Instructions + Increment Increase the value of the current memory cell by one. - Decrement Decrease the value of the current memory cell by one. > Forward Move the pointer to the next memory cell. < Back Move the pointer to the previous memory cell. , Input Read a byte from Standard Input and store it in the current memory cell. . Output Write the value of the current memory cell to standard output. [ Loop If the value of the current memory cell is 0, continue to the cell after the next ']'. ] Next Go back to the last previous '['. Extensions to ANSI Brainfuck This implementation has extra instructions available. In order to avoid such terrible bloat, they are only available if you use the ver- bose pragma like so: use Acme::Brainfuck qw/verbose/; The extra instructions are: ~ Reset Resets the pointer to the first memory cell and clear all memory cells. # Peek Prints the values of the memory pointer and the current memory cell to STDERR. See also "Debugging" below. Debugging By using the debug pragma like this: use Acme::Brainfuck qw/debug/; you can dump out the generated perl code. (Caution: it is not pretty.) The key to understanding it is that the memory pointer is repre- sented by $p, and the memory array by @m Therefore the value of the current memory cell is $m[$p]. RETURN VALUE
Each sequence of Brainfuck instructions becomes a Perl block and returns the value of the current memory cell. EXAMPLES
JABH #!/usr/bin/env perl use Acme::Brainfuck; print "Just another "; ++++++[>++++++++++++++++<-]> ++.-- >+++[<++++++>-]<.>[-]+++[<------>-]< +.- +++++++++.--------- ++++++++++++++.-------------- ++++++.------ >+++[<+++++++>-]<.>[-]+++[<------->-]< +++.--- +++++++++++.----------- print " hacker. "; Countdown #!/usr/bin/env perl use strict; use Acme::Brainfuck qw/verbose/; print "Countdown commencing... "; ++++++++++[>+>+<<-] >>+++++++++++++++++++++++++++++++++++++++++++++++<< ++++++++++[>>.-<.<-] print "We have liftoff! "; Reverse #!/usr/bin/env perl use Acme::Brainfuck qw/verbose/; while(1) { print "Say something to Backwards Man and then press enter: "; +[->,----------]< print 'Backwards Man says, "'; [+++++++++++.<]< print "" to you too. "; ~ } Math #!/usr/bin/env perl use Acme::Brainfuck; use strict; use warnings; my $answer = +++[>++++++<-]> ; print "3 * 6 = $answer "; VERSION
1.1.1 Apr 06, 2004 AUTHOR
Jaldhar H. Vyas E<lt>jaldhar@braincells.comE<gt> THANKS
Urban Mueller - The inventor of Brainfuck. Damian Conway - For twisting perl to hitherto unimaginable heights of weirdness. Marco Nippula <http://www.hut.fi/~mnippula/> - Some code in this module comes from his brainfuck.pl Mr. Rock - Who has a nice Brainfuck tutorial at <http://www.cydathria.com/bf/>. Some of the example code comes from there. COPYRIGHT AND LICENSE
Copyright (c) 2004, Consolidated Braincells Inc. Licensed with no warranties under the Crowley Public License: "Do what thou wilt shall be the whole of the license." perl v5.8.3 2004-04-06 Acme::Brainfuck(3)
All times are GMT -4. The time now is 06:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy