Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Split string to arrayref? SQL::Abstract

by ww (Archbishop)
on Nov 02, 2011 at 12:02 UTC ( #935366=note: print w/replies, xml ) Need Help??

in reply to Split string to arrayref? SQL::Abstract

moritz is briefer (and direct creation of the ref is likely better) but this is tut form:
#!/usr/bin/perl use Modern::Perl; # 935351 # how can I split a string (on bar character) into an array ref for us +e in SQL::Abstract? my $string = 'foo|bar|baz|bat'; my @array = split /\|/, $string; # 1 my $arrayref = \@array; # 2 spititout($arrayref); # 3 sub spititout { my $array_ref_in_sub = shift; # 4 my @workingarray = @$array_ref_in_sub; # 5 for $_(@workingarray) { # 6 say $_; } }


  1. break the string on VBARs and stuff the resulting elements to @array
  2. create a ref to @array
  3. call the sub
  4. get the ref to the original $array back from the arrayref passed to the sub
  5. dereference; put the data referenced (loosely, "pointed to") in the reference into an array with which we can work
  6. demonstrate that $array_ref_in_sub has what OP wants for SQL::Abstract

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935366]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2017-08-18 04:29 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (294 votes). Check out past polls.