mallah_rajesh has asked for the wisdom of the Perl Monks concerning the following question:

Dear Gurus,

consider

$a = `find . -maxdepth 1 -print0`;
@b = ??????  WHAT CODE ???? , $a ;

so that i have all the filenames in the array @b the problem is that the seperater is null byte.
regds
mallah, Sorry for such a late update The reason was after i posted my question i did not know where it disappeared. I i got no msg when people replied to the question. I still think its the best site for perl lovers though. back to the problem.
`find . -maxdepth 1 -print0`
was just an example. I get the data from QmailRemote (sumthing similar) perl module. but the beast sends the data seperated by null character , i need to split em. Read "RESULTS" under
http://www.die.net/doc/linux/man/man8/qmail-remote.8.html
split  /\0/, $a
does not do the trick. The find example was also meant for easy setup of the problem. Regds mallah print "JAPH";
  • Comment on splitting/unpacking a string containing data sepearted by \0

Replies are listed 'Best First'.
Re: splitting/unpacking a string containing data sepearted by \0
by Anonymous Monk on Feb 12, 2004 at 21:47 UTC
    Write code that uses one of the splitting/unpacking perl functions. Something like split /\0/, $a perl functions are documented in perlfunc
Re: splitting/unpacking a string containing data sepearted by \0
by Fletch (Bishop) on Feb 12, 2004 at 22:01 UTC

    Not to change the topic, but considering the usage of find given in this case: what's wrong with just using opendir() and readdir()?

      I'm partial to glob, myself. e.g. @files = (glob("*"), glob(".*"));

      Update: added missing parentheses.

      Update: just for fun, and those who abhor repetition: @files = map glob, qw(* .*);

      Update: duff++

        just for fun, and those who abhor repetition: @files = map glob, qw(* .*);

        What about those of us who are lazy?

        @files = glob "* .*";
      That's built into perl and requires you to write more code :)