[tpm] Regex question

Tom Legrady legrady at gmail.com
Fri Oct 19 20:07:49 PDT 2012


Since it's a fixed format, I would go with unpack (inventing appropriate
widths)

my ( $zone, $supply, $exhaust, $fan, $flow ) = unpack "A25A10A10A10A10"
$line;
$supply   += 0;  # convert strings to numbers
$exhaust += 0;
$fan        += 0;
$flow       += 0;

and work from there

On Fri, Oct 19, 2012 at 9:43 PM, Chris Jones <cj at enersave.ca> wrote:

>  I pull data from long files in that are in a fixed format, ascii report.
>
> For example:
>                                SUPPLY   EXHAUST             MINIMUM
>      ZONE                       FLOW      FLOW       FAN      FLOW
>      NAME                     (CFM )    (CFM )      (KW)    (FRAC)
>
> Kitchen Area 1C Spc zn         2750.     1400.     0.249     1.000
> Kitchen Area 1C Pl zn             0.        0.     0.000     0.000
>
> The Zone names are a max a maximum of 25 characters - spaces allowed.   I
> want to split the lines into the zone name field and the 4 number fields:
> I am hoping the first pattern will leave the last character and remove the
> trailing spaces up to the maximum of 25 characters (assuming the user would
> have at least one character in the zone name.).
>
> I am hoping the following does the trick but I think the first pattern
> will end up removing the last character in the zone name:
>
> my @zoneLine = split /[\w\s{0,25)$]/+\w{4}/, $inLine;
>
> At any rate, the above gives me a compile error:
>
> Search pattern not terminated at Test-Split-1.pl line 5.
>
> Any help appreciated!
>
>
> **
>
> ** >>
> Christopher Jones, P.Eng.
> Suite 1801, 1 Yonge Street
> Toronto, ON M5E1W7
> Tel. 416-203-7465
> Fax. 416-946-1005
> email cj at enersave.ca
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20121019/a6a5a260/attachment.html>


More information about the toronto-pm mailing list