perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
The following demonstrates the problem:
If I put the params in an array, the 006 collapses right off the bat:n> perl -E 'use P; my $fmt="prod\t006\t2.13\tx86_64\trpm";P $fmt; my $str=P $fmt;P "str=\"$str\""; my @flds=split /\t/,"$str"; foreach (@flds) { Pe "%s \x83", "$_"; } P " "; ' prod 006 2.13 x86_64 rpm str="prod 006 2.13 x86_64 rpm" prod 6 2.13 x86_64 rpm
Using qw the tabs don't expand (so the split doesn't work anyway), but the 6 still collapses:perl -E 'use P; my $fmt=["%s\t%s\t%s\t%s\trpm","prod", "006", "2.13", "x86_64", "rpm"] +; P "%s", $fmt; # already converted ' ["%s %s %s %s rpm","prod",6,2.13,"x86_64","rpm"]
Quirky combo to hack it:> perl -E 'use P; my $fmt=[qw(%s\t%s\t%s\t%s\t%s prod 006 2.13 x86_64 rpm)]; P "%s", $fmt; # already converted before fmt my $str=P @$fmt; P "str=\"$str\""; my @flds=split "\t","$str"; Pe "(%s) \x83", "$_" foreach @flds; P " ";' ["%s\t%s\t%s\t%s\t%s","prod",6,2.13,"x86_64","rpm"] str="prod\t6\t2.13\tx86_64\trpm" (prod\t6\t2.13\tx86_64\trpm)
But running that in the prog I ended up with:> perl -E 'use P; my $fmt=["%s\t%s\t%s\t%s\t%s", qw( prod "006" "2.13" x86_64 rpm)]; P "%s", $fmt; # already converted before fmt my $str=P @$fmt; P "str=\"$str\""; my @flds=split "\t","$str"; Pe "(%s) \x83", "$_" foreach @flds; P " ";' ["%s %s %s %s %s","prod",""006"",""2.13"","x86_64"," +rpm"] str="prod "006" "2.13" x86_64 rpm" (prod) ("006") ("2.13") (x86_64) (rpm)
!!!! Guess I'll keep poking at it... there's gotta be a way... but dang if this isn't harder than it should be...Recycling 1 duplicates...(cannot stat, already deleted?) path=/Share/s +use/distribution/12.1/repo/oss/suse/test2/smugbatch-"006"-"2.1.3".x86 +_64.rpm, dev=(undef)
p.s. maybe I'll just toss an eval on that final string and forget figuring out how to quote it...urg...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: is split suppose to drop 0's from strings?
by roboticus (Chancellor) on Mar 05, 2013 at 23:33 UTC | |
by perl-diddler (Chaplain) on Mar 06, 2013 at 01:03 UTC | |
by perl-diddler (Chaplain) on Mar 06, 2013 at 03:08 UTC | |
|
Re: is split suppose to drop 0's from strings?
by kielstirling (Scribe) on Mar 05, 2013 at 23:00 UTC | |
|
Re: is split suppose to drop 0's from strings?
by Anonymous Monk on Mar 06, 2013 at 07:42 UTC |