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"
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|