[ale] Perl Help split stopped working recently
Leam Hall
leamhall at gmail.com
Thu Dec 1 12:57:08 EST 2022
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
--
Automation Engineer (reuel.net/resume)
Scribe: The Domici War (domiciwar.net)
General Ne'er-do-well (github.com/LeamHall)
More information about the Ale
mailing list