Prev: Need to capture Log of each thread --Parallel::ForkManager;
Next: FAQ 3.11 Where can I get Perl macros for vi?
From: Tad McClellan on 30 Jun 2010 13:03 Sooraj S <soorajspadmanabhan(a)gmail.com> wrote: > I want to read all the data from a file into an array. But if there > is any "#" character in the file it should be replaced with "&" > character. How to store "$_" into an array? If you want all the lines in an array, then read all of the lines into an array in the first place. -------------------------- #!/usr/bin/perl use warnings; use strict; local @ARGV = './ip_file'; my @tmp_arr = <>; foreach (@tmp_arr) { tr/#/&/; } foreach (@tmp_arr) { print; } -------------------------- -- Tad McClellan email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/" The above message is a Usenet post. I don't recall having given anyone permission to use it on a Web site.
From: J�rgen Exner on 30 Jun 2010 22:32
Peter Valdemar M�rch <4ux6as402(a)sneakemail.com> wrote: >On Jun 30, 5:00�pm, J rgen Exner <jurge...(a)hotmail.com> wrote: >> Where is this array coming from? You never declared it (are you using >> warnings and strictures? You absolutely should!!!) and never defined it, >> therefore it is empty and this loop will never be executed. > >Uhm, didn't he in fact declare it explicitly?: You are right, sorry. Still, he doesn't put any values in it. jue |