in reply to Re: How to Split on specific occurrence of a comma
in thread How to Split on specific occurrence of a comma

I think this approach should work. thanks!

  • Comment on Re^2: How to Split on specific occurrence of a comma

Replies are listed 'Best First'.
Re^3: How to Split on specific occurrence of a comma
by LanX (Saint) on Dec 03, 2020 at 22:34 UTC
    Your welcome! :)

    on a side note

    This

      $line =~ s/^[^=]*\=//;

    is IMHO better written as

      my ($var,$list) = split /=/, $line, 2; °

    It's not only much easier to read and self-documenting, you'll also have a chance to check if $var eq "Teams"

    And if $var is of no interest you can also write

      my ( undef, $list ) = split /=/, $line;

    debugger demo

    DB<211> $line = "Teams=PATRIOTS,BILLS,DOLPHINS,JETS,COWBOYS,GIANTS,E +AGLES,REDSKINS,BENGALS,OILERS,STEELERS,BROWNS,SEAHAWKS,RAMS,49ERS,RAI +DERS" DB<212> x ($var,$list) = split /=/, $line 0 'Teams' 1 'PATRIOTS,BILLS,DOLPHINS,JETS,COWBOYS,GIANTS,EAGLES,REDSKINS,BENGAL +S,OILERS,STEELERS,BROWNS,SEAHAWKS,RAMS,49ERS,RAIDERS'

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    °) the 2 in case you are worried that the character "=" appears in your list elements