> 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 r
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 usi
> 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 (.
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:
>
> US
> 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 () {
# do some
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 $cur
> > ($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;
> >
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
1.
$filename = 'foo.txt';
open(FH,"<$filename") or die "couldn't open $filename - $!";
while ($line = ){
print "$line matches\n" if ($line =~ /^USD /);
}
2.
while ($line=){
chomp $line;
next unless $line;
next if ($line =~ /^-+?$/);
next if ($line =~ /^=+?$/);
# only goo
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
> 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 a
--- David Gilden <[EMAIL PROTECTED]> wrote:
> Dear Casey and the list,
> Thanks for your all of your valuable help,
>
> What is $|++ for?
$| is a boolean Perl variable that determines whether the currently
selected default output stream will be unbuffered. The default it
STDOUT, so $|=1; means
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
- Original Message -
From: Paul Johnson <[EMAIL PROTECTED]>
To: David Gilden <[EMAIL PROTECTED]>
Cc: Casey West <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, April 23, 2001 10:30 PM
Subject: Re: quick PERL question
> >
> > $x = &check
On Mon, Apr 23, 2001 at 03:23:06PM -0400, David Gilden wrote:
> What is $|++ for?
perldoc perlvar
It sets the output to be unbuffered. Personally I'd use $| = 1 just to
be explicit, and in case some joker had previously set it to -1 :-)
> I could not seem to include the sub chekPrice in my if
- Original Message -
From: David Gilden <[EMAIL PROTECTED]>
To: Casey West <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, April 23, 2001 9:23 PM
Subject: quick PERL question
> Dear Casey and the list,
> Thanks for your all of your valuable help,
>
> What is $|++ for?
>
> #!/u
16 matches
Mail list logo