Convert perl qw list to text file list?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert perl qw list to text file list?
# 1  
Old 05-06-2010
Hammer & Screwdriver Convert perl qw list to text file list?

Does anyone have a good example? I am having trouble looping..

Thanks
# 2  
Old 05-06-2010
Something like this?
Code:
#!/usr/bin/perl

my $outfile = 'fruits.txt';
my @fruits = qw(apple banana orange);

open(OUT,">$outfile") or die $!;

foreach my $fruit (@fruits) {
        printf OUT "$fruit\n";
    }

close(OUT);

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting a list of words from a text file

Hello, I have a list of words separated by spaces I am trying to delete from a text file, and I could not figure out what is the best way to do this. what I tried (does not work) : delete="password key number verify" arr=($delete) for i in arr { sed "s/\<${arr}\>]*//g" in.txt } >... (5 Replies)
Discussion started by: Hawk4520
5 Replies

2. Shell Programming and Scripting

Convert list of numbers to text range

Hi, I'd like to take a list of numbers (with a prefix) and convert to a range, for example: cn001 cn004 cn016 cn017 cn018 cn019 cn020 cn021 cn031 cn032 cn038 cn042 cn043 cn044 cn045 (5 Replies)
Discussion started by: chrissycc
5 Replies

3. Homework & Coursework Questions

Loop to Convert a list from an input file and output it to another file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: A) Write a script, which will take input from a file and convert the number from Centigrade to Fahrenheit... (5 Replies)
Discussion started by: AliTheSnake
5 Replies

4. Programming

Perl list file

Hi all I am looking for a way to list files in a directoy using perl but then exlude some of the results i've got this to list the files, but how can exclude some of the results #!/usr/bin/perl $d = "/data"; opendir(DIR, $d); foreach my $file (readdir(DIR)) { print "Version:... (5 Replies)
Discussion started by: ab52
5 Replies

5. Shell Programming and Scripting

Extract list of IP addresses from a text file.

I have an xml file with IP addresses all over the show. I want to print only the IP addresses and cut off any text before or after the IP address. Example: Note: The IP addresses (x.x.x.x) do not consistently appear in the xml file as per the pattern below. Sometimes there are text before... (8 Replies)
Discussion started by: lewk
8 Replies

6. Programming

c++ function to convert a linear list to circular list

hi all, i need a c++ function which converts a linear list to circular. presently i am working with two files. i.e., one linear list file. and one circular list file to do some operations. i thought it will be helpful if there is a function that converts a linear list to circular n undo the... (1 Reply)
Discussion started by: vidyaj
1 Replies

7. Shell Programming and Scripting

Is it possible to convert text file to html table using perl

Hi, I have a text file say file1 having data like ABC c:/hm/new1 Dir DEF d:/ner/d sd ...... So i want to make a table from this text file, is it possible to do it using perl. Thanks in advance Sarbjit (1 Reply)
Discussion started by: sarbjit
1 Replies

8. Shell Programming and Scripting

List moved files in text file

Hi. I am actually doing all of this on OSX, but using unix apps and script. I have built my own transparent rsync/open directory/mobility/etc set of scripts for the firm I work at, and it is all almost complete except for ONE THING. I have the classic problem with rsync where if a user... (0 Replies)
Discussion started by: Ashtefere
0 Replies

9. Shell Programming and Scripting

Plain Text List to HTML List

Hello, I am trying to take a simple list (from echo, not a file) and turn it into a list with HTML codes. List item one. List item two. List item three. to <ol> <li>List item one.</li> <li>List item two.</li> <li>List item three.</li> </ol> The list is coming in via echo on... (4 Replies)
Discussion started by: QuestunAthority
4 Replies

10. Shell Programming and Scripting

Convert XML file into TEXT file using PERL seript

Dear Yogesh..."Convert XML file into TEXT file using PERL seript"... can u help me regarding this issue...plz Thanks Rudro (0 Replies)
Discussion started by: Rudro
0 Replies
Login or Register to Ask a Question