Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: string comparison

by tphyahoo (Vicar)
on May 27, 2005 at 10:02 UTC ( #461008=note: print w/replies, xml ) Need Help??


in reply to Re^2: string comparison
in thread string comparison

Extending this logic a bit, and using <DATA> to read in the test data:
use strict; use warnings; my ($first_line, $current_line); while (<DATA>) { chomp; # get rid of newline # get the first line sorted if ($. == 1) { $first_line = join ",", sort( split /,/,); } else { #die if doesn't match the first line sorted. $current_line = join ",", sort( split /,/,); die "$_ didn't match first line" unless $current_line eq $firs +t_line; } } __DATA__ ~cake,pastry,donuts,meringue pastry,~cake,meringue,donuts meringue, donuts,pastry,~cake,meringue
This dies on the third line, as it should.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2023-02-04 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?