Hi All,
I'm new to Perl, and to PM so gentle guidance is welcome! Having said that I do have many years on computers.
I am attepting to write a Perl script to retrieve an email from a pop3 mailserver. The email contains only one line of text that is comprised of 6 tab delimited data fields so I need to parse the 6 data values to a mysql data base. I've been able to connect to the server and download the email, and I know enough mysql to make that work .... but I can't do the simplest part in the middle, which is extract the 6 individual data values from the text! I'm willing to work at it, have googled and have good books, but still cna not figure out how to use regexp search and then assign variable names to the data values. Initially I'm just trying to print the variables to see if I got them.
Thanks for all suggestions.
Jim
=================
data file
1234567890123456 2004-07-10 14:47:39 51.12345 -1.12345
=================
my latest failing perl script!
#!/usr/bin/perl
open (INPUT, "< data")
or die "Couldn't open data file for reading: $!\n";
while (<INPUT>) {
$firstvalue =~ /(\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d)/; # match first 16
+ digit value
print $firstvalue #"This is the first parameter.\n";
}
close (INPUT);
text
janitored by ybiC: Balanced <code> tags around codeblock, as per Monastery convention.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.