in reply to find, then store functions into array problem

This appears to do what you need.

#!/usr/bin/perl -w use strict; while (my $righteq = <DATA>) { my @remaining = $righteq =~ /([a-z]\^(?:[a-z]|\([a-z][+-]\d+(?:\.\ +d+)?\)))/g; print '$remaining[',$_,'] is ',$remaining[$_],$/ for 0..$#remainin +g; } __DATA__ +++-+++t^n+++f^n+e^(t-123.22) t^n+--++-+f^n++e^(t-123.22)++ +++++---+t^n+f^n+++e^(t-123.22)-

Output:

$remaining[0] is t^n $remaining[1] is f^n $remaining[2] is e^(t-123.22) $remaining[0] is t^n $remaining[1] is f^n $remaining[2] is e^(t-123.22) $remaining[0] is t^n $remaining[1] is f^n $remaining[2] is e^(t-123.22)

**Update:** changed to read into $righteq instead of using $_.

90% of every Perl application is already written. ⇒ |

dragonchild |

Replies are listed 'Best First'. | |
---|---|

Re: Re: find, then store functions into array problem
by hideki-san (Initiate) on May 04, 2003 at 23:28 UTC |

In Section
Seekers of Perl Wisdom

Comment onRe: find, then store functions into array problemSelectorDownloadCode