0day has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
It is difficult to explain in words (I do not know English very well),
here is the code:
Update
There is a solution (help my friend):
It is difficult to explain in words (I do not know English very well),
here is the code:
I would like to perform such a trick in regular expression. Possible?open (my $file, '<', 'data.bin'); binmode $file; my $binary_data = <$file>; $binary_data =~ /(.)(.){$1}/; # how can I do something like that? #or better yet $binary_data =~ /(.)(.){(?{unpack 'H*', $1})}/; # ? # or may be /(.)(?{unpack 'H*', $1})(.){$^R}/; # ???
Update
There is a solution (help my friend):
but, how I can in this example, assign values to three different groups?/(.)((??{'.' x $1}))/;
There are other solutions?$_ = "3aaaa\nbbbb\nccccc\nddddd"; /(\d)((??{'.*?\n' x $1}))/; print $2; # aaaa\nbbbb\nccccc\n # how to assign a value aaaa\n of $3, bbbb\n -> $4 etc ?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regular expressions: interpolate the variable in the value of the number of repetitions for the group
by rjt (Curate) on Aug 03, 2013 at 01:40 UTC | |
by 0day (Sexton) on Aug 03, 2013 at 05:47 UTC | |
by rjt (Curate) on Aug 03, 2013 at 10:29 UTC | |
by Laurent_R (Canon) on Aug 03, 2013 at 09:41 UTC | |
Re: Regular expressions: interpolate the variable in the value of the number of repetitions for the group
by kcott (Archbishop) on Aug 03, 2013 at 10:30 UTC | |
by 0day (Sexton) on Aug 03, 2013 at 14:46 UTC |
Back to
Seekers of Perl Wisdom