Gerard Robin wrote:
Hello,
I guess that one can write in more perlish fashion that I did: the part between the #### of this script to pack the array @array.

Please, can someone give me some hint ?

#!/usr/bin/perl
# pack_array.pl

use strict;
use warnings;

my $string = "[EMAIL PROTECTED] n??e#w [?! \$ \% y]e{?]a##r? 2\*0\$0'\"6\# ! \^";
my @array = split / /, $string;

foreach (@array) {

 s/[EMAIL PROTECTED]"^'"\]\[\*{]//g;
}
####################################
my @pack;
my $j = 0;

foreach my $i (0..$#array) {

 if ($array[$i] eq '') {

   $i++;

 } else {

   $pack[$j] = $array[$i];

   $j++;

 }
}
#####################################

print "@pack\n";

__END__

tia


Is this what you mean?

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my $string = "[EMAIL PROTECTED] n??e#w [?! \$ \% y]e{?]a##r? 2\*0\$0'\"6\# ! \^";
$string =~ s/[EMAIL PROTECTED]"^'"\]\[\*{\s]+/ /g;
print "$string\n";

my @array = split /\s+/, $string;
print "@array\n";

__END__


--

Just my 0.00000002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to