[EMAIL PROTECTED] wrote:
Thanks for the repsponse guys!!! With your help ( really the direct
answer ) I was able to get this going! Below is my final script that
works like a charm.

The only question for learning purposes is, what does "=~ /[-+]?[\d.]+/
g;" actually do?

=~ is the binding operator. It binds the expression on the left (readline) to the match operator on the right in scalar context so only the first line is read from the file. The regular expression matches a '-' or a '+' character zero or one time followed by a numerical digit or a '.' character one or more times. The /g global option is used so all fields that matched are returned in list context.


My Perl Cookbook doesn't explain ( or I just don't
know where to look ) to me how that parsed each field within the first
line of the file I'm opening...

There are two basic ways to use regular expressions to extract data from a string. Use split() to remove data that you don't want or use a global m//atch to extract data that you do want.

For example:

# remove non-digits return list of digit strings
my @data = split /\D+/, $string;

# extract list of digit strings
my @data = $string =~ /\d+/g;



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to