use strict; opendir(DIR, "./") or die $!; # open current directory my @files; while (my $file = readdir(DIR)) { # Use a regular expression to ignore files beginning with a period push(@files, lc($file)); } closedir(DIR); # read the prompt. my $promptfile = shift; print STDERR "reading $promptfile\n"; open(PROMPT, $promptfile); my $i = 0; while (my $prompt = <PROMPT>) { $i++; print STDERR $prompt . "\n"; $prompt =~ s/^\d+\.\s//; # remove "93. "; $prompt = lc($prompt); # concat a list of .wav files corresponding to the prompt my $files = ""; foreach my $word (split(/\s+/, $prompt)) { # choose a random file from the files, that beings with the gi +ven $word. my @grepped = grep(/^$word/, @files); my $file = $grepped[ int(rand(scalar @grepped)) ]; # choose a +random file $files .= $file . " "; } my $output = sprintf("S%05d",$i); my $command = "sox $files $output.wav"; print STDERR $command . "\n"; # TODO: add system call. system($command); print STDOUT "$output.wav $output.mfc\n"; } close(PROMPT);

AFTER RUN THIS I GOT

Use of uninitialized value $file in concatenation (.) or string at scr +ipts/conca tprompt.pl line 29, <PROMPT> line 100. sox S00100.wav sox FAIL sox: Not enough input filenames specified

AND COMMAND IS LIKE:

perl -w scripts/concatprompt.pl trainprompts > codetrain.scp

PLEASE TELL ME HOW TO REMOVE THIS ERROR...


In reply to Use of uninitialized value $file in concatenation by Anonymous Monk

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.