Re: Quick Perl Question

2001-06-19 Thread Nigel Wetters
1. $filename = 'foo.txt'; open(FH,$filename) or die couldn't open $filename - $!; while ($line = FH){ print $line matches\n if ($line =~ /^USD /); } 2. while ($line=FH){ chomp $line; next unless $line; next if ($line =~ /^-+?$/); next if ($line =~ /^=+?$/); # only good

Re: Quick Perl Question

2001-06-19 Thread Jack Lauman
Me wrote: Analysis of the code you attached. $quote_date = substr($_,0,79); The above line is pointless. --- Agreed. The next couple lines are great: ($year, $month, $mday, $hour, $minute, $second, $timezone) = $quote_date = /^Rates as of (\d+).(\d+).(\d+)

Re: Quick Perl Question

2001-06-19 Thread Me
($year, $month, $mday, $hour, $minute, $second, $timezone) = /^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+) (\w+) (.*)$/; The following code is pointless: $year = $1; $month = $2; $mday = $3; $hour = $4; $minute = $5;

Re: Quick Perl Question

2001-06-19 Thread Jack Lauman
currency.csv contains using the code below. The date has been adjusted from 2000-12-30 00:16:19 UTC to PST. The rest of the file is still not being processed. 2000-12-29,16:16:19,PST #!/usr/bin/perl # # cur2csv.pl # use strict; use vars qw($started); use vars qw($quote_date $cur_sym

Re: Quick Perl Question

2001-06-19 Thread Me
printf OUTFILE %s\,%s\,%s\,%s\,%s\,%s\,%s\n, $date, $time, $tz, $cur_sym, $cur_desc, $usd_unit, $units_usd; close(INFILE); close(OUTFILE); print STDERR \n; 1; You seem to be misunderstanding one particular aspect of perl. Given the following: while (INFILE) { # do something

Re: Quick Perl Question

2001-06-19 Thread Jack Lauman
The second loop is executing. The TEST statement worked. This will surely print out, which shows that the regex didn't match. In other words: ($cur_sym, $cur_desc, $usd_unit, $units_usd) = /^([A-Z]{3})( [A-Za-z])+\s+(\d+\.\d+)\s+(\d+\.\d+)\s*$/; Doesn't match: USD United

Re: Quick Perl Question

2001-06-19 Thread Me
The second loop is executing. The TEST statement worked. Ok. The Currency part of the email has a fixed format that is never deviated from: 1-3 $cur_sym 4 space 5-32 $cur_desc 33-35 (3) spaces 36-55 d8.d10 (.00) 56-58 (3) spaces 59-78 d8.d10 (.00)

Re: Quick Perl Question

2001-06-19 Thread Jack Lauman
Got a combination that sort of works. It returns all the required fields but truncates any line where $usd_unit or $units_usd has more than 1 digit before the decimal point. There can be as many as (8) digits before and (10) digits after the decimal point in both cases. Here's the regex I'm

Re: Quick Perl Question

2001-06-19 Thread Me
Got a combination that sort of works. It returns all the required fields but truncates any line where $usd_unit or $units_usd has more than 1 digit before the decimal point. There can be as many as (8) digits before and (10) digits after the decimal point in both cases. Here's the regex

Quick Perl Question

2001-06-18 Thread Jack Lauman
1. I want to read in a text file and match any line that begins with three capital letters followed by a space. i.e. USD How do you do that? 2. I need to ignore any blank lines, lines containing all ---, lines containing all ===. Again, how? Thanks in advance, Jack

Re: Quick Perl Question

2001-06-18 Thread Me
1. I want to read in a text file and match any line that begins with three capital letters followed by a space. i.e. USD while () { /^[A-Z]{3} / and dostuff; # $_ contains line } 2. I need to ignore any blank lines, lines containing all ---, lines containing all ===.

Re: Quick Perl Question

2001-06-18 Thread Me
I forgot to explain. 1. I want to read in a text file and match any line that begins with three capital letters followed by a space. i.e. USD while () { will read from the file(s) you specify on the command line when you run your perl script, ie perl myscript.pl

RE: quick PERL question

2001-04-23 Thread King, Jason
M.W. Koskamp writes .. The special variable $| sets the autoflush. See PERLVAR documentation. Whats this person does is a dirty way of setting $| to a true value (not 0 or undef). Default = 0. why do you say 'dirty' ? .. do you just mean 'less readable' ? .. or are you implying some other