A simple perl script.

Maybe someone can improve it. :)

Code:
#! /usr/bin/env perl

################################################################################

use warnings;

use diagnostics;

################################################################################

@sys = qw
{
	textproc/docproj-nojadetex
	ports-mgmt/portmaster
};

@x = qw
{
	x11-drivers/xorg-drivers
};

@gnome = qw
{
	x11/gnome-applets
	audio/gnome-media
	deskutils/gnome-utils
	graphics/eog
	graphics/evince
	x11/gnome-terminal
	x11/gnome-session
	x11-fm/nautilus
	x11-themes/gnome-themes
	sysutils/gconf-editor
	sysutils/gnome-control-center
	x11/gdm
};

@net = qw
{
	ftp/gftp
	www/firefox36
	irc/irssi
	mail/mutt
	mail/fetchmail
	mail/procmail
	mail/msmtp
};

@multimedia = qw
{
	multimedia/mplayer
	multimedia/audacious-plugins
	multimedia/audacious

};

@dev = qw
{
	editors/vim
	devel/cscope/
	devel/cmake
	devel/llvm

};

@tex = qw
{
	print/teTeX-base
	print/latex-pgf

};

@math = qw
{
	math/octave
	math/R
	math/gnuplot
};

@others = qw
{
	databases/postgresql90-server
	security/gnupg
	security/pinentry-curses
	textproc/stardict3
};

################################################################################

@total = (@sys, @x, @gnome, @net, @multimedia, @dev, @tex, @math, @others);

$prefix = "/usr/ports/";

foreach $port (@total)
{
	system("cd $prefix$port; make showconfig");

}

################################################################################
 
Dont see any reason to write perl script for this.
But if you write, start with
Code:
use strict;
 
Sounds like something that can be done with a shell script too, or even a makefile. After all it is a list of programs to be installed...
 
@fender: I'd add that you are assigning lists of paths to various arrays, then assigning a list of arrays to another array, and then iterating through the final list to perform a single operation on each item.

IMO, it would be more succinct and more useful to keep the list of paths in a separate file (rather than hardcoding them in the script). All your perl(1) - or whatever - script would have to do is read the file and perform the operation on each line, a la:

Code:
#!/usr/bin/perl

use warnings ;
use strict ;

my $p_paths = 'foo.txt' ;

open my $IN, '<', $p_paths or die "Unable to open $p_paths: $!" ;

while (<$IN>) {

  # do something with $_

}
 
fluca1978 said:
Sounds like something that can be done with a shell script too, or even a makefile. After all it is a list of programs to be installed...

Or Ruby, or anything you like, really. But I haven't done a Makefile for a while, so here's a not-very-tested translation:
Code:
SYS=    textproc/docproj-nojadetex ports-mgmt/portmaster

X=      x11-drivers/xorg-drivers

GNOME=  x11/gnome-applets audio/gnome-media deskutils/gnome-utils \
        graphics/eog graphics/evince x11/gnome-terminal \
        x11/gnome-session x11-fm/nautilus x11-themes/gnome-themes \
        sysutils/gconf-editor sysutils/gnome-control-center \
        x11/gdm

NET=    ftp/gftp www/firefox36 irc/irssi mail/mutt mail/fetchmail \
        mail/procmail mail/msmtp

MULTIMEDIA=     multimedia/mplayer multimedia/audacious-plugins \
                multimedia/audacious

TEX=    print/teTeX-base print/latex-pgf

MATH=   math/octave math/R math/gnuplot

OTHERS= databases/postgresql90-server security/gnupg \
        security/pinentry-curses textproc/stardict3

TOTAL=  ${SYS} ${X} ${GNOME} ${NET} ${MULTIMEDIA} ${DEV} ${TEX} ${MATH} ${OTHERS}

all-config:
        @for PORT in ${TOTAL} ; do \
          cd "/usr/ports/$${PORT}" ;\
          make config ;\
        done
 
Back
Top