11983 How to take the data from array - Perl Programming
Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
How to take the data from array

Posted by amarnathreddy (amarnathreddy), 6 December 2007
{name {
[0]{name "EMS",value "LSN/EMS_XDM_5"},
[1]{name "ManagedElement",value "4430"}
}


The required format is name  value
                                   EMS     LSN/EMS_XDM_5
                                   M         44

(I require the syntax for collecting the values into an array .And also when multiple arrays exists)
(  i am reading data from a log file.and I have to store in another file)


Posted by KevinAD (KevinAD), 6 December 2007
You were asked to provide your existing perl code in your other post. As Graham said, this is a technical help forum, not a script writing service. Please post your exisiting perl code.

Posted by amarnathreddy (amarnathreddy), 6 December 2007
#!/usr/bin/perl -w
$LOGFILE = "extr.log";
open(LOGFILE) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
   
   ($name, $value) = split(' ',$line);
   
   chop($name);
   chop($value);
   }
close(LOGFILE);
(I asked the syntax for collecting data from an array,not for the script)




Posted by amarnathreddy (amarnathreddy), 6 December 2007
#!/usr/bin/perl -w
$LOGFILE = "extr.log";
open(LOGFILE) or die("Could not open log file.");
foreach $line (<LOGFILE>) {
   
   ($name, $value) = split(' ',$line);
   
   chop($name);
   chop($value);
   }
close(LOGFILE);
(I asked the syntax for collecting data from an array,not for the script)




Posted by KevinAD (KevinAD), 6 December 2007
Sorry, I don't think I can help you. I have little to no idea what your question is. Maybe somene else will understand you.

Posted by admin (Graham Ellis), 7 December 2007
I'm starting to see a pattern with
EMS     LSN/EMS_XDM_5
being extracted from
[0]{name "EMS",value "LSN/EMS_XDM_5"},

but I don't see how you decide that you need to extract
M         44
from
[1]{name "ManagedElement",value "4430"}

I could write you a regular expression of something to do either or both of the extractions (are you familiar with regular expressions?) but rather better I think for you to come along here on Monday, 7th January and make it a long day - I'm quite happy to cover specific and help you in to the evening at no extra charge



Posted by KevinAD (KevinAD), 8 December 2007
Graham, the link you posted appears to be incorrect:

http://www.wellho.ne/refull.html



Posted by admin (Graham Ellis), 9 December 2007
Thanks, Kevin .... serves me right for advertising my own training courses.   It should have been http://www.wellho.net/course/refull.html ... and I have now corrected the original too.  



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2013: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho
0