[23398] in Perl-Users-Digest
Perl-Users Digest, Issue: 5616 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 4 21:07:29 2003
Date: Sat, 4 Oct 2003 18:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 4 Oct 2003 Volume: 10 Number: 5616
Today's topics:
A couple of matching questions. (AGoodGuyGoneBad)
Re: A couple of matching questions. (Tad McClellan)
Re: A couple of matching questions. <zoooz@gmx.de>
Re: CGI: redirect some value to the previous URL <spam@thecouch.homeip.net>
Re: fastest count of instances in string? <skweek@no.spam>
Re: fastest count of instances in string? (Tad McClellan)
Re: outputting raw data to a file <spam@thecouch.homeip.net>
PerlQt question <zoooz@gmx.de>
Re: Unexpected alteration of array's content (Roy Johnson)
using PAR (pp) for executables (The Mosquito ScriptKiddiot)
Re: using PAR (pp) for executables astewart1@cox.net
Re: using PAR (pp) for executables (The Mosquito ScriptKiddiot)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 04 Oct 2003 23:02:04 GMT
From: agoodguygonebad@aol.com (AGoodGuyGoneBad)
Subject: A couple of matching questions.
Message-Id: <20031004190204.15275.00000173@mb-m23.aol.com>
2 questions
Q1. I have a string of characters like
$string="aaagggcebbb";
"cfbbcaaacee"
"ebccaaaggge"
I need to pass this string to a sub, and return true if
the characters (repeating or not) are in order.
That is, if a character occurs anywhere other than beside itself,
the string fails.
In the 3 strings above, T,F for c,F for e.
If true, I need 2 other strings, the characters in the order they appear
and the a string of the times they appear.
ie "aaagggcmbbb" true "agcmb" "33113" or maybe "3,3,1,1,3" since I'm not sure
yet if a character will appear more than 9 times.
Q2. I have a string of characters where some repeat and some don't,
and an array of characters. The string is only made up of characters
from the array.
I need to match the string, at the begining, with
a string of repeating characters from the array greater than 4,
or a string of non repeating characters within the array,
or a string of reversed non repeating characters within the array.
I know I can find any repeat with =m/^(.)\1{4,}/;
and $+ contains what character it found, and length($&) is how many, (I think).
How can I find if there is a match in the forward or reverse strings?
short examples
ie for @array like @array=('a','b','c','d','g');
$forward=join('',@array);
$reverse=join('', sort {$b <=> $a} @array);
$string="dcbabbaddcg" reverse match found dcba
"gcbabbadcg" reverse match not found, d did not follow g.
"bcdgaaaaaaaa" forward match found for bcdg
I've been trying to use matches, and tring to avoid
long loops using substrings.
Steve
tia
------------------------------
Date: Sat, 4 Oct 2003 18:53:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: A couple of matching questions.
Message-Id: <slrnbnunck.52v.tadmc@magna.augustmail.com>
AGoodGuyGoneBad <agoodguygonebad@aol.com> wrote:
> Q1. I have a string of characters like
>
> $string="aaagggcebbb";
> "cfbbcaaacee"
> "ebccaaaggge"
>
> I need to pass this string to a sub, and return true if
> the characters (repeating or not) are in order.
> That is, if a character occurs anywhere other than beside itself,
> the string fails.
> In the 3 strings above, T,F for c,F for e.
> If true, I need 2 other strings, the characters in the order they appear
> and the a string of the times they appear.
>
> ie "aaagggcmbbb" true "agcmb" "33113" or maybe "3,3,1,1,3" since I'm not sure
> yet if a character will appear more than 9 times.
-----------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
foreach my $string ( qw/ aaagggcebbb cfbbcaaacee ebccaaaggge aaagggcmbbb/ ) {
my($letters, $count) = str_check( $string );
if ( $count )
{ print "$string is valid $letters: $count\n" }
else
{ print "$string is invalid due to '$letters'\n" }
}
sub str_check {
my($str) = @_;
my @series;
push @series, length $1 while $str =~ /((\w)\2*)/g;
$str =~ tr/a-z//s;
my %seen;
foreach my $letter ( split //, $str) {
return $letter, 0 if $seen{$letter}++;
}
return $str, join ',', @series;
}
-----------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 05 Oct 2003 02:38:27 +0200
From: Amir Kadic <zoooz@gmx.de>
Subject: Re: A couple of matching questions.
Message-Id: <blnpi5$ej9u0$1@ID-142982.news.uni-berlin.de>
AGoodGuyGoneBad wrote:
> Q1.
Here is another attempt returning a hash ref.
---------------------------------------------------
sub doIt {
my $a= shift;
for(0..length($a)-1){
$b=substr($a,$_,1);
$counts{$b}++;
$singlechars.=$b unless $singlechars=~ /$b/;
}
$ok=1;
foreach $c (keys %counts) {
($ok=0 && last) if ($a=~/$c[^$c]+$c/);
}
return {ok => $ok, singlechars => $singlechars, counts => \%counts};
}
---------------------------------------------------
------------------------------
Date: Sat, 04 Oct 2003 18:41:55 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: CGI: redirect some value to the previous URL
Message-Id: <T0Ifb.61275$1M6.1219027@wagner.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Wenjie wrote:
> Hello,
>
>
> I add an upload file feature to a BBS using perl. The
> difficult thing is how I manage to integrate the upload
> and message posting: the BBS is written using CGI.pm but
> the posting code block is mainly HTML and javascripts
> with perl variables, so my standalone upload.pl won't
> work. Now I provided the URL of upload.pl for the user
> to use the uploading function. But the user have to
> copy and paste the uploaded file name and 'back' to
> previous page. My question is: could I use some trick
> to redirect the upload.pl result to the previous page
> automatically
It's the same technique that any normal CGI uses to re-direct really. It's irrelevant that
upload.pl is receiving file contents and saving it into a file vs. normally receiving key=value
pairs and parsing them in memory.
You can output an HTTP "Location:" re-direct tag, or output text/html containing meta-refresh or
javascript re-direct code.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE/f0y1eS99pGMif6wRApJ6AJ4x1LaUSV5xD+sbDzPKwP4aeTt1PwCg/ptU
O/rq9IudFEfwIDvnPAVTwC4=
=R7FF
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 05 Oct 2003 00:08:31 +0200
From: AlV <skweek@no.spam>
Subject: Re: fastest count of instances in string?
Message-Id: <blngd0$kmq$1@news-reader3.wanadoo.fr>
John W. Krahn wrote:
> Roy Johnson wrote:
>
>>In much the same way that
>> "$stupid"
>>is the same as
>> $stupid
>
>
> It is?
>
> $ perl -le'
> $stupid = \55;
> print "<", $stupid + 0, "> <", "$stupid" + 0, ">";
> $stupid = [ 1,2,3 ];
> print "<", @{$stupid}, "> <", @{"$stupid"}, ">";
> '
> <135267140> <0>
> <123> <>
Eh, eh, eh, nice shots! :oD
But, I am not sure that bill (the person who posted the first question
of this thread) is using Perl anymore...
He most certainly is hard at work learning Java or Python or
WhateverLanguageThatIsNotPerl while mumbling about "a bunch of irascible
loonies" ;o)
This last remark is not for you, as you certainly understood, John :o)
Have a nice day,
------------------------------
Date: Sat, 4 Oct 2003 18:55:28 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: fastest count of instances in string?
Message-Id: <slrnbnunfg.52v.tadmc@magna.augustmail.com>
Roy Johnson <rjohnson@shell.com> wrote:
> In much the same way that
> "$stupid"
> is the same as
> $stupid
But they are not the same!
perldoc -q vars
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 04 Oct 2003 18:36:51 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: outputting raw data to a file
Message-Id: <8YHfb.61151$1M6.1217056@wagner.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
The Mosquito ScriptKiddiot wrote:
> hey,
>
> i need to output raw data to a file without perl first converting it to a
> string...for example, when i try the following:
>
> open(SES,">filename");
> $x=43;
> print SES $x;
>
> perl converts $x to the string '43' then stores that string (2 ascii byte
> values) into the file...how can i make it so that instead it just stores 43 as
> the first byte of the file?...ie, i want the first byte of the file to have a
> value of 43 (and each byte of the file to have a unique value that i'll be
> determining as well)
See perldoc -f pack
And especially in your simple 1-character case, see perldoc -f chr
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE/f0uGeS99pGMif6wRAt8+AKDVdO6XTvNaQ23Ix+zTBbOEiOHO3QCgyg00
if2Y5KZl/SOYzcZT3Jdw3uY=
=LA8k
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 05 Oct 2003 00:50:31 +0200
From: Amir Kadic <zoooz@gmx.de>
Subject: PerlQt question
Message-Id: <blnj78$e9es8$1@ID-142982.news.uni-berlin.de>
First off, I apologize if this isn't the best group for my
question...
I can't seem to make a proper Qt::Thread subclass.
Here is my attempt (which ends with:
Can't locate package Qt::Thread for @WannaBeAThread::ISA at
/usr/local/lib/perl/5.6.1/Qt/isa.pm line 45.
Segmentation fault
)
------------------------------------
package WannaBeAThread;
use strict;
use Qt;
use Qt::isa qw(Qt::Thread);
sub NEW {
shift->SUPER::NEW();
}
sub run {
1 for (0..4);
}
1;
package main;
use strict;
use WannaBeAThread;
my $ttt= WannaBeAThread;
$ttt->start();
-------------------------------------
Has anyone had more luck (or brains) ?
Amir
------------------------------
Date: 4 Oct 2003 15:05:05 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Unexpected alteration of array's content
Message-Id: <3ee08638.0310041405.34a8e888@posting.google.com>
Brian McCauley <nobull@mail.com> wrote in message news:<u9oewydvo3.fsf@wcl-l.bham.ac.uk>...
>
> No, map returns a _list_ not an _array_. It is quite possible for a
> function that returns a list to return a list of lvalues.
Alrighty, then. I don't see the importance of the distinction here,
but I'm quite certain you are correct.
> If I do:
>
> for my $line (grep 1, @lines){
>
> Then @lines _is_ still modified.
This was new to me.
> > I can tell you like code that makes people blink. :-)
>
> No I don't.
Then I'm sorry to inform you that the idiom you prefer is still going
to cause a WTF moment for the casual reader. At least with a simple
assignment, it is intuitively obvious that something is being copied.
> Not once you get used to it (I certainly blinked at the map example).
There is no reason for @{[@ar]} to become a familiar idiom. It doesn't
do anything that is often going to be necessary. It's not difficult to
decipher, but it still takes a blink.
> Yes I was going to post exactly this in answer to the OP and had even
> got as far as typing a follow-up but then decided it was too obvious
> to mention and I didn't hit send.
Unless there is a reason given that the obvious solution shouldn't be
used, it's generally a good idea to mention it. People will overlook
the darndest things, sometimes.
> Please see other current thread about why local $_ can do strange
> things.
I will do that, if I can find it.
------------------------------
Date: 04 Oct 2003 23:21:22 GMT
From: anotherway83@aol.comnospam (The Mosquito ScriptKiddiot)
Subject: using PAR (pp) for executables
Message-Id: <20031004192122.07925.00000280@mb-m11.aol.com>
hey,
i cant figure out how to get PAR to actually work for me (par.perl.org)...it
says there that i should use 'pp' to create executables from perl scripts, but
when i download the module (PAR-0.75.tar.gz) and extract it, i get 'pp' without
an extension (along with par.pl and parl.pod) in the folder called
'scripts'...i have tried switching to that directory using the ms-dos prompt on
win98, and doing what it says at
http://search.cpan.org/~autrijus/PAR-0.75/script/pp to get an executable:
pp -o output.exe input.pl
replacing (output.exe and input.pl with the appropriate arguments, of course)
but its not working...can ne1 pls. enlighten me
thanks
--The Mosquito Scriptkiddiot.
"I wish I was a glow worm
A glow worm's never glum
'Cos how can you be grumpy
When the sun shines out your bum!"
------------------------------
Date: Sat, 04 Oct 2003 17:04:19 -0700
From: astewart1@cox.net
Subject: Re: using PAR (pp) for executables
Message-Id: <7lnunvstk9ni4qatg6rcgei5h05hqjpvg7@4ax.com>
On 04 Oct 2003 23:21:22 GMT, anotherway83@aol.comnospam (The Mosquito
ScriptKiddiot) wrote:
>hey,
>
>i cant figure out how to get PAR to actually work for me (par.perl.org)...it
>says there that i should use 'pp' to create executables from perl scripts, but
>when i download the module (PAR-0.75.tar.gz) and extract it, i get 'pp' without
>an extension (along with par.pl and parl.pod) in the folder called
>'scripts'...i have tried switching to that directory using the ms-dos prompt on
>win98, and doing what it says at
>http://search.cpan.org/~autrijus/PAR-0.75/script/pp to get an executable:
>
>pp -o output.exe input.pl
>
>replacing (output.exe and input.pl with the appropriate arguments, of course)
>but its not working...can ne1 pls. enlighten me
>
>thanks
>
>
>--The Mosquito Scriptkiddiot.
>"I wish I was a glow worm
>A glow worm's never glum
>'Cos how can you be grumpy
>When the sun shines out your bum!"
>
>
If you have it extracted, read the instructions in the "readme" file.
You have to install it. Follow the "Installation" section and ""Notes
for Windows users". BTW, the "cpansign -v" step is not neccessary and
requires even more installation.
After the installation, you will have executables and batch files in
your Perl bin directory, in particular, pp.bat.
astewart
------------------------------
Date: 05 Oct 2003 00:18:08 GMT
From: anotherway83@aol.comnospam (The Mosquito ScriptKiddiot)
Subject: Re: using PAR (pp) for executables
Message-Id: <20031004201808.01183.00000189@mb-m29.aol.com>
thanks, but i think theres a problem with my installation...here is what it
shows when i type in perl makefile.pl:
*** ExtUtils::AutoInstall version 0.54
*** Checking for dependencies...
[Core Features]
- File::Temp ...loaded. (0.12)
- Compress::Zlib ...loaded. (1.16 >= 1.14)
- Archive::Zip ...failed! (needs 1)
- Module::ScanDeps ...failed! (needs 0.3)
- PAR::Dist ...failed! (needs 0.05)
==> Do you wish to install the 3 mandatory module(s)? [y] y
*** Dependencies will be installed the next time you type 'nmake'.
*** ExtUtils::AutoInstall configuration finished.
Writing Makefile for PAR
Warning: prerequisite Archive::Zip 1 not found at
C:/Perl/lib/ExtUtils/MakeMaker
.pm line 343.
Warning: prerequisite Module::ScanDeps failed to load: Can't locate
Module/ScanD
eps.pm in @INC (@INC contains: inc C:/Perl/lib C:/Perl/site/lib) at (eval 20)
li
ne 3.
Warning: prerequisite PAR::Dist failed to load: Can't locate PAR/Dist.pm in
@INC
(@INC contains: inc C:/Perl/lib C:/Perl/site/lib) at (eval 21) line 3.
Usage: xsubpp [-v] [-C++] [-except] [-prototypes] [-noversioncheck]
[-nolinenumb
ers] [-nooptimize] [-noinout] [-noargtypes] [-s pattern] [-typemap typemap]...
f
ile.xs
i think it has to do with those warnings...how do i fix it!!
thanks
--The Mosquito Scriptkiddiot.
"I wish I was a glow worm
A glow worm's never glum
'Cos how can you be grumpy
When the sun shines out your bum!"
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5616
***************************************