in reply to Perl array output sorting

I love to use glob for such an exercise:

use strict; use warnings; use File::Glob 'bsd_glob'; my @dbs = ("db1","db2"); my @commands =( "HPRMCLI exch create -s EXCHDAGNODE1", "HPRMCLI exch mount -h RMEBackupSvr", "HPRMCLI exch validate -level Log", "HPRMCLI exch unmount", "HPRMCLI exch remove", "HPRMCLI exch create -s EXCHDAGNODE2 -nc", "HPRMCLI exch mount -h RMEBackupSvr", "HPRMCLI exch validate -level Full", "HPRMCLI exch unmount", "HPRMCLI exch remove"); $"=","; my @cmds = bsd_glob "{@commands} -mdb {@dbs}"; print "$_\n" for @cmds;

Update: Of course -- as the Perl Puritans did point out -- the use of any special variable should be localized:

my @cmds = do { local $"=","; bsd_glob "{@commands} -mdb {@dbs}" };

Replies are listed 'Best First'.
Re^2: Perl array output sorting
by LanX (Saint) on Oct 31, 2013 at 20:32 UTC
    some Perl puritians wouldn't even use do

    DB<107> my @cmd; { local $"=','; @cmds = < "{@commands} - {@dbs}" > +} => ( "HPRMCLI exch create -s EXCHDAGNODE1 - db1", "HPRMCLI exch create -s EXCHDAGNODE1 - db2", "HPRMCLI exch mount -h RMEBackupSvr - db1", "HPRMCLI exch mount -h RMEBackupSvr - db2", "HPRMCLI exch validate -level Log - db1", ...

    update

    > the use of any special variable should be localized:

    not any just the ones potentially creating global damage ... =)

    Cheers Rolf

    ( addicted to the Perl Programming Language)