[22592] in Perl-Users-Digest
Perl-Users Digest, Issue: 4813 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 4 00:06:42 2003
Date: Thu, 3 Apr 2003 21:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 3 Apr 2003 Volume: 10 Number: 4813
Today's topics:
$PROGRAM_NAME <none@none.com>
Bless equivalent in PHP? <umop@psyon.org>
Re: Bless equivalent in PHP? <goldbb2@earthlink.net>
Re: Bless equivalent in PHP? <kkeller-spammmm@wombat.san-francisco.ca.us>
Re: cpan <goldbb2@earthlink.net>
Re: cpan <45673&5@yahoo.co.uk>
Re: cpan <jurgenex@hotmail.com>
Crypt::OpenPGP <cb@sebaw.com>
Help with this <mail@annuna.com>
Re: Help with this <goldbb2@earthlink.net>
How to use other modules in SOAP's server module? (Hubert)
line sorting question <dmanjunath@yahoo.com>
Re: line sorting question <mbudash@sonic.net>
modifying a line with user input <tony.wong@sbcglobal.net>
Re: modifying a line with user input <goldbb2@earthlink.net>
Need to build a "sheduler" (Timer) - advice please... <anthony@no_spam.invalid>
Re: Nevermind!!! <mail@annuna.com>
Re: new Perl feature request: call into shared libs <jcoffin@taeus.com>
Problems with perlembed under Linux (xs_init and boot_S <topper@virginia.edu>
Re: sort numerically descending is not right? <bwalton@rochester.rr.com>
Re: sort numerically descending is not right? <none@none.com>
Re: sort numerically descending is not right? <mbudash@sonic.net>
Re: sort numerically descending is not right? <kalinabears@hdc.com.au>
Re: sort numerically descending is not right? <goldbb2@earthlink.net>
subroutine ref makes a script hang using strict <tunmaster@hotmail.com>
Re: subroutine ref makes a script hang using strict <skuo@mtwhitney.nsc.com>
Re: subroutine ref makes a script hang using strict <uri@stemsystems.com>
Re: system PROGRAM LIST syntax <grazz@nyc.rr.com>
Re: Text::ParseWords <bwalton@rochester.rr.com>
Re: Which is better - hashes or subroutines <goldbb2@earthlink.net>
Re: Win32::Sound::Volume() setting balance (Jay Tilton)
Wrong data <mail@annuna.com>
Re: Wrong data (Jay Tilton)
Re: Wrong data <bwalton@rochester.rr.com>
Re: Wrong data <skuo@mtwhitney.nsc.com>
Re: Wrong data <mail@annuna.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 3 Apr 2003 17:33:54 -0700
From: "Mark Holt" <none@none.com>
Subject: $PROGRAM_NAME
Message-Id: <b6ijrt$old$1@terabinaries.xmission.com>
I am having trouble with $0 (or $PROGRAM_NAME). In Perl 5.6.1, (RedHat
Linux 7.3) no problem, I can set $0 and ps reports the new name. Also, the
modified value appears in /proc/PID/cmdline.
BUT, in Perl 5.8.0 (RedHat Linux 8.0) this no longer works; ps reports the
same thing regardless of assignment to $0. Has anyone else noticed this? I
have scripts that depend on this behavior for reporting state.
At first I thought maybe it was just disabled for security purposes but then
I saw that sendmail is still reporting "sendmail: accepting connections"
which is definitely what I'm trying to do. So now I'm starting to believe
there is a bug in 5.8.0 which fails to set $0.
Is there a workaround? Is this actually a bug in Perl? What is the system
call that actually modifies the "cmdline" file?
Thanks,
Mark
------------------------------
Date: Thu, 3 Apr 2003 15:41:54 -0800
From: "Eric Arnold" <umop@psyon.org>
Subject: Bless equivalent in PHP?
Message-Id: <b6iguj$5drlu$1@ID-144898.news.dfncis.de>
does anybody know an equivalent to the 'bless' keyword to use in PHP (or any
other language, for that matter)?
Thanks
Eric
------------------------------
Date: Thu, 03 Apr 2003 20:25:58 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Bless equivalent in PHP?
Message-Id: <3E8CDF26.A638A4A3@earthlink.net>
Eric Arnold wrote:
>
> does anybody know an equivalent to the 'bless' keyword to use in PHP
> (or any other language, for that matter)?
For most OO languages, one cannot alter what class an object is a member
of (or, if you want to think of it another way, it isn't needed in most
languages). Consider C++ or Java -- the 'new' operator allocates the
appropriate amount of memory for you, then does whatever "default"
initialization is necessary (In C++, this means calling the constructors
for whatever object fields are classes; in Java, it's setting number
fields to zero and object fields to null), and then your constructor
gets called.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Thu, 3 Apr 2003 17:44:56 -0800
From: Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us>
Subject: Re: Bless equivalent in PHP?
Message-Id: <o2oi6b.uqq.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In article <b6iguj$5drlu$1@ID-144898.news.dfncis.de>, Eric Arnold wrote:
> does anybody know an equivalent to the 'bless' keyword to use in PHP (or any
> other language, for that matter)?
Perhaps people in a PHP group are more likely to know the answer
to this question.
- --keith
- --
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
public key: http://wombat.san-francisco.ca.us/kkeller/kkeller.asc
alt.os.linux.slackware FAQ: http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj6M45cACgkQhVcNCxZ5ID+MxACgirRl6RkUNOIKVieo0dqPhyOB
mRMAnjB2PqRzsrYz/T5hlT1k5LzLY2YB
=UuX5
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 03 Apr 2003 19:57:58 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: cpan
Message-Id: <3E8CD896.46A0A17A@earthlink.net>
Ian wrote:
> Anno Siegel wrote:
> > Ian wrote:
> > > Hi,
> > > I'm very new to this. I'm configuring cpan
> > > with "o conf init" and I'm getting asked some
> > > questions that I find awkward to answer.
> > > What do you guys use for unzip? Gzip I have and
> > > winzip is not command line.
> >
> > If it shows a default, accept the default.
[snip]
> > > for a nearby continent?
> >
> > The continent you're on.
[snip]
> It did not accept America canada quebec or anything
> else I typed
Those are countries, not continents.
Try "north america", "south america", "europe", "asia", "africa". You
can also enter "central america" or "oceana", which aren't technically
continents.
If you are in antarctica, then you're out of luck. :)
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Thu, 03 Apr 2003 22:44:34 -0500
From: L D Jones <45673&5@yahoo.co.uk>
Subject: Re: cpan
Message-Id: <3E8CFFA2.FB97F972@yahoo.co.uk>
Ian wrote:
>
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
[...]
> > If you answer the "continent" question, it will give you a list of
> > servers to select from.
> It did not accept America canada quebec or anything else I typed
because those are not continents?
------------------------------
Date: Fri, 04 Apr 2003 04:15:15 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: cpan
Message-Id: <nF7ja.609$Yb.28@nwrddc03.gnilink.net>
L D Jones wrote:
> Ian wrote:
>> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> [...]
>>> If you answer the "continent" question, it will give you a list of
>>> servers to select from.
>> It did not accept America canada quebec or anything else I typed
>
> because those are not continents?
America is not a continent? Interesting.
On the other hand, if the USA is the world already, then America must be the
universe. So I guess you are right after all.
jue
------------------------------
Date: Thu, 03 Apr 2003 23:08:53 GMT
From: ChineseBob <cb@sebaw.com>
Subject: Crypt::OpenPGP
Message-Id: <9a3ja.3920783$TJ.546640@post-02.news.easynews.com>
To All,
I am trying to encrypt files and then put them someplace else. But
after using Crypt::OpenPGP to encrypt them, the files are just sitting
in memory as a text and I can't seem to push them to a file. If I put
in print $ciphertext they appear in the log.txt file as the encrypted
text. I need them in their own separate file to be moved around and so on.
Does anyone have any ideas?
See Code:
sub process_dir{
my $directory = shift;
my @file = &open_directory($directory);
for my $processing(@file){
my $file= &encrypt_file($processing);
my $encrypted_output = "$dir/$processing"; #$dir is a global declared
at the top
open OUT, "> $encrypted_output" || die "can't $!";
select OUT;
print $file;
rename("$dir/$file", "$dir/$file.pgp");
}
}
sub encrypt_file{
my $file = shift;
my $pgp = Crypt::OpenPGP->new;
my $ciphertext = $pgp-encrypt(
Filename => $file,
Recipient => $key_id,
Armour => 1,
);
return($ciphertext);
------------------------------
Date: Thu, 03 Apr 2003 21:50:00 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Help with this
Message-Id: <3E8D00E8.1040802@annuna.com>
Why do I get an @grid needs an explicit package name here
sub move {
my ($mi, $play, $grid) = @_;
my $xm = $play->{x};
my $ym = $play->{y};
my %mov = ( n => [ 0, -1], s => [ 0, 1], e => [1, 0], w => [-1,
0], q => [0, 0]);
$xm = $xm + $mov{$mi}[0];
$ym = $ym + $mov{$mi}[1];
if ($xm > $#$grid)
{$xm=0;}
if ($xm < 0)
{$xm=$#$grid;}
if ($ym > $#{$grid[$xm]}) <-------**********
{$ym=0;}
if ($ym < 0)
{$ym=$#{$grid[$xm]};} <----*********
$play->{x} = $xm;
$play->{y} = $ym;
return $mi, $play;
}
($in1, $player[$in] ) = move($in1, $player[$in],\@grd);
@grd = 2d array (simulated)
------------------------------
Date: Fri, 04 Apr 2003 00:15:38 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help with this
Message-Id: <3E8D14FA.88BBD816@earthlink.net>
Joe Creaney wrote:
>
> Why do I get an @grid needs an explicit package name here
>
> sub move {
> my ($mi, $play, $grid) = @_;
> my $xm = $play->{x};
> my $ym = $play->{y};
> my %mov = ( n => [ 0, -1], s => [ 0, 1],
> e => [1, 0], w => [-1, 0], q => [0, 0]);
> $xm = $xm + $mov{$mi}[0];
> $ym = $ym + $mov{$mi}[1];
> if ($xm > $#$grid)
> {$xm=0;}
> if ($xm < 0)
> {$xm=$#$grid;}
> if ($ym > $#{$grid[$xm]}) <-------**********
Because $grid[$xm] is accessing the $xm'th element of @grid, not the
$xm'th element of @$grid. You want either $$grid[$xm] or $grid->[$xm].
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: 3 Apr 2003 20:56:11 -0800
From: hubert_xu@yahoo.com (Hubert)
Subject: How to use other modules in SOAP's server module?
Message-Id: <8e423c1d.0304032056.59b7d8b2@posting.google.com>
I have soap server code like this,
$daemon = SOAP::Transport::HTTP::Daemon
-> new (LocalAddr => localhost, LocalPort => 8080, Reuse => 1)
-> dispatch_to('EXAMPLE');
print "Contact SOAP server at ", $daemon->url, "\n";
$daemon->handle;
and the 'EXAMPLE' package like this,
package EXAMPLE;
use bar;
sub foo {
...
my $b = bar->new;
...
}
I found I just cannot use "use bar;" and "bar->new;", otherwise the
client cannot get correct result.
Just wondering why this happen and how can I fix this?
Thanks in advance,
Hubert
------------------------------
Date: Thu, 03 Apr 2003 23:25:31 GMT
From: "manj dodda" <dmanjunath@yahoo.com>
Subject: line sorting question
Message-Id: <Lp3ja.814$rA3.805@newssvr16.news.prodigy.com>
I have a list of lines like
VADA tmp4 final temp2
BAT tmp1 error missing
ADA tmp2 missing error
AAA temp2 tmp1 tmp2
............
It is in a array as
@myArray
$myArray[0] = "VADA tmp4 final temp2" ;
$myArray[1] = "BAT tmp1 error missing" ;
$myArray[2] =
Now i want to sort the array based on the first element of the
line.
What i want is finally
$myArray[0] = "AAA temp2 tmp1 tmp2" ;
$myArray[1] = "ADA tmp2 missing error" ;
$myArray[2] = "BAT tmp1 error missing" ;
How is this done ?.
Thanks in advance for your help
md
------------------------------
Date: Fri, 04 Apr 2003 02:57:41 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: line sorting question
Message-Id: <mbudash-304FDE.18573903042003@typhoon.sonic.net>
In article <Lp3ja.814$rA3.805@newssvr16.news.prodigy.com>,
"manj dodda" <dmanjunath@yahoo.com> wrote:
> I have a list of lines like
>
> VADA tmp4 final temp2
> BAT tmp1 error missing
> ADA tmp2 missing error
> AAA temp2 tmp1 tmp2
> ............
>
> It is in a array as
> @myArray
> $myArray[0] = "VADA tmp4 final temp2" ;
> $myArray[1] = "BAT tmp1 error missing" ;
> $myArray[2] =
>
> Now i want to sort the array based on the first element of the
> line.
> What i want is finally
> $myArray[0] = "AAA temp2 tmp1 tmp2" ;
> $myArray[1] = "ADA tmp2 missing error" ;
> $myArray[2] = "BAT tmp1 error missing" ;
>
> How is this done ?.
>
> Thanks in advance for your help
>
> md
>
>
one way:
@sorted_array = sort { (split /\s+/, $a)[0] cmp (split /\s+/, $b)[0] }
@array;
hth-
--
Michael Budash
------------------------------
Date: Fri, 04 Apr 2003 04:31:19 GMT
From: "Tony" <tony.wong@sbcglobal.net>
Subject: modifying a line with user input
Message-Id: <rU7ja.1772$kd1.1724694@newssrv26.news.prodigy.com>
I have a text file I need to replace 3 variables with what a user input in.
The only thing is I only need the variables in line 2 and 3 of the text file
modified.
for example::
Line 2 Server = "hostname";
Line 3: JavaUrl =
"jdbc:mysql://"+Server+"domain.com:3306/test?user=yyyy&password=xxxxxxx";
The 3 variables in this case is
1. hostname
2. user
3. password
So I only want line 2 and 3 modified and no other occurences below these
lines modified.
How would I do this in perl?
------------------------------
Date: Fri, 04 Apr 2003 00:12:54 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: modifying a line with user input
Message-Id: <3E8D1456.10A66200@earthlink.net>
Tony wrote:
>
> I have a text file I need to replace 3 variables with what a user input
> in.
>
> The only thing is I only need the variables in line 2 and 3 of the text
> file modified.
>
> for example::
>
> Line 2 Server = "hostname";
>
> Line 3: JavaUrl =
> "jdbc:mysql://"+Server+"domain.com:3306/test?user=yyyy&password=xxxxxxx";
>
> The 3 variables in this case is
>
> 1. hostname
>
> 2. user
>
> 3. password
>
> So I only want line 2 and 3 modified and no other occurences below
> these lines modified.
>
> How would I do this in perl?
You could do it as a command from the unix shell:
perl -wpli.bak \
-e 'next unless 2..3;' \
-e 's/\bdomain.com\b/otherdomain.com/g;' \
-e 's/\byyyy\b/zzzzz/g; s/\bxxxxxxxx\b/wwwwwwwww/g;'
Or, write a program which does it:
#!/usr/bin/perl -wpli.bak
use strict; use warnings;
next unless 2..3; # only change lines 2..3
s/\bhostname\b/newhostname/g; # change domain
s/\byyyy\b/zzzzz/g; # change user
s/\bxxxxxxxx\b/wwwwwwwww/g; # change password
__END__
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 04 Apr 2003 11:10:27 +1000
From: "Tony" <anthony@no_spam.invalid>
Subject: Need to build a "sheduler" (Timer) - advice please...
Message-Id: <pan.2003.04.04.01.10.25.412632@no_spam.invalid>
Hi there,
I am a bit "green" with Perl and would like some advice.
I wish to have a perl program which will do the following:
1. Read in a time schedule from a file.
2. The time schedule runs to a 7 day "plan"
based on the day of the week rather than
on a specific date. This is specified in the file.
Events and times may be the same for each
week day but could be different for some or all
days of the week.
A maximum of 24 events would be needed
per 24 hour period with each event being able
to control up to 10 different "ports" or output
events.
3. An event could be switching on a light or telling
an application to play a file to one of up to 10
audio/video devices (In this case it will be used
to schedule playing to a multimedia device.).
3. When playing a file to an A/V device the program
must also be able to read a selection of files listed
in a seperate file or generate a list of available
files by reading files placed in a specific directory.
EXAMPLE:
Tuesday: 10:30 Play <file_no1> to device no. 2
and send title of <file_no1> to an on screen
display (File name or name read in fom a file
containing the names of the file or titles)
10:30 Play file_no3 to device no 1
and send title....(Repeat as above)
Wednesday: 14:45 Play <file_no3> to an....
(Same as above)
Now I am not asking any one to do this for me (Not for
free anyway) but I would like to know if it is possible
without to much trouble while learning a bit about
Perl in the process.
Looking at the perl modules on CPAN it would seem that there
are several programs that can be used to find the day of the
week based on the date - so far so good.
There are also modules to read directory content to get a list of
files in a directory.
Even getting the timer schedules read in should not be hard.
Where I have got "stuck" is in how to aproach the "event"
scheduling. Are there modules for that sort of
task? (I have not found any)
It is also unclear to me what type of structure should
be used in the schedule file. I think a basic coma delimited
row by column approach would seem a good idea (Like a
spread sheet). This will also enable a relatively easy
way of building a web page to enter the events
and output "channels" of the events
I hope this is not to big a "mouthful" to ask here.
Please let me know if this is an appropriate task for Perl - people
are telling me it is a "piece of cake" but being "green" makes
it a bit harder to know if this is the right path.
Thanks in advance
Tony
PS. I posted this in the "modules" news group - maybe it
was inappropriate there...
--
--------------------------------------------------------------
To reply directly send to: anthony AT movielink DOT net DOT au
Replace AT and DOT with @ and . and mail will get through.
Any spammers will be persued until they get booted off the net
------------------------------
Date: Thu, 03 Apr 2003 21:54:39 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Re: Nevermind!!!
Message-Id: <3E8D01FF.2090705@annuna.com>
I figured it out I just needed and extra $ in those places. Amazing
what comes to me right after I post this message.
Joe Creaney wrote:
> Why do I get an @grid needs an explicit package name here
>
> sub move {
> my ($mi, $play, $grid) = @_;
> my $xm = $play->{x};
> my $ym = $play->{y};
> my %mov = ( n => [ 0, -1], s => [ 0, 1], e => [1, 0], w => [-1,
> 0], q => [0, 0]);
> $xm = $xm + $mov{$mi}[0];
> $ym = $ym + $mov{$mi}[1];
> if ($xm > $#$grid)
> {$xm=0;}
> if ($xm < 0)
> {$xm=$#$grid;}
> if ($ym > $#{$grid[$xm]}) <-------**********
> {$ym=0;}
> if ($ym < 0)
> {$ym=$#{$grid[$xm]};} <----*********
>
> $play->{x} = $xm;
> $play->{y} = $ym;
>
> return $mi, $play;
>
>
>
> }
>
> ($in1, $player[$in] ) = move($in1, $player[$in],\@grd);
>
> @grd = 2d array (simulated)
>
------------------------------
Date: Fri, 04 Apr 2003 03:07:53 GMT
From: Jerry Coffin <jcoffin@taeus.com>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <MPG.18f6a5d9d4bbf1809898e1@news>
In article <b5dibh$2ju4$1@agate.berkeley.edu>, nospam-abuse@ilyaz.org
says...
[ ... ]
> Given that no useful program can be written in limits of ANSI-C, I
> hardly see why this is relevent to the discussion at hand.
I'd go along with the statement that useful programs can't be written in
"strictly conforming" C. At the opposite extreme, merely "conforming" C
has a sufficiently loose definition that almost anything qualifies
(including most FORTRAN programs, for one example).
--
Later,
Jerry.
The universe is a figment of its own imagination.
------------------------------
Date: Thu, 03 Apr 2003 20:09:56 -0500
From: David Topper <topper@virginia.edu>
Subject: Problems with perlembed under Linux (xs_init and boot_Socket issues)
Message-Id: <3E8CDB64.9060505@virginia.edu>
Hi folks,
I'm trying to use Perl as a parser for my app. So far, I have the
basics down. I am able to send a buffer via C++ class method
"perlparse(char *)" but am running into some trouble:
1. I get an error about the module I'm trying to load. It's
proprietary, but works fine. I have a command line based app which also
uses Perl to parse input. It also uses this module. In any case,
here's the error:
Can't locate loadable object for module RT in @INC (@INC ...
I do have the RT.pm module in the right place. Note that the above
error is different from:
Can't locate RT.pm in @INC ...
which is what it would say if it couldn't find RT.pm. The problem seems
to be with loading. So I've read through "man perlembed" and am trying
to make sure I'm doing things right. Here's my basic perl parser, taken
pretty much out of the docs:
int perl_parse_buf (char *inBuf) {
STRLEN n_a;
char *embedding[] = { "", "-e", "" };
my_perl = perl_alloc();
perl_construct( my_perl );
perl_parse(my_perl, xs_init, 3, embedding, NULL);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_run(my_perl);
eval_pv(inBuf, TRUE);
perl_destruct(my_perl);
perl_free(my_perl);
return 0;
}
but my xs_init was originally just this:
xs_init()
{
char *file = __FILE__;
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
}
The docs say I should add:
newXS("Socket::bootstrap", boot_Socket, file);
but when I do, I get an error at compile time:
/musr/src/RTcmix/Minc/pimbRTcmix.o(.text+0x1f03): In function `xs_init':
/home/topper/RTcmix/Minc/parse_with_perl.c:29: undefined reference
to `boot_Socket'
collect2: ld returned 1 exit status
make: *** [plink] Error 1
and I am in fact using the linking syntax: `perl -MExtUtils::Embed -e
ldopts` So there's something screwy. Why can't ld fine boot_Socket? I
suspect I need it given previous errors.
Any input would be most appreciated.
Thanks,
Dave Topper
--
Technical Director - Virginia Center for Computer Music
http://www.virginia.edu/music/vccm.html
------------------------------
Date: Fri, 04 Apr 2003 00:36:18 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: sort numerically descending is not right?
Message-Id: <3E8CD36C.3090308@rochester.rr.com>
Bing Du Test wrote:
> Script is like this:
>
> =======
> #!/usr/local/bin/perl
>
> @terms =
> ('2003V','20033','20032','20031','20023','2004A','2003B','2003C','2002V','2002C');
>
> foreach $term (sort {$b <=> $a} @terms)
> {
> push @terms_in_order, $term;
> }
>
> print "terms_in_order are ",join(',',@terms_in_order),"\n";
> ======
>
> The result is:
>
> =======
> terms_in_order are
> 20033,20032,20031,20023,2004A,2003B,2003C,2003V,2002C,2002V
> =======
>
> But what I expect should be:
>
> ======
> terms_in_order are
> 2004A,2003V,2003C,2003B,20033,20032,20031,2002V,2002C,20023
> ======
>
> Can anybody tell me why @terms is not sorted? Is it because some
> elements have alphabetic characters?
Well, they *are* sorted they way you told Perl to sort them:
numerically. It would appear that you want an alphanumeric sort. You
get that using the cmp operator, not the <=> operator. Also, your
program is way way too complicated. Try:
@terms_in_order=sort{$b cmp $a}@terms;
in place of your foreach loop.
...
> Bing
--
Bob Walton
------------------------------
Date: Thu, 3 Apr 2003 17:39:27 -0700
From: "Mark Holt" <none@none.com>
Subject: Re: sort numerically descending is not right?
Message-Id: <b6ik6a$ork$1@terabinaries.xmission.com>
the "spaceship" operator is for numbers only. If you take out all the
letters in your scalars, you will see that this is indeed sorting properly.
To sort lexicographically rather than numerically, change $b <=> $a to $b
cmp $a. "cmp" is the string equivalent of "<=>"
Mark
"Bing Du Test" <bing-du@tamu.edu> wrote in message
news:3E8CB43E.F2D7C2A3@tamu.edu...
> Script is like this:
>
> =======
> #!/usr/local/bin/perl
>
> @terms =
>
('2003V','20033','20032','20031','20023','2004A','2003B','2003C','2002V','20
02C');
>
> foreach $term (sort {$b <=> $a} @terms)
> {
> push @terms_in_order, $term;
> }
>
> print "terms_in_order are ",join(',',@terms_in_order),"\n";
> ======
>
> The result is:
>
> =======
> terms_in_order are
> 20033,20032,20031,20023,2004A,2003B,2003C,2003V,2002C,2002V
> =======
>
> But what I expect should be:
>
> ======
> terms_in_order are
> 2004A,2003V,2003C,2003B,20033,20032,20031,2002V,2002C,20023
> ======
>
> Can anybody tell me why @terms is not sorted? Is it because some
> elements have alphabetic characters?
>
> Thanks for any help.
>
>
> Bing
>
------------------------------
Date: Fri, 04 Apr 2003 00:42:45 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: sort numerically descending is not right?
Message-Id: <mbudash-9ED3EC.16424403042003@typhoon.sonic.net>
In article <3E8CB43E.F2D7C2A3@tamu.edu>,
Bing Du Test <bing-du@tamu.edu> wrote:
> Script is like this:
>
> =======
> #!/usr/local/bin/perl
>
> @terms =
> ('2003V','20033','20032','20031','20023','2004A','2003B','2003C','2002V','2002
> C');
>
> foreach $term (sort {$b <=> $a} @terms)
> {
> push @terms_in_order, $term;
> }
>
> print "terms_in_order are ",join(',',@terms_in_order),"\n";
> ======
>
> The result is:
>
> =======
> terms_in_order are
> 20033,20032,20031,20023,2004A,2003B,2003C,2003V,2002C,2002V
> =======
>
> But what I expect should be:
>
> ======
> terms_in_order are
> 2004A,2003V,2003C,2003B,20033,20032,20031,2002V,2002C,20023
> ======
>
> Can anybody tell me why @terms is not sorted? Is it because some
> elements have alphabetic characters?
>
> Thanks for any help.
>
>
> Bing
>
@terms_in_order = sort {$b cmp $a} @terms;
'<=>' is for numbers.
hth
--
Michael Budash
------------------------------
Date: Fri, 4 Apr 2003 10:45:22 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: sort numerically descending is not right?
Message-Id: <3e8cd68d$0$20138@echo-01.iinet.net.au>
"Bing Du Test" <bing-du@tamu.edu> wrote in message
news:3E8CB43E.F2D7C2A3@tamu.edu...
> Script is like this:
>
> =======
> #!/usr/local/bin/perl
>
> @terms =
>
('2003V','20033','20032','20031','20023','2004A','2003B','2003C','2002V','20
02C');
>
> foreach $term (sort {$b <=> $a} @terms)
> {
> push @terms_in_order, $term;
> }
>
> print "terms_in_order are ",join(',',@terms_in_order),"\n";
> ======
>
> The result is:
>
> =======
> terms_in_order are
> 20033,20032,20031,20023,2004A,2003B,2003C,2003V,2002C,2002V
> =======
>
> But what I expect should be:
>
> ======
> terms_in_order are
> 2004A,2003V,2003C,2003B,20033,20032,20031,2002V,2002C,20023
> ======
>
> Can anybody tell me why @terms is not sorted? Is it because some
> elements have alphabetic characters?
>
Yes, you've asked for a "numeric" sort, and some of those elements are not
numbers - of which you would have been informed, had you enabled warnings.
Instead of '$b <=> $a', try '$b cmp $a'.
Cheers,
Rob
------------------------------
Date: Thu, 03 Apr 2003 20:18:37 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: sort numerically descending is not right?
Message-Id: <3E8CDD6D.9BABC657@earthlink.net>
Bing Du Test wrote:
>
> Script is like this:
>
> =======
> #!/usr/local/bin/perl
use strict;
use warnings;
> @terms =
> ('2003V','20033','20032','20031','20023','2004A','2003B','2003C','2002V','2002C');
my @terms = qw(2003V 20033 20032 20031
20023 2004A 2003B 2003C 2002V 2002C);
> foreach $term (sort {$b <=> $a} @terms)
> {
> push @terms_in_order, $term;
> }
my @terms_in_order = sort @terms;
> print "terms_in_order are ",join(',',@terms_in_order),"\n";
> ======
>
> The result is:
>
> =======
> terms_in_order are
> 20033,20032,20031,20023,2004A,2003B,2003C,2003V,2002C,2002V
> =======
Looks right, for a numeric sort.
> But what I expect should be:
>
> ======
> terms_in_order are
> 2004A,2003V,2003C,2003B,20033,20032,20031,2002V,2002C,20023
> ======
When you asked perl to sort with {$b <=> $a}, this means put the
numerically largest items first, ignoring any non-numeric parts
afterwards. Why in the world would 2003 (the number part of "2003B" be
considered numerically larger than 20033?
> Can anybody tell me why @terms is not sorted? Is it because some
> elements have alphabetic characters?
They *are* sorted, but not in the way that you expected them to be.
Maybe what you want is:
my @terms_in_order = map $_->[0], sort {
$a->[1] <=> $b->[1] or $a->[2] cmp $b->[2];
} map [$_, /^(\d*)(.)\z/s], @terms;
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 04 Apr 2003 01:45:04 GMT
From: "joe" <tunmaster@hotmail.com>
Subject: subroutine ref makes a script hang using strict
Message-Id: <As5ja.1486221$Wr.55573575@Flipper>
Ok, I've got slightly stuck at the following piece of code, using 'strict'.
$::action = param('a');
$::action = ($::action =~ /^(\w*)$/) ? $1:"";
if (defined &$::action) {&$::action}
else {&printPage}
The var 'action' gets the value from a form field and is untainted right
away. A moment later the script checks whether there is a subroutine with
the same name as $::action. If so, I want it to run that sub. That's it! It
works fine without using 'strict'. Using 'strict' I get an error message
that it can't use my string as a subroutine ref while 'strict' is in use.
Didn't I untaint my var well enough?
I found out that the code below does pull it off, but doesn't any risk come
with it's use? Does this influence the called subroutines? Isn't there a way
to do this without turning 'strict' partially off?
{
no strict 'refs';
if (defined &$::action) {&$::action}
else {&printPage}
}
I hope someone can help me out here, thanks a lot in advance...!
Joe
------------------------------
Date: Thu, 3 Apr 2003 18:43:20 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: subroutine ref makes a script hang using strict
Message-Id: <Pine.GSO.4.21.0304031839070.2416-100000@mtwhitney.nsc.com>
On Fri, 4 Apr 2003, joe wrote:
> Ok, I've got slightly stuck at the following piece of code, using 'strict'.
>
> $::action = param('a');
> $::action = ($::action =~ /^(\w*)$/) ? $1:"";
>
> if (defined &$::action) {&$::action}
> else {&printPage}
>
> The var 'action' gets the value from a form field and is untainted right
> away. A moment later the script checks whether there is a subroutine with
> the same name as $::action. If so, I want it to run that sub. That's it! It
> works fine without using 'strict'. Using 'strict' I get an error message
> that it can't use my string as a subroutine ref while 'strict' is in use.
> Didn't I untaint my var well enough?
>
> I found out that the code below does pull it off, but doesn't any risk come
> with it's use? Does this influence the called subroutines? Isn't there a way
> to do this without turning 'strict' partially off?
>
> {
> no strict 'refs';
> if (defined &$::action) {&$::action}
> else {&printPage}
> }
>
> I hope someone can help me out here, thanks a lot in advance...!
>
> Joe
>
Well, then don't use symbolic references. Use a dispatch table
instead:
#! /usr/local/bin/perl -T
use strict;
use warnings;
my %code_ref = (
foo => \&foo,
bar => \&bar,
);
my $action = param('a');
if ($action =~ /^(\w*)$/) {
$action = $1;
} else {
$action = ''; # default;
}
if (exists $code_ref{$action}) {
$code_ref{$action}->();
} else {
warn "No valid action to take";
}
sub foo {
print "FOO\n";
}
sub bar {
print "BAR\n";
}
--
Hope this helps,
Steven
------------------------------
Date: Fri, 04 Apr 2003 03:07:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: subroutine ref makes a script hang using strict
Message-Id: <x7u1dfdkpd.fsf@mail.sysarch.com>
>>>>> "j" == joe <tunmaster@hotmail.com> writes:
j> Ok, I've got slightly stuck at the following piece of code, using 'strict'.
j> $::action = param('a');
j> $::action = ($::action =~ /^(\w*)$/) ? $1:"";
j> if (defined &$::action) {&$::action}
that is using symrefs and that is bad. regardless of all the other
reasons not to use symrefs, that code allows a cgi script to call any
sub in your script.
use a dispatch table. search google for many discussions of them in this
group.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Thu, 03 Apr 2003 23:15:31 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: system PROGRAM LIST syntax
Message-Id: <ng3ja.5333$an1.2995@twister.nyc.rr.com>
Steven Kuo <skuo@mtwhitney.nsc.com> wrote:
>
> In line 12 below, I'm issuing a system call
s/issuing.*/calling system()/
> with an indirect object in front of the argument list.
The system() syntax is fine, but
1) even though you can exec a #! script with the "wrong"
name in argv[0], the interpreter is invoked with *its*
name in argv[0] and the path to the script after any
shebang line arguments. (And for obvious reasons, the
path to the script needs be correct this time.)
2) perl sets $0 to the script's name (or "-" or "-e")
--
Steve
------------------------------
Date: Fri, 04 Apr 2003 03:26:05 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Text::ParseWords
Message-Id: <3E8CFB35.308@rochester.rr.com>
Robert Brooks wrote:
> In article <3E8B9266.5020205@rochester.rr.com>
> Bob Walton <bwalton@rochester.rr.com> wrote:
>
>> Robert Brooks wrote:
...
>>> my $string = ' alpha beta';
...
> I dismissed out-of-hand, and refused to believe,
> that anyone would write a parser that returns
> an empty value. Another example of TMTOWTDI
...
Well, the reason Text::ParseWords returned an empty value was because
your text started with a delimiter (whitespace). The word before the
delimiter was, well, empty. Perhaps it is hard to believe anyone would
give a parser text which starts with a delimiter?
--
Bob Walton
------------------------------
Date: Thu, 03 Apr 2003 20:04:58 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Which is better - hashes or subroutines
Message-Id: <3E8CDA3A.40D6A9E9@earthlink.net>
"Tassilo v. Parseval" wrote:
[snip]
> sub AUTOLOAD {
> my ($self) = @_;
> (my $var = $AUTOLOAD) =~ s/^.+:://;
> return if $var eq 'DESTROY';
> if (exists $self->{$var}) {
> *$AUTOLOAD = sub () { $self->{$var} };
ITYM:
*$AUTOLOAD = sub () { shift()->{$var} };
> goto &$AUTOLOAD;
> } else {
> die "Unknown word or phrase: $var\n";
> }
> }
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 04 Apr 2003 01:46:25 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Win32::Sound::Volume() setting balance
Message-Id: <3e8ce30c.598166@news.erols.com>
"Ian.H [dS]" <ian@WINDOZEdigiserv.net> wrote:
: #!d:\perl\bin\perl
: use strict;
: use warnings;
: use Win32::Sound;
: Win32::Sound::Volume(0xFFFF, 0xFFFF);
: Win32::Sound::Play("C:\\WINNT\\Media\\notify.wav");
: #Win32::Sound::Volume(0);
: Win32::Sound::Stop();
:
: This demo works, but it seems to set the balance to 100% left after
: playing the sound.
It's doing unpredictable things on me. Sometimes it sets balance 100%
left, other times not.
: Has anyone else encountered this issue and/or knows a way around it?
Not before today. :)
Something really squirrelly is going on. When I set this one-liner
going (line-wrapped for inconvenience),
perl -MWin32::Sound -e "$|=1;printf qq#left:%3d
right:%3d\r#,Win32::Sound::Volume() while 1"
then start twiddling volume/balance sliders, the numbers emitted just
don't jibe with reality. Why this happens I don't know, but at least
you're not the only one witnessing the misbehavior.
I was going to suggest saving the volume values, then restoring them
when you're done, e.g.
my($l, $r) = Win32::Sound::Volume;
Win32::Sound::Volume(0xFFFF, 0xFFFF);
Win32::Sound::Play("C:\\WINNT\\Media\\notify.wav");
Win32::Sound::Volume($l, $r);
Win32::Sound::Stop();
but even that does not work reliably.
------------------------------
Date: Thu, 03 Apr 2003 18:10:19 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Wrong data
Message-Id: <3E8CCD6B.6070905@annuna.com>
In basic they had a statment like this
enter 1-10:
input a
if a > < 10 then basck to enter 1-10
is there an effecient way of doing this in perl?
------------------------------
Date: Fri, 04 Apr 2003 01:56:41 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Wrong data
Message-Id: <3e8ce465.943027@news.erols.com>
Joe Creaney <mail@annuna.com> wrote:
: In basic they had a statment like this
: enter 1-10:
: input a
: if a > < 10 then basck to enter 1-10
: is there an effecient way of doing this in perl?
What is your metric for efficiency?
my $a;
{
print "Enter 1-10:";
redo unless ($a=<STDIN>) >=1 && $a <=10;
}
print "You entered $a";
------------------------------
Date: Fri, 04 Apr 2003 03:09:10 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Wrong data
Message-Id: <3E8CF73E.1040208@rochester.rr.com>
Joe Creaney wrote:
> In basic they had a statment like this
> enter 1-10:
> input a
> if a > < 10 then basck to enter 1-10
> is there an effecient way of doing this in perl?
>
while(1){
chomp($a=<>);
last if $a>=1 and $a<=10;
}
--
Bob Walton
------------------------------
Date: Thu, 3 Apr 2003 19:17:44 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Wrong data
Message-Id: <Pine.GSO.4.21.0304031914550.5666-100000@mtwhitney.nsc.com>
On Thu, 3 Apr 2003, Joe Creaney wrote:
> In basic they had a statment like this
> enter 1-10:
> input a
> if a > < 10 then basck to enter 1-10
> is there an effecient way of doing this in perl?
>
Sorry, I don't know BASIC; but I suspect that you want something
like:
my $a;
do {
print "enter 1-10:\n";
$a = <STDIN>;
} until ($a =~ /^\d+$/ && $a <= 10 && $a >= 1);
I threw in the regular expression match to prevent non-numeric
comparisons.
--
Hope this helps,
Steven
--
"kuo is also set to release around 10% shares it owns to
reduce its stake to 18"
http://www.googlism.com/index.htm?ism=kuo&type=1
------------------------------
Date: Thu, 03 Apr 2003 21:43:32 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Re: Wrong data
Message-Id: <3E8CFF64.60108@annuna.com>
Wow I didn't know that I must have missed that simple statment in my
studdies.
Thanks!
Jay Tilton wrote:
> Joe Creaney <mail@annuna.com> wrote:
>
> : In basic they had a statment like this
> : enter 1-10:
> : input a
> : if a > < 10 then basck to enter 1-10
> : is there an effecient way of doing this in perl?
>
> What is your metric for efficiency?
>
> my $a;
> {
> print "Enter 1-10:";
> redo unless ($a=<STDIN>) >=1 && $a <=10;
> }
> print "You entered $a";
>
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4813
***************************************