Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Blackslash confusion and newlines

by pimperator (Acolyte)
on May 31, 2014 at 00:20 UTC ( [id://1088083] : perlquestion . print w/replies, xml ) Need Help??

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

O' Perl Monks, I pray that you lend me your aid in my time of confusion. O' Perl Monks, help me see the error of my ways O' Perl Monks, why does this happen?

I'm writing a script that has to pass a command to the terminal using system(). My problem is that the filehandle looks something like this

$fileHand = "folder\012614ESA YADDA_(YADDA).txt"; print $fileHand."\n";
The output:
$ folder 614ESA YADDA_(YADDA).txt
What's going on here? Is "\012" a secret newline character? O Perl Monks, I bless you. My file names will be numeric as such, if I escape the backslash every time, do I run the risk of screwing something up?

Replies are listed 'Best First'.
Re: Blackslash confusion and newlines
by taint (Chaplain) on May 31, 2014 at 03:15 UTC
    Greetings, pimperator.

    The following is NOT intended to sound as bad as it will. :)

    Perl cheat-sheet

    #!/usr/bin/perl # I hate the cryptic words Perl usually chooses use Modern::Perl; use strict; # ALWAYS # Let Perl inform me if I might be doing something wrong use warnings; # I hate to read the fine Perl documentation # either I'm too lazy, or it makes my head spin # But I understand Perl will tell me what to do if I use diagnostics; # my code follows {...}


    λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

        Indeed it does (implement strictures). But was used for a different reason -- qw(say); | feature say;, in this case. Meaning it had "friendlier" names for print, and such. I might also add, it's a great shortcut for many other "features", as well. :)


        UPDATE I probably should have expressed it as:
        use Modern::Perl qw(say);

        λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

Re: Blackslash confusion and newlines
by Anonymous Monk on May 31, 2014 at 00:26 UTC

    That is not a "filehandle" that is a string

    Its because single quotes do not interpolate while double quotes do interpolate. perlintro and Modern Perl explain interpolation.

      If I used single quotes then I should not have this problem?