Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Apr 2004 16:53:10 -0400 (EDT)
From:      "Aaron Peterson" <aaron@alpete.com>
To:        drew@mykitchentable.net
Cc:        freebsd-questions@freebsd.org
Subject:   Perl Help For Newbie
Message-ID:  <2487.206.114.147.90.1083012790.squirrel@mail.alpete.com>

next in thread | raw e-mail | index | archive | help
for your regex, you might try something like:

foreach $line (@input_file)
{
    if ( ($val1,$val2,$val3) = $line =~
        /\$(\d\.\d\d)\s+\$(\d\.\d\d)\s+\$(\d\.\d\d)/ )
    {
        $changed = sprintf "%.2f",$val1 * 1.5;
        s/\$\d\.\d\d\s+\$\d\.\d\d\s+\$\d\.\d\d/\$$changed \$$val3/;
    }
}

perhaps the calculation and substitution could all be done in one line,
but it makes my head hurt to think about it.

Aaron



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2487.206.114.147.90.1083012790.squirrel>