Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

neilwatson's scratchpad

by neilwatson (Priest)
on Jun 01, 2004 at 20:19 UTC ( #358525=scratchpad: print w/replies, xml ) Need Help??

I encourage wisdom seekers to present sample data and use Test::More in the example code of their question. Let's look at some examples.

How do I make the regex match?

#!/usr/bin/perl use strict; use warnings; use Test::More; my $data = "Some string here"; my $regex = qr/ fancy regex here /mxis; like( $data, $regex, "Matching my regex" ); done_testing;

Your code fails, but readers can read this code and run it and make changes that will make it pass.

Why does my sub return an error?

#!/usr/bin/perl use strict; use warnings; use Test::More; sub mysub { return; } ok( mysub(), "Should return true" ); done_testing;

Presenting Larger sample data as if you were reading a file line by line.

Use __DATA__.

#!/usr/bin/perl use strict; use warnings; use Test::More; my $wanted_matches = 2; my $actual_matches = 0; my $regex = qr/ fancy regex here /mxis; while ( my $line = <DATA> ) { chomp $line; if ( $line =~ $regex ){ $actual_matches++; } } ok( $wanted_matches == $actual_matches, "Correct number of matches" ); done_testing; __DATA__ line one..... line two..... .... line ten.....
Log In?

What's my password?
Create A New User
[Spenser]: yes, I have mysql client libs installed.
[choroba]: You can also try DBD::MariaDB instead of MySQL
[choroba]: it's not on CPAN yet, unfortunately, so you have to install manually from github
[Spenser]: Thanks. I tried DBD::MariaDB just now. It can't find that module.
[Spenser]: oh, I'll check github

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2018-03-17 12:56 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (224 votes). Check out past polls.