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"
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|