Perl

Moderators: Jonathan
Number of threads: 1259
Number of posts: 3644

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
string processing Posted by Michael32180 on 20 Mar 2002 at 6:53 PM
i have a string and i would like to be able to pull out the words in the string and store them, in either an array or a hash. all the words are separated by one or more spaces and consist of numeric values, alpha-numeric words, dates, and times. the string was pulled from a log file. i need to display the most recent line in the log file and output the different values. any help would be appreciated! thanks
Report
Re: string processing Posted by Xfactor on 21 Mar 2002 at 7:45 PM
: i have a string and i would like to be able to pull out the words in the string and store them, in either an array or a hash. all the words are separated by one or more spaces and consist of numeric values, alpha-numeric words, dates, and times. the string was pulled from a log file. i need to display the most recent line in the log file and output the different values. any help would be appreciated! thanks
:
The easiest way that I know of is to use the split command. The syntax is:

@array = split /pattern/, $string

@array is the array that is returned after the split is executed
pattern what you are parsing on. This is usually a regular expression.
$string is the string you are parsing.

I hope this helps.

X



 

Recent Jobs