|
Posted by Wolfram Humann on August 24, 2006, 4:47 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,
> There
> is a rogue carriage return (0xd) in the string
> Is there something I can do to deal with this
> situation?
Repair the corrupted file:
perl -p -i -e 'tr/\r//d' bad_file
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
Posted by anno4000 on August 24, 2006, 7:15 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,
> There
> is a rogue carriage return (0xd) in the string
> Is there something I can do to deal with this
> situation?
Repair the corrupted file:
perl -p -i -e 'tr/\r//d' bad_file
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
Posted by wolfram.humann on August 24, 2006, 9:53 pm
Please log in for more thread options >>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,
> There
> is a rogue carriage return (0xd) in the string
> Is there something I can do to deal with this
> situation?
Repair the corrupted file:
perl -p -i -e 'tr/\r//d' bad_file
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
Posted by Brian McCauley on August 25, 2006, 7:05 am
Please log in for more thread options >>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,
> There
> is a rogue carriage return (0xd) in the string
> Is there something I can do to deal with this
> situation?
Repair the corrupted file:
perl -p -i -e 'tr/\r//d' bad_file
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
Posted by wolfram.humann on August 27, 2006, 9:49 pm
Please log in for more thread options Brian McCauley wrote:
> wolfram.humann wrote:
>
>> So I think I will stick to my original idea, stuff it into a sub like this:
>>
>> sub resolve
>> {
>> my ($tmp, $path) = @_;
>> $tmp = $tmp-> for split '\.', $path;
>> return $tmp;
>> }
>
> Sooner or later you'll probably wish you'd written that as an lvalue
> sub
>
> sub resolve : lvalue
> {
> my $tmp = \shift;
> $tmp = $$tmp-> for split '\.', shift;
> $$tmp;
> }
>
Hey, I haven't read perlsub in a while -- I didn't even know about these. But
I'm slightly concerned
to use something with a fat warning "Lvalue subroutines are EXPERIMENTAL".
Always fearing that
someone might decide that it was not such a good idea after all and remove them
altogether...
Thanks for the hint!
|
| Similar Threads | Posted | | Splitting a string with placeholders | April 13, 2007, 1:24 pm |
| how access to hash which contains hash and sclar var? | December 12, 2004, 12:09 am |
| FAQ 4.27: How can I access or change N characters of a string? | December 22, 2004, 6:03 am |
| FAQ 4.27 How can I access or change N characters of a string? | February 21, 2005, 12:03 pm |
| FAQ 4.27 How can I access or change N characters of a string? | April 29, 2005, 5:03 am |
| FAQ 4.27 How can I access or change N characters of a string? | July 14, 2005, 10:03 pm |
| FAQ 4.27 How can I access or change N characters of a string? | August 20, 2005, 10:03 pm |
| FAQ 4.27 How can I access or change N characters of a string? | February 25, 2006, 12:03 pm |
| FAQ 4.27 How can I access or change N characters of a string? | May 21, 2006, 9:03 pm |
| FAQ 4.27 How can I access or change N characters of a string? | June 11, 2006, 9:03 am |
|