![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to store values into variable in perl | chittiprasad15 | Linux | 3 | 05-07-2008 09:21 PM |
| Need help to write a Perl script | user_prady | Shell Programming and Scripting | 10 | 03-25-2008 11:38 PM |
| how to get last value in an array in perl | meghana | Shell Programming and Scripting | 7 | 02-04-2008 02:12 PM |
| formating array file output using perl | seismic_willy | Shell Programming and Scripting | 4 | 03-21-2007 11:23 PM |
| need help to write perl code | getdpg | Shell Programming and Scripting | 0 | 09-20-2006 06:24 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
perl -write values in a file to @array in perl
Hi
can anyone suggest me how to write a file containing values,... say 19 20 21 22 .. 40 to an array @array = (19, 20, ... 40) -- Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
open(FILE, "<", "file");
while(<FILE>) {
chomp;
push(@arr, $_);
}
close(FILE);
|
|
#3
|
|||
|
|||
|
thanks for the reply.. but it dint work... do u have any further suggestions???
|
|
#4
|
|||
|
|||
|
Quote:
What is the expected output ? Do you want to print the array elements ? If so, add the following snippet at the end Code:
foreach(@arr) {
print "array element: $_\n";
}
|
|
#5
|
|||
|
|||
|
i dont know but.. this one worked for me...
open(FILE, "<", "tmpfile"); my @values = <FILE>; close(FILE); i just wanted to write the values of a file into @array... but still.. ur example helped me as a start point... appreciate it.. thanks again... |
|
#6
|
|||
|
|||
|
can you help me on this... i try to print them($count, $last_rec) in two different lines but they get printed in one line if i use this script.....
open (fh,">>","file"); print fh "$count"; print fh "$last_rec"; close(fh); can you suggest any solution for this...thanks |
|
#7
|
|||
|
|||
|
Quote:
The other one I had posted should also work |
|||
| Google The UNIX and Linux Forums |