Skip to content

Instantly share code, notes, and snippets.

@kidd
Created November 7, 2009 14:32
Show Gist options
  • Save kidd/228718 to your computer and use it in GitHub Desktop.
Save kidd/228718 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my $l;
open my $fh, '<', shift || $0;
while(<$fh>){
$l = $_ if /say/;
};
print "$l\n";
my %h;
$h{goatse}=()= $l =~ /( )/g; #4. force list context and then, scalar context
($h{match}) = $l =~ /( )/g; #' '.list context but only assigning the first result
(@{$h{array}}) = $l =~ /( )/g; #[' ',' ',' ',' ']. list context
@{$h{array2}} = $l =~ /( )/g;#[' ',' ',' ',' ']. list context
$h{bool} = $l =~ /( )/g; #1. true / false
print Dumper \%h;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment