Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear all I apologize if I am going to ask a question that may be easy

I'm trying to read a list of file in a specific directory that are all done in this way: word-number.box When the script find the file it should go elsewhere launching a different program on each individual file found with this structure. My main issue is how to put in the variable $filename text and scalar together.

$filename=print($a,$x,$c) ;

This command is printing in the proper way but is not setting them in the $filename $a and $c are texts while $x is a number.

Here is the code:
#!/usr/bin/perl -w $job="eman-ctf.b"; for ($x=3 ; $x <=4 ; $x++){ $a='/sData/users/Musa/Necen/process/EspB-trunc/espbtrunc-imagi +c-ctf/3-img-no-ctf/box/et3f-' ; $c='.box'; $d=print($a,$x,$c) ; $filename = $d; print $d ; if (-e $filename) { print "File Exists!"; @_=($job,$x); system(@_) == 0 or warn "system @_ failed "; } }
Thank you in advance Max

Replies are listed 'Best First'.
Re: printing in a variable scalar and text togheter
by choroba (Cardinal) on Jul 31, 2012 at 18:45 UTC
    print prints its arguments, but returns 1 on success. That is what gets assigned to $d. You probably wanted
    my $filename = $a . $x . $c;
    or
    my $filename = "$a$x$c";
    or even
    my $filename = join '.', $a, $x, $c;
    Tweak to suit your needs.
Re: printing in a variable scalar and text togheter
by Anonymous Monk on Jul 31, 2012 at 18:43 UTC
    Sorry everybody I find the answer on the topic concatenating variables: http://www.perlmonks.org/?node_id=984630 It is just
    $d=$a.$x.$c
    Best Max