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

hereto doc

by Anonymous Monk
on Jun 03, 2010 at 20:43 UTC ( #843001=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I want to use a HTD b/c its the best way I can think of for my small amount of code. I need to run a system image called an ignite on HPUX, but I also need to exclude many directories. Here is my code but my hereto doc (HTD) does not work. Any ideas?

#!/usr/bin/env perl use strict; use warnings; $ENV{PATH} = qq(/usr/bin:/bin:/usr/sbin:/sbin:/opt/ignite/bin); my $host = qx(/usr/bin/hostname); my $log = qq(/root/admin/logs/ignite/DR.log); my $svr = q/172.x.x.x/; ### Give me non-system mount point names ### my ($bdf,@excludes); for $bdf (qx|bdf|) { next if $bdf =~ /:?vg00/ || $bdf =~ /:?mounted/i; push @excludes, (split(" ", $bdf, 0))[5]; } my $string = <<`EOC`; -x exclude=$_ foreach (@excludes); EOC print $string; __DATA__ proper syntax is $ make_net_recovery -v -s "IP addr" -x inc_entire=vg00 \ -x exclude=/usrb -x exclude=/cache array contains /usrb /cache /journal . . .
thank you!

Comment on hereto doc
Download Code
Re: hereto doc
by almut (Canon) on Jun 03, 2010 at 20:56 UTC
    my $string = <<`EOC`; -x exclude=$_ foreach (@excludes); EOC

    Not really sure I understand, but maybe you want something like this (?)

    my @excludes = qw(/usrb /cache /journal); my $string = join " ", map "-x exclude=$_", @excludes; print $string; __END__ -x exclude=/usrb -x exclude=/cache -x exclude=/journal
Re: hereto doc
by choroba (Canon) on Jun 03, 2010 at 20:57 UTC
    You probably mean something like
    my $string = join " -x exclude=$_" ,q(),@excludes;
    You can use shell commands in back-quoted here doc, as in
    print <<`EOF`; ls cd / ls EOF

    Update: join used instead of for. Why do I always correct just a half of the problem? :)

Re: hereto doc
by Krambambuli (Deacon) on Jun 04, 2010 at 17:52 UTC
    If you're still concerned about the here-doc not working:

    it seems you're using backquotes instead of apostrophes, ` instead of ' or ", in

    my $string = <<`EOC`;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2015-07-02 22:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (46 votes), past polls