Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

printing in a variable scalar and text togheter

by Anonymous Monk
on Jul 31, 2012 at 18:32 UTC ( #984642=perlquestion: print w/ replies, xml ) Need Help??
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

Comment on printing in a variable scalar and text togheter
Select or Download Code
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
Re: printing in a variable scalar and text togheter
by choroba (Prior) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://984642]
Approved by cavac
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2013-05-24 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (509 votes), past polls