Re: perl coding ?
At 2004-04-21T22:15:17Z, Mark Ovens <[EMAIL PROTECTED]> writes: > You are quite correct; I just copied the OP's variable names. I had kind of assumed that you'd that, but wanted to make sure that I wasn't missing something. :) -- Kirk Strauser pgp0.pgp Description: PGP signature
Re: perl coding ?
Kirk Strauser wrote: At 2004-04-21T17:29:34Z, Mark Ovens <[EMAIL PROTECTED]> writes: $dup-number = substr($dup-counter, 0, length($dup-counter) - 1); Did you actually test that? I'm pretty sure Perl doesn't like dashes in variable names: % perl -e '$foo-bar = 1;' Can't modify subtraction (-) in scalar assignment at -e line 1, near "1;" Execution of -e aborted due to compilation errors. You are quite correct; I just copied the OP's variable names. He has since sent me a copy of the script and it does use '_' rather than '-' so I guess it was a typo in his e-mail. Thanks for pointing it out. Regards, Mark ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: perl coding ?
At 2004-04-21T17:29:34Z, Mark Ovens <[EMAIL PROTECTED]> writes: > $dup-number = substr($dup-counter, 0, length($dup-counter) - 1); Did you actually test that? I'm pretty sure Perl doesn't like dashes in variable names: % perl -e '$foo-bar = 1;' Can't modify subtraction (-) in scalar assignment at -e line 1, near "1;" Execution of -e aborted due to compilation errors. -- Kirk Strauser "94 outdated ports on the box, 94 outdated ports. Portupgrade one, an hour 'til done, 82 outdated ports on the box." pgp0.pgp Description: PGP signature
Re: perl coding ?
>> An temp field $dup-counter contains an counter that is >> suffixed with x as in 23x have no idea how big of an >> number the counter can grow to. The suffix is all ways >> one position but has different alpha values. >> >> How do I separate $dup-counter into two new fields? >> $dup-number and $dup-sufix > This will do it: > > $dup-number = substr($dup-counter, 0, length($dup-counter) - 1); > $dup-suffix = substr($dup-counter, -1, 1); or alternately: ($dup-number,$dup-suffix) = $dup-counter =~ /(\d+)(\w+)/; the regex could be loosened or made more strict as needed... aaron ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: perl coding ?
JJB wrote: I have an perl scrip somebody else wrote. I am just learning perl by modifying this script. An temp field $dup-counter contains an counter that is suffixed with x as in 23x have no idea how big of an number the counter can grow to. The suffix is all ways one position but has different alpha values. How do I separate $dup-counter into two new fields? $dup-number and $dup-sufix This will do it: $dup-number = substr($dup-counter, 0, length($dup-counter) - 1); $dup-suffix = substr($dup-counter, -1, 1); HTH Regards, Mark Thanks for you help ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]" . ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
perl coding ?
I have an perl scrip somebody else wrote. I am just learning perl by modifying this script. An temp field $dup-counter contains an counter that is suffixed with x as in 23x have no idea how big of an number the counter can grow to. The suffix is all ways one position but has different alpha values. How do I separate $dup-counter into two new fields? $dup-number and $dup-sufix Thanks for you help ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
perl coding ?
I have an perl scrip somebody else wrote. I am just learning perl by modifying this script. An temp field $dup-counter contains an counter that is suffixed with x as in 23x have no idea how big of an number the counter can grow to. The suffix is all ways one position but has different alpha values. How do I separate $dup-counter into two new fields? $dup-number and $dup-sufix Thanks for you help ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"