squimby has asked for the wisdom of the Perl Monks concerning the following question:
I don't mean 'fix it' in general, as I'm sure there are plenty of people with that request. Specifically I'm looking for help with the interpreter becoming upset with $userhash{$currow[0]}{$domain[$i]} = 1;, and $userhash{$currow[0]}{$domain[$i]} = "undef"; and I'm getting the warning 'requires explicit package name', though that should be within the scope of that variable's declaration, right? Thoughts? Advice? Rants?
#!/usr/bin/perl use strict; use warnings; print "What is the name of the access rights .csv? (Full file name)\n" +; my $file = <>; print "Is there a header in this file?\n"; my $header = <>; if ($header =~ m/^yes|^y]/i){ $header = "1"; } else {$header = "undef"; } print "What file format are your messages in?\n"; my $format = <>; open (CSV, "<", $file); my (@emailList, @domain, %userHash); while (my $currow = <CSV>){ if ($header || $currow =~ m/^email|^e-mail/i){ @domain = split (',', $currow); shift @domain; $header = "undef"; } if($currow =~ m/[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\. +[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3}))$/){ for my $i (0..$#domain){ my @currow = split (',', $currow); if ($currow[$i+1]) { $userhash{$currow[0]}{$domain[$i]} = 1; } else{ $userhash{$currow[0]}{$domain[$i]} = "undef"; } push (@emailList, $currow[0]); } } else{ print STDERR "This email address isn't properly formatted! $!\ +n" } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Fix-it fix-it fix-it!
by davido (Cardinal) on Nov 14, 2012 at 19:41 UTC | |
by squimby (Acolyte) on Nov 14, 2012 at 19:43 UTC | |
by davido (Cardinal) on Nov 14, 2012 at 19:45 UTC | |
by squimby (Acolyte) on Nov 14, 2012 at 19:56 UTC | |
by AnomalousMonk (Archbishop) on Nov 15, 2012 at 01:26 UTC | |
Re: Fix-it fix-it fix-it!
by jwkrahn (Abbot) on Nov 15, 2012 at 04:52 UTC | |
by Tux (Canon) on Nov 15, 2012 at 07:08 UTC | |
Re: Fix-it fix-it fix-it!
by jmlynesjr (Deacon) on Nov 14, 2012 at 20:52 UTC | |
Re: Fix-it fix-it fix-it!
by sundialsvc4 (Abbot) on Nov 14, 2012 at 22:30 UTC | |
by Anonymous Monk on Nov 14, 2012 at 23:43 UTC |
Back to
Seekers of Perl Wisdom