Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

String interpolation

by hippo (Curate)
on May 16, 2014 at 16:17 UTC ( #1086351=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Deleting first and last lines of a text file
in thread Deleting first and last TWO(2) lines of a text file

Have a read about quoting to see why the variable isn't interpolated. Also, never say "it didn't work" as a bug report - that's pretty much content-free.


Comment on String interpolation
Re: String interpolation
by vsmeruga (Acolyte) on May 16, 2014 at 16:42 UTC

    Below is the code for test.pl and it printed the variable to a output file:test.txt. But it could not replace with the variable(${filedt} in file name)

    #!/usr/bin/perl use Time::Piece; use warnings; use strict; my $file='test.txt'; open STDOUT, ">", $file or die "$0: open: $!"; open STDERR, ">&STDOUT" or die "$0: dup: $!"; my $filedt = localtime->strftime('%Y%m%d'); print $filedt; #my $infile = '/home/vmeruga_alt/EXEC_${filedt}.txt';
Re: String interpolation
by vsmeruga (Acolyte) on May 16, 2014 at 16:49 UTC

    got it . Double quotes instead of single here . Thanks!!

    my $infile = "/home/vmeruga_alt/EXEC_${filedt}.txt";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2014-09-19 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (130 votes), past polls