Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Cannot find the error

by jwkrahn (Abbot)
on Apr 03, 2020 at 20:51 UTC ( [id://11115009]=note: print w/replies, xml ) Need Help??


in reply to Cannot find the error

I have a script that is parsing through large text files

I rewrote it, assuming a text file.

#!/usr/bin/perl use warnings; use strict; my $file = <<FILE; t13:45 D13:45 S13:45 Unicorn D13:45 S13:45 T13:45 t13:45 D13:45 T13:46 t13:45 D13:45 S13:45 D13:45 S13:45 UNICORN T13:45 t13:45 D13:45 T13:46 FILE my $value = 'unicorn'; open my $FH, '<', \$file or die "Cannot open 'file' because: $!"; my $section = ''; while ( <$FH> ) { if ( /^t/ .. /^T/ ) { $section .= $_; } if ( /^T/ ) { print $section if $section =~ /$value/i; $section = ''; } }

Debug statements are left as an exercise for the OP.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11115009]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-25 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found