Re: boxquote [was: bcm43xx wireless with static ip]

2007-07-07 Thread Felix C. Stegerman
* Felix C. Stegerman [EMAIL PROTECTED] [2007-07-06 17:41]:
 * Felix C. Stegerman [EMAIL PROTECTED] [2007-07-06 11:36]:
  * William Xu [EMAIL PROTECTED] [2007-07-06 07:39]:
   Felix C. Stegerman [EMAIL PROTECTED] writes:
  
But I was wondering how you made the above print.  Is there
some handy utility to pretty-print files like that?  Or did
you [have to] do it by hand?
  
   Of course not by hand, ;-)
  
   The answer: GNU Emacs + boxquote.el
 
  To bad I'm a vim user ;-)
 
  I guess I'll just whip up a perl script then.  Thanks for the info
  though.

 $ echo '... and so I did ;-)' | boxquote
 ,[ (standard input) ]
 | ... and so I did ;-)
 `

And I've even added something:

$ boxquote -c 'fortune -s perl'
,[ fortune -s perl | ]
| It's easy to solve the halting problem with a shotgun.   :-)
| -- Larry Wall in [EMAIL PROTECTED]
`


- Felix

-- 
Felix C. Stegerman [EMAIL PROTECTED]  http://obfusk.net
~ Any sufficiently advanced bug is indistinguishable from a feature.
~   -- R. Kulawiec
~ vim: set ft=mail tw=70 sw=2 sts=2 et:


signature.asc
Description: Digital signature


Re: boxquote [was: bcm43xx wireless with static ip]

2007-07-07 Thread Elimar Riesebieter
On Sat, 07 Jul 2007 the mental interface of
Felix C. Stegerman told:

 * Felix C. Stegerman [EMAIL PROTECTED] [2007-07-06 17:41]:
[...]
 And I've even added something:
 
 $ boxquote -c 'fortune -s perl'
 ,[ fortune -s perl | ]
 | It's easy to solve the halting problem with a shotgun.   :-)
 | -- Larry Wall in [EMAIL PROTECTED]
 `

And what is the output of

$ cat boxqoute | boxqoute

?


-- 
  Excellent day for drinking heavily. 
  Spike the office water cooler;-)


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: boxquote [was: bcm43xx wireless with static ip]

2007-07-07 Thread Felix C. Stegerman
* Elimar Riesebieter [EMAIL PROTECTED] [2007-07-07 18:36]:
 On Sat, 07 Jul 2007 the mental interface of
 Felix C. Stegerman told:

  * Felix C. Stegerman [EMAIL PROTECTED] [2007-07-06 17:41]:
 [...]
  And I've even added something:
 
  $ boxquote -c 'fortune -s perl'
  ,[ fortune -s perl | ]
  | It's easy to solve the halting problem with a shotgun.   :-)
  | -- Larry Wall in [EMAIL PROTECTED]
  `

 And what is the output of

 $ cat boxqoute | boxqoute

 ?

$ boxquote -c 'wc -l $(which boxquote)'
,[ wc -l $(which boxquote) | ]
| 290 /usr/local/bin/boxquote
`

Since it's 290 lines, I've chosen not to paste, but instead to attach
it.


- Felix

-- 
Felix C. Stegerman [EMAIL PROTECTED]  http://obfusk.net
~ Any sufficiently advanced bug is indistinguishable from a feature.
~   -- R. Kulawiec
~ vim: set ft=mail tw=70 sw=2 sts=2 et:
#!/usr/bin/perl

# 
#
# boxquote - quote text with a semi-box [based on boxquote.el]
#
# 
#
# Felix C. Stegerman [EMAIL PROTECTED]
# 2007-07-06 [22:47]
#
# 
#
# Copyright (C) 2007  Felix C. Stegerman
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA
#
# 

our $VERSION = '2007-07-06 [22:47]';

# 

use strict;
use warnings;

# 

use Getopt::Long;
use Pod::Usage;

# 

my $prog  = 'boxquote';
my %opts  = (
  'bottom-corner' = '`',
  'command'   = [],
  'hide-title'= 0,
  'label' = '(standard input)',
  'side'  = '| ',
  'title-format'  = '[ %s ]',
  'top-and-tail'  = '',
  'top-corner'= ',',
);

# 

Getopt::Long::Configure ('auto_version');

GetOptions (
  \%opts, 'help|h|?', 'man', 'bottom-corner|bc=s', 'command|c=s',
  'hide-title|ht!', 'label|l=s', 'side|s=s', 'title-format|tf=s',
  'top-and-tail|tt=s', 'top-corner|tc=s',
) or pod2usage (2);

$opts{'help'} and pod2usage (1);
$opts{'man'}  and pod2usage ('-verbose' = 2);

# 

sub print_top ($) # top text
{
  my $file  = shift;  # file name

  my $label = $file eq '-' ? $opts{'label'} : $file;

  print   $opts{'top-corner'};
  print   $opts{'top-and-tail'};
  printf  $opts{'title-format'}, $label unless $opts{'hide-title'};
  print   \n;
}

sub print_side () # side text
{
  print   $opts{'side'};
}

sub print_bottom ()   # bottom text
{
  print   $opts{'bottom-corner'};
  print   $opts{'top-and-tail'};
  print   \n;
}

sub process ($$)  # process file[handle]
{
  my $HANDLE  = shift;
  my $title   = shift;

  print_top ($title);

  while ($HANDLE)
{
  print_side; print $_;
}

  print_bottom;
}

# 

my @commands  = @{$opts{'command'}};
my @files = @ARGV ? @ARGV :
@commands ? (   ) :
('-') ;
my $FILE  = undef;

# 

foreach my $cmd (@commands)
  {
open ($FILE, '-|', $cmd)
  or die Could not open pipe from `$cmd': $!;

process ($FILE, $cmd |);

close $FILE;
  }

# 

foreach my $file (@files)
  {
$file eq '-' ? open ($FILE, '-') : open ($FILE, '', $file)
  or die Could not open `$file': $!;

process ($FILE, $file);

close $FILE;
  }

# 

# vim: set ft=perl tw=70 sw=2 sts=2 et:

__END__

=begin comment

  boxquote.pod

  Felix C. Stegerman [EMAIL PROTECTED]
  2007-07-07 [15:18]

=end comment

=head1 NAME

boxquote - quote text with a semi-box

=head1 SYNOPSIS

Bboxquote [Ioptions] [Ifile(s)]

=head1 DESCRIPTION

The Bboxquote Cperl(1) script does more or less what
Bboxquote.el [on which it is based] does [for Cemacs(1)].

From the description