[ale] Perl Help split stopped working recently

Jerald Sheets questy at gmail.com
Fri Dec 2 08:19:46 EST 2022


I was just about to suggest encoding or non printable chars.

Sent from my iPhone

> On Dec 1, 2022, at 1:59 PM, DJPfulio--- via Ale <ale at ale.org> wrote:
> 
> Thanks!  So I'm not crazy. It should work!
> 
> For perl-5.33.8 and 5.30.x:
> 
> $ ./t.pl in.test
> Use of uninitialized value $stop_time in concatenation (.) or string at ./t.pl line 17, <> line 1.
> Line:   5:00 AM - 6:00 AM Live
>          5:00 AM - 6:00 AM Live,
> Use of uninitialized value $stop_time in concatenation (.) or string at ./t.pl line 17, <> line 2.
> Line:   6:00 AM - 7:00 AM New
>          6:00 AM - 7:00 AM New,
> 
> 
> Note how the output with 2 parameters shows the ',' at the end? That's because split() didn't do anything.  Initially, I thought a different '-' character was being provided. Nope. Nothing different there.
> 
> So, that got me thinking.  The input source changed the whitespace characters! Because I only email with 7-bit ASCII, nobody here saw that.
> 
> Thanks again.  I'll be replacing whitespace in the input lines to ASCII now. That should prevent any likely issues. Hopefully.
> 
> 
>> On 12/1/22 12:57, Leam Hall via Ale wrote:
>> Here's what I got From Perl 5.32.1:
>> ./for_dj.pl < dj.file
>> Line: 5:00 AM - 6:00 AM Live
>>       5:00 AM, 6:00 AM Live
>> Line: 6:00 AM - 7:00 AM New
>>       6:00 AM, 7:00 AM New
>> From (hand typed):
>> #!/usr/bin/env perl
>> use strict;
>> use warnings;
>> use utf8;
>> my $start_time = "";
>> my $stop_time = "";
>> while (<>){
>>     chomp;
>>     my $line = $_;
>>     ($start_time, $stop_time ) = split( / - /, $line, 2 );
>>     print "Line: $line\n \t $start_time, $stop_time \n";
>> }
>>> On 12/1/22 11:11, DJPfulio--- via Ale wrote:
>>> 
>>> I have this complete, simple, perl program ...
>>> 
>>> ==
>>> #!/usr/bin/env perl
>>> use strict;
>>> use warnings;
>>> use utf8;
>>> 
>>> my $start_time = "";
>>> my $stop_time = "";
>>> 
>>> while (<>){
>>>   chomp;
>>>   my $line = $_;
>>> 
>>>    ( $start_time, $stop_time ) = split( / - /, $line, 2);
>>> 
>>>     print "Line: $line\n \t $start_time, $stop_time\n";
>>> }
>>> ==
>>> 
>>> And I feed it this input file:
>>> 
>>> ==
>>>    5:00 AM - 6:00 AM Live
>>>    6:00 AM - 7:00 AM New
>>> ==
>>> 
>>> This pattern for split is something I've used for over 25 yrs and 2 weeks ago, it was working as expected.  Today, it doesn't work.  The $stop_time isn't being set.  split() ain't workin'.  The $start_time ends up with a copy of the line.
>>> 
>>> Tried with perl v5.30 and v5.33 on 2 different systems. Same results.
>>> 
>>> I expect the start to be "  5:00 AM" and the stop to be "6:00 AM Live" for the first input after the split().
>>> 
>>> Any ideas?  I'm assuming it is something dumb, but for something this simple, I'm just missing it.
>>> _______________________________________________
>>> Ale mailing list
>>> Ale at ale.org
>>> https://mail.ale.org/mailman/listinfo/ale
>>> See JOBS, ANNOUNCE and SCHOOLS lists at
>>> http://mail.ale.org/mailman/listinfo
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> https://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo


More information about the Ale mailing list