Hey There! I'm quite a newbie with Perl and i'm stuck with subroutines and arrays.
#!/usr/bin/perl use strict; use warnings; use Getopt::Std; my $cimzett; my $domain; my $date; my @data; getopts ('m:d:s:'); use vars qw ($opt_m $opt_d $opt_s); $date=$opt_d; $domain=$opt_s; sub csv { open(BEJOVO, ">>bejovo.csv"); open(KIMENO, ">>kimeno.csv"); while (my $in = @data) { my @mails = readlog($in); #CSV fejlec # print BEJOVO ";BEJOVO LEVELEK;\n"; # print BEJOVO "Idopont;Felado;Cimzett\n"; # print KIMENO ";KIMENO LEVELEK;\n"; # print KIMENO "Idopont;Felado;Cimzett\n"; #fajlba iras if ( $mails[9] =~ /$domain/i ) { print KIMENO "$mails[2];$mails[9];$mai +ls[11]\n"; } elsif ( $mails[9] =~ /@/ ) { print BEJOVO "$mails[2];$mails[9];$mai +ls[11]\n"; } if ( $mails[8] =~ /$domain/i ) { print KIMENO "$mails[2];$mails[8];$mai +ls[10]\n"; } elsif ( $mails[8] =~ /@/ ) { print BEJOVO "$mails[2];$mails[8];$mai +ls[10]\n"; } #csv fajlok e-mail mellekletkent [cimzett]-nek #mpack program kell hozza! # system("mpack -s kimeno-`date -I` kimeno.csv $cimzett"); # system("mpack -s bejovo-`date -I` bejovo.csv $cimzett"); # system('rm bejovo.csv'); # system('rm kimeno.csv'); } close(KIMENO); close(BEJOVO); } sub readlog { my $line = $_[0]; chomp($line); my @mails; my $key = "<"; my $key2 = ">"; #Naplofajlok beolvasasa #amavis bejegyzesek kinyerese if ( $line =~ /amavis/ ) { #szokozonkent szetvalasztas es tombbe illesztes @mails = split ('$line'); #csak a kivalasztott napot vegye figyelembe if ( $mails[1] == $date ) { #"><" karakterek levagasa if ( $mails[9] =~ /@/ ) { $mails[9] =~ s/$key//g; $mails[9] =~ s/$key2//g; $mails[11] =~ s/$key//g; $mails[11] =~ s/$key2//g; } else { $mails[8] =~ s/$key//g; $mails[8] =~ s/$key2//g; $mails[10] =~ s/$key//g; $mails[10] =~ s/$key2//g; } } } return @mails; } while (<>) { push @data, $_; } if ( $opt_m eq "csv" ) { csv; }
The script is just half functional but useable. I think the passing of arrays between the subroutines aren't wokring properly. Thank You for your help!

In reply to passing arrays by ScOut3R

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.