For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > November 2007 > How to set a global on the command line?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to set a global on the command line?
kj

2007-11-25, 7:09 pm



I often use Johan Vromans' handy script mp3cat, which I downloaded
from CPAN. I invoke it like this, for example:

% mp3cat --output=all.mp3 /some/dir/*.mp3

mp3cat works great most of the time, but lately it has been giving
me problems. I've traced these problems to the value of a certain
global variable, $MPEG::Audio::Frame::free_bitrate. This variable
is undef by default, and mp3cat leaves it unchanged. I discovered
(by running mp3cat in the debugger) that the problems I mentioned
would disappear if I set this variable to the correct bitrate (which
I know).

The only problem now is that mp3cat offers no way to specify a
value for this variable. I could hack mp3cat to add this functionality,
but I wondered, is there was a less "invasive" way to specify the
value of a global variable, e.g. on the command line?

TIA!

kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Big and Blue

2007-11-25, 7:09 pm

kj wrote:
....

> The only problem now is that mp3cat offers no way to specify a
> value for this variable. I could hack mp3cat to add this functionality,
> but I wondered, is there was a less "invasive" way to specify the
> value of a global variable, e.g. on the command line?


Write your own init.pm module which sets it, then run

perl -Minit /path/to/mp3cat --output=all.mp3 /some/dir/*.mp3


--
Just because I've written it doesn't mean that
either you or I have to believe it.
Glenn Jackman

2007-11-26, 4:13 am

At 2007-11-25 09:51AM, "kj" wrote:
> % mp3cat --output=all.mp3 /some/dir/*.mp3
>
> mp3cat works great most of the time, but lately it has been giving
> me problems. I've traced these problems to the value of a certain
> global variable, $MPEG::Audio::Frame::free_bitrate. This variable
> is undef by default, and mp3cat leaves it unchanged. I discovered

[...]
> but I wondered, is there was a less "invasive" way to specify the
> value of a global variable, e.g. on the command line?


untested: create a wrapper script

#!/usr/bin/perl --
$MPEG::Audio::Frame::free_bitrate = 'whatever';
do '/path/to/mp3cat';
__END__

Invoke as: mp3catwrapper.pl --output=...

--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com