[23397] in Perl-Users-Digest
Perl-Users Digest, Issue: 5615 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 4 18:06:14 2003
Date: Sat, 4 Oct 2003 15:05:09 -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: 5615
Today's topics:
Re: Classic ASP HTML Templates like Perl's HTML::Templa <chris@FLARBLEinfinitemonkeys.org.uk>
Re: data varification code logic (Tad McClellan)
Re: data varification code logic <king21122@yahoo.com>
Re: fastest count of instances in string? (Roy Johnson)
Re: fastest count of instances in string? <krahnj@acm.org>
Re: javascript in HTML ... not running on some browsers (Gaurav)
Re: javascript in HTML ... not running on some browsers <hyweljenkins@hotmail.com>
Re: LWP:UserAgent not working ??? (Gaurav)
Re: LWP:UserAgent not working ??? <mbudash@sonic.net>
Re: LWP:UserAgent not working ??? (Bill)
Re: multiple SQL line query via Perl (Greg Bacon)
Re: Newbie Q - Nicer way to lc something? <perl@my-header.org>
Re: Newbie Q - Nicer way to lc something? <chris@FLARBLEinfinitemonkeys.org.uk>
outputting raw data to a file (The Mosquito ScriptKiddiot)
Re: outputting raw data to a file <sfandino@yahoo.com>
Re: outputting raw data to a file (The Mosquito ScriptKiddiot)
Re: outputting raw data to a file <invalid-email@rochester.rr.com>
test news silvia@onairos.com
Re: two regexs (Greg Bacon)
Re: Unexplained Multiple Lauches of Script with NetBack <jandk1@nospanners.comcast.net>
Re: waitpid and alarms (Greg Bacon)
Re: waitpid and alarms <News@SteveNoWayEast.com>
Re: WWW::Mechanize .. anyone? (Randal L. Schwartz)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 04 Oct 2003 18:29:03 +0100
From: Chris Smith <chris@FLARBLEinfinitemonkeys.org.uk>
Subject: Re: Classic ASP HTML Templates like Perl's HTML::Template?
Message-Id: <bln07g$p22$1$830fa79d@news.demon.co.uk>
C. Olive wrote:
> Sorry to ask for ASP help in a Perl group, but Perl people are the
> only ones that are going to know what in the world I'm talking about
> by way of Perl comparisions...
>
> I'm stuck doing development work in VBScript and ASP. Yuck.
> Previously I've always been able to do ASP work in PerlScript and so
> I've always been able to bring the power of Perl (and CPAN modules)
> into the ASP environment, but not at this gig.
>
> I'm sorely missing the power of HTML::Template (which I actually used
> in ASP/PerlScript). Do any of you Perl hackers out there that have
> been pressed into a similiar spot (eg. having to do ASP work) know of
> a free ASP templating system that works like Perl's HTML::Template?
> I'm desparate. It's twice the work in Classic ASP to use ASP as is
> not to mention having to code in VBScript (how do people stomach this
> stuff, I wonder?)... Hopefully some Perl person has crossed this
> bridge and knows what I'm talking about.
I've gone from ASP to Perl. You're screwed. Sorry.
There are precisely zero ASP templating systems that work properly.
--
Chris Smith
http://www.infinitemonkeys.org.uk/
------------------------------
Date: Sat, 4 Oct 2003 09:39:46 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: data varification code logic
Message-Id: <slrnbntmti.3kn.tadmc@magna.augustmail.com>
King <king21122@yahoo.com> wrote:
> my @col = map { (split)[0] } <DATA>; # untested
> this code will not work if it is in the same program with another
> statement which is also using the <DATA> .
Maybe, maybe not. We would need to see the actual code to tell (hint!).
> if I comment the first
> block(s) then it works. where do I find some reading about this if this
> is the correct behaviour, if not then what is going on?
I'm forced to guess at what is going on in the unseen code.
The input operator above ( <DATA> ) is in "list context"
(see "Context" section in perldata.pod).
The input operator in list context reads _all_ of the lines
from the filehandle, so you will be at end-of-file afterwards.
(see the named function corresponding to <>: perldoc -f readline)
BTW, the DATA filehandle is meant to be "meta" here, ie: you should
replace it with some other properly open()ed filehandle in your
real program.
Sounds like you are trying to use the same filehandle for 2 different
things. Can't you use 2 filehandles (and 2 files) for the 2 different
things?
> another point:
> since I need to write DATA to another file FH, should I make an array
> with those $seen{key} > 1 and then as I loop through the DATA check each
> key to see weather to write this line out or to ask for <STDIN> to
> choose which line to keep and ignore the rest of the duplicates? or
> someother logic is better to do this?
>
> notice I changed the __DATA__ below in-order to better reflect what I am
> trying to explain,
If you change the requirements, the code is likely to be different.
My earlier code is not very helpful given this new requirement.
You can avoid lots of similar round-and-round by getting the
requirements clear up-front.
Too many iterations and you'll end up using all of your coupons
before you get an answer that you can actually use...
> I am trying to get the code to show me the whole
> lines of DATA with the same keys and allow me to select which line to
> keep and disregard the rest. so according to the DATA it should say
> 1: one two1
> 2: one two2
> please select the line to keep:
> if <STDIN> = 2 then donot copy "one two1" to the new file and do next
^
^ you cannot assign to the input operator, should be == ?
We are still missing an essential requirement:
Can we be sure that the entire file will fit into memory?
The code (and algorithm) are likely to be very different
depending on the answer to that question.
I'll assume we can put the whole thing into memory.
The best data structure seems to me to be a HoL (Hash of Lists,
more accurately: a hash of references to arrays).
--------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper; # invaluable for debugging data structures
### load up the data structure
my %data; # HoL
while ( <DATA> ) {
my $key = (split)[0]; # or: my($key) = /^(\S*)/;
push @{ $data{$key} }, $_; # save lines associated with the key
}
#print Dumper \%data; # see what it is that we have built thus far
### make the output
my $outfile = 'tmp';
open OUT, ">$outfile" or die "could not open '$outfile' $!";
foreach my $key ( sort keys %data ) {
print OUT select_line( $data{$key} ); # pass a ref-to-array
}
close OUT;
sub select_line {
my($linesref) = @_;
return $linesref->[0] unless @$linesref > 1; # there is only one line
print "$_: $linesref->[$_]" for 0 .. $#$linesref;
print " please select the line to keep: ";
chomp(my $index = <STDIN>);
return $linesref->[$index];
}
__DATA__
one two
one two
One Two
one three
Two five
two three
Two three
--------------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 05 Oct 2003 07:23:05 +1000
From: King <king21122@yahoo.com>
Subject: Re: data varification code logic
Message-Id: <3F7F3A39.604@yahoo.com>
Tad McClellan wrote:
> King <king21122@yahoo.com> wrote:
>
>
>
>>my @col = map { (split)[0] } <DATA>; # untested
>
>
>>this code will not work if it is in the same program with another
>>statement which is also using the <DATA> .
>
>
>
> Maybe, maybe not. We would need to see the actual code to tell (hint!).
>
>
>
>>if I comment the first
>>block(s) then it works. where do I find some reading about this if this
>>is the correct behaviour, if not then what is going on?
>
>
>
> I'm forced to guess at what is going on in the unseen code.
>
> The input operator above ( <DATA> ) is in "list context"
> (see "Context" section in perldata.pod).
>
> The input operator in list context reads _all_ of the lines
> from the filehandle, so you will be at end-of-file afterwards.
> (see the named function corresponding to <>: perldoc -f readline)
>
> BTW, the DATA filehandle is meant to be "meta" here, ie: you should
> replace it with some other properly open()ed filehandle in your
> real program.
>
> Sounds like you are trying to use the same filehandle for 2 different
> things. Can't you use 2 filehandles (and 2 files) for the 2 different
> things?
>
I will need to read to find out if I can use 2 differnt filehandles for
the SAME file or not. maybe I can or even try it if it works.
because there will be the program code which has more than one block
each is using the same file independently.
>
>
>>another point:
>>since I need to write DATA to another file FH, should I make an array
>>with those $seen{key} > 1 and then as I loop through the DATA check each
>>key to see weather to write this line out or to ask for <STDIN> to
>>choose which line to keep and ignore the rest of the duplicates? or
>>someother logic is better to do this?
>>
>>notice I changed the __DATA__ below in-order to better reflect what I am
>>trying to explain,
>
>
>
> If you change the requirements, the code is likely to be different.
>
> My earlier code is not very helpful given this new requirement.
>
> You can avoid lots of similar round-and-round by getting the
> requirements clear up-front.
>
> Too many iterations and you'll end up using all of your coupons
> before you get an answer that you can actually use...
my apologies, I just went over and read my original post and yes I did
not discribe the problem acuretly, I don't know why, next time I will do
better. sometimes I feel if I start putting too many details in my
questoin, I run out of words to explain my problem. or worse loose the
attention of the reader. or even unable to put thoughts in words. :-)
>
>
>
>>I am trying to get the code to show me the whole
>>lines of DATA with the same keys and allow me to select which line to
>>keep and disregard the rest. so according to the DATA it should say
>>1: one two1
>>2: one two2
>>please select the line to keep:
>>if <STDIN> = 2 then donot copy "one two1" to the new file and do next
>
> ^
> ^ you cannot assign to the input operator, should be == ?
>
>
> We are still missing an essential requirement:
>
> Can we be sure that the entire file will fit into memory?
yes the file can fit in memory, but since you mentioned it. what in the
code or it's structure needs changing if it does not.
thanks for the step by step post. it helps me understand many things.
I understand most of the code below and will go over it again once I get
my Data::Dumper installed "problems with make test" with the help from
another post.
>
> The code (and algorithm) are likely to be very different
> depending on the answer to that question.
>
> I'll assume we can put the whole thing into memory.
>
>
> The best data structure seems to me to be a HoL (Hash of Lists,
> more accurately: a hash of references to arrays).
>
> --------------------------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Data::Dumper; # invaluable for debugging data structures
>
> ### load up the data structure
> my %data; # HoL
> while ( <DATA> ) {
> my $key = (split)[0]; # or: my($key) = /^(\S*)/;
>
> push @{ $data{$key} }, $_; # save lines associated with the key
> }
> #print Dumper \%data; # see what it is that we have built thus far
>
>
> ### make the output
> my $outfile = 'tmp';
> open OUT, ">$outfile" or die "could not open '$outfile' $!";
> foreach my $key ( sort keys %data ) {
> print OUT select_line( $data{$key} ); # pass a ref-to-array
> }
> close OUT;
>
>
> sub select_line {
> my($linesref) = @_;
>
> return $linesref->[0] unless @$linesref > 1; # there is only one line
>
> print "$_: $linesref->[$_]" for 0 .. $#$linesref;
> print " please select the line to keep: ";
> chomp(my $index = <STDIN>);
> return $linesref->[$index];
> }
>
>
> __DATA__
> one two
> one two
> One Two
> one three
> Two five
> two three
> Two three
> --------------------------------------------
>
>
------------------------------
Date: 4 Oct 2003 13:32:02 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: fastest count of instances in string?
Message-Id: <3ee08638.0310041232.3dc2d264@posting.google.com>
Uri Guttman <uri@stemsystems.com> wrote in message news:<x7pthemau3.fsf@mail.sysarch.com>...
> first, you have the same problem that tr/// doesn't intrpolate.
That's actually not my problem. Perhaps I wasn't clear enough in
communicating that I was only interested in the relative merits of
specifying a replacement list vs. not.
> secondly, replacing each char by itself is never destuctive.
I didn't say that it was. Again, I may have been unclear: the reason I
mentioned destructiveness is that having a blank replacement set may
*appear* to be destructive. That is the only reason I can think of for
specifying that a character set be replaced with itself.
> so not passing in the replacement string is just syntactic sugar and
> nothing special semantically.
In much the same way that
"$stupid"
is the same as
$stupid
, my point is that
tr/stupid/stupid/
is the same as
tr/stupid//
And for whatever reason, I got the barest improvement in speed when I
benchmarked. The second version is less prone to error (say,
transposing characters in one set) and is easier to grok at a glance:
"oh, nothing is being replaced."
------------------------------
Date: Sat, 04 Oct 2003 21:51:25 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: fastest count of instances in string?
Message-Id: <3F7F409D.23B8A681@acm.org>
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> <>
John
--
use Perl;
program
fulfillment
------------------------------
Date: 4 Oct 2003 07:49:17 -0700
From: bansal2425@hotmail.com (Gaurav)
Subject: Re: javascript in HTML ... not running on some browsers
Message-Id: <42983cb.0310040649.23b2f4d0@posting.google.com>
Hywel Jenkins <hyweljenkins@hotmail.com> wrote in message news:<MPG.19e7b89862d38e4b989701@news.individual.net>...
> In article <bljbog$70e$1@newsreader.mailgate.org>,
> kaspREMOVE_CAPS@epatra.com says...
> > > Can someone tell me whats the problem ? And how can i solve it.
> >
> > By posting your question in a Javascript or HTML related newsgroup.
>
> He did. Then he picked some other groups at random as his client-side
> problem is obviously Perl related.
didnt do at random. i posted them on html, perl and java script groups
as i my program has all three components.
------------------------------
Date: Sat, 4 Oct 2003 18:51:48 +0100
From: Hywel Jenkins <hyweljenkins@hotmail.com>
Subject: Re: javascript in HTML ... not running on some browsers
Message-Id: <MPG.19e9190d46fba06998970a@news.individual.net>
In article <42983cb.0310040649.23b2f4d0@posting.google.com>, bansal2425
@hotmail.com says...
> Hywel Jenkins <hyweljenkins@hotmail.com> wrote in message news:<MPG.19e7b89862d38e4b989701@news.individual.net>...
> > In article <bljbog$70e$1@newsreader.mailgate.org>,
> > kaspREMOVE_CAPS@epatra.com says...
> > > > Can someone tell me whats the problem ? And how can i solve it.
> > >
> > > By posting your question in a Javascript or HTML related newsgroup.
> >
> > He did. Then he picked some other groups at random as his client-side
> > problem is obviously Perl related.
>
> didnt do at random. i posted them on html, perl and java script groups
> as i my program has all three components.
How did you figure that your JavaScript problem is related to either
Perl or HTML, then?
--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php
------------------------------
Date: 4 Oct 2003 07:47:29 -0700
From: bansal2425@hotmail.com (Gaurav)
Subject: Re: LWP:UserAgent not working ???
Message-Id: <42983cb.0310040647.240bb225@posting.google.com>
wherrera@lynxview.com (Bill) wrote in message news:<239ce42f.0310030946.66fedbec@posting.google.com>...
> bansal2425@hotmail.com (Gaurav) wrote in message news:<42983cb.0310030625.fa12d98@posting.google.com>...
> > Hello,
> >
> > i have a perl script that i last used early this year i guess. It was running fine.
>
> Was this on the samer server setup? Or was the installation changed?
>
>
> >
> > Now if i try to run it, i get this error message.
> > ***********************************
> > perl data.pl 4 1 2002 6 30 2002
> > Can't locate LWP/UserAgent.pm in @INC (@INC contains:
> > /usr/perl5/5.00503/sun4-so
> > laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
> > /usr/perl5/site
> > _perl/5.005 .) at Web.pm line 12.
> > BEGIN failed--compilation aborted at data.pl line 10.
> > ***********************************
> >
> >
> > Can someone tell me whats wrong?
> > what is @INC ?
> >
>
> @INC is the list of places where a module might be stored on disk.
>
> > thank you in advance.
> >
> > Gaurav
>
> Usually this means LWP is not installed properly--check this via
>
> perl -e "use LWP::UserAgent;"
>
> at the command line--does it tell you it cannot find the module?
I tried perl -e "use LWP::UserAgent;" on my server and i got the
following message. It seems like module doesnt exist.
**********************************
gbansal@ernie:~> perl -e "use LWP::UserAgent;"
Can't locate LWP/UserAgent.pm in @INC (@INC contains:
/usr/perl5/5.00503/sun4-so
laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
/usr/perl5/site
_perl/5.005 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
***************************************
How can i add the module ? I am a user on a school server.
Gaurav
------------------------------
Date: Sat, 04 Oct 2003 20:11:21 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: LWP:UserAgent not working ???
Message-Id: <mbudash-18887E.13112004102003@typhoon.sonic.net>
In article <42983cb.0310040647.240bb225@posting.google.com>,
bansal2425@hotmail.com (Gaurav) wrote:
> wherrera@lynxview.com (Bill) wrote in message
> news:<239ce42f.0310030946.66fedbec@posting.google.com>...
> > bansal2425@hotmail.com (Gaurav) wrote in message
> > news:<42983cb.0310030625.fa12d98@posting.google.com>...
> > > Hello,
> > >
> > > i have a perl script that i last used early this year i guess. It was
> > > running fine.
> >
> > Was this on the samer server setup? Or was the installation changed?
> >
> >
> > >
> > > Now if i try to run it, i get this error message.
> > > ***********************************
> > > perl data.pl 4 1 2002 6 30 2002
> > > Can't locate LWP/UserAgent.pm in @INC (@INC contains:
> > > /usr/perl5/5.00503/sun4-so
> > > laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
> > > /usr/perl5/site
> > > _perl/5.005 .) at Web.pm line 12.
> > > BEGIN failed--compilation aborted at data.pl line 10.
> > > ***********************************
> > >
> > >
> > > Can someone tell me whats wrong?
> > > what is @INC ?
> > >
> >
> > @INC is the list of places where a module might be stored on disk.
> >
> > > thank you in advance.
> > >
> > > Gaurav
> >
> > Usually this means LWP is not installed properly--check this via
> >
> > perl -e "use LWP::UserAgent;"
> >
> > at the command line--does it tell you it cannot find the module?
>
>
> I tried perl -e "use LWP::UserAgent;" on my server and i got the
> following message. It seems like module doesnt exist.
> **********************************
> gbansal@ernie:~> perl -e "use LWP::UserAgent;"
> Can't locate LWP/UserAgent.pm in @INC (@INC contains:
> /usr/perl5/5.00503/sun4-so
> laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
> /usr/perl5/site
> _perl/5.005 .) at -e line 1.
> BEGIN failed--compilation aborted at -e line 1.
> ***************************************
>
> How can i add the module ? I am a user on a school server.
>
> Gaurav
perldoc -q "my own"
--
Michael Budash
------------------------------
Date: 4 Oct 2003 13:47:30 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: LWP:UserAgent not working ???
Message-Id: <239ce42f.0310041247.37cb4656@posting.google.com>
bansal2425@hotmail.com (Gaurav) wrote in message news:<42983cb.0310040647.240bb225@posting.google.com>...
> wherrera@lynxview.com (Bill) wrote in message news:<239ce42f.0310030946.66fedbec@posting.google.com>...
> > bansal2425@hotmail.com (Gaurav) wrote in message news:<42983cb.0310030625.fa12d98@posting.google.com>...
>
>
> I tried perl -e "use LWP::UserAgent;" on my server and i got the
> following message. It seems like module doesnt exist.
> **********************************
> gbansal@ernie:~> perl -e "use LWP::UserAgent;"
> Can't locate LWP/UserAgent.pm in @INC (@INC contains:
> /usr/perl5/5.00503/sun4-so
> laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
> /usr/perl5/site
> _perl/5.005 .) at -e line 1.
> BEGIN failed--compilation aborted at -e line 1.
> ***************************************
>
> How can i add the module ? I am a user on a school server.
>
> Gaurav
Simplest, have your sysadmin do it.
However, I've installed user directory CPAN modules via HTTP/CGI
before, so I know it's possible to install them yourself, as long as
you can create directories on your server somewhere.
See if you can run CPAN from the Command line:
$> perl -e "use CPAN; CPAN::shell(); "
If so, read the documentation for CPAN to set up installation to one
of your directories. Then add a
use INC 'mydir';
to your programs. The documentation for CPAN has this:
-------------------------------------------------------------------------
How do I manually install a module in a private/non-standard
directory?
You need to set PREFIX and LIB when you run the Makefile.PL. LIB is
where the module files will go and PREFIX is the stub directory for
everything else. For example:
foo@barbell$ perl Makefile.PL LIB=/home/foobar/mylib
PREFIX=/home/foobar/mylib
Read more about this in the ExtUtils::MakeMaker documentation.
--------------------------------------------------------------------------------
How do I use a module installed in a private/non-standard directory?
There are several ways to use modules installed in private
directories:
foo@barbell$ setenv PERL5LIB /path/to/module sets the environment
variable PERL5LIB.
use lib qw(/path/to/module); used at the top of your script tells perl
where to find your module.
foo@barbell$ perl -I/path/to/module
All of these will append /path/to/module to @INC. You should keep in
mind that having private/non-standard libraries may cause problems if
you wish to have portable code.
----------------------------------------------
------------------------------
Date: Sat, 04 Oct 2003 13:25:21 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: multiple SQL line query via Perl
Message-Id: <vntii1m0omjg75@corp.supernews.com>
In article <8a1c0c84.0310031124.28e7862f@posting.google.com>,
JohnnyQ <chicagojohnny1@yahoo.com> wrote:
: [...]
: So, my problem is that I have to find a way to group the following SQL
: statements together and have them execute at once:
:
: declare @rowct int
: select @rowct = 1
: while (@rowct > 0)
: begin
: delete Foo where creationDate < dateadd(day, -5, getdate())
: select @rowct = @@rowcount
: end
What about the following?
$dbh->do(q{
declare @rowct int
select @rowct = 1
while (@rowct > 0)
begin
delete Foo where creationDate < dateadd(day, -5, getdate())
select @rowct = @@rowcount
end
});
Greg
--
Kelso: I'm not shallow, Fez. I just judge chicks by their looks.
------------------------------
Date: Sat, 04 Oct 2003 15:15:35 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Newbie Q - Nicer way to lc something?
Message-Id: <0t6tnv41oqopqpb2rqcph2n5ovlkcram5c@4ax.com>
X-Ftn-To: Chris Smith
Chris Smith <chris@FLARBLEinfinitemonkeys.org.uk> wrote:
>> $a = "\L$a"; #also fine
>
>Thank you - just what I was after!
Don't thank me, if you're really lazy notice that lc $a is still shorter
version. :)
--
Matija
------------------------------
Date: Sat, 04 Oct 2003 18:11:20 +0100
From: Chris Smith <chris@FLARBLEinfinitemonkeys.org.uk>
Subject: Re: Newbie Q - Nicer way to lc something?
Message-Id: <blmv6a$8mq$5$8300dec7@news.demon.co.uk>
Matija Papec wrote:
> X-Ftn-To: Chris Smith
>
> Chris Smith <chris@FLARBLEinfinitemonkeys.org.uk> wrote:
>>> $a = "\L$a"; #also fine
>>
>>Thank you - just what I was after!
>
> Don't thank me, if you're really lazy notice that lc $a is still shorter
> version. :)
Yes but in the context I need it in, it's lazier ;-)
--
Chris Smith
http://www.infinitemonkeys.org.uk/
------------------------------
Date: 04 Oct 2003 20:16:00 GMT
From: anotherway83@aol.comnospam (The Mosquito ScriptKiddiot)
Subject: outputting raw data to a file
Message-Id: <20031004161600.16521.00000276@mb-m19.aol.com>
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)
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 21:36:03 +0100
From: Salvador Fandino <sfandino@yahoo.com>
Subject: Re: outputting raw data to a file
Message-Id: <blnavp$8q3$06$1@news.t-online.com>
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)
use chr or pack functions
open(SES,">filename");
$x=43;
print SES chr($x);
Bye,
- Salva
------------------------------
Date: 04 Oct 2003 20:59:00 GMT
From: anotherway83@aol.comnospam (The Mosquito ScriptKiddiot)
Subject: Re: outputting raw data to a file
Message-Id: <20031004165900.15443.00000338@mb-m28.aol.com>
>use chr or pack functions
>
> open(SES,">filename");
> $x=43;
> print SES chr($x);
>
>Bye,
>
> - Salva
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 22:00:04 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: outputting raw data to a file
Message-Id: <3F7F42DA.7060305@rochester.rr.com>
Salvador Fandino wrote:
>
>
> The Mosquito ScriptKiddiot wrote:
...
>> 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)
>
>
> use chr or pack functions
>
> open(SES,">filename");
> $x=43;
> print SES chr($x);
>
> Bye,
>
> - Salva
>
And , even though it isn't needed for this specific example, don't forget
binmode(SES);
if on Windoze or other non-*nix system, or if using Perl 5.8 or later.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sat, 4 Oct 2003 19:23:05 +0000 (UTC)
From: silvia@onairos.com
Subject: test news
Message-Id: <bln6mp$pbr$1@localhost.localdomain>
test news
--
Silvia
Sex Fotos
http://www.personal.able.es/ensoriano
------------------------------
Date: Sat, 04 Oct 2003 13:07:30 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: two regexs
Message-Id: <vnthgi422jim3e@corp.supernews.com>
In article <nh4tnvk2dch5sogntfd3gi5qgm5tnmmhf2@4ax.com>,
Matija Papec <perl@my-header.org> wrote:
: I would like to match each value from @str with only one regex. I come
: to,
: if ( /="(.+?)"|=(\S+)/ ) { print $1 || $2 }
:
: but I'm not sure if this is the best matching solution?
How about the following?
#! /usr/local/bin/perl
use warnings;
use strict;
my @str = (
'="foo bar" ..',
'=foobar ..',
);
for (@str) {
print $_, ":\n";
if (/="(.+?)"|=(\S+)/) {
my $hit = defined $1 ? $1 : $2;
print " got [$hit]\n";
}
else {
print " no match\n";
}
}
Greg
--
Any sufficiently complicated C or Fortran program contains an ad hoc
informally-specified bug-ridden slow implementation of half of Common Lisp.
-- Philip Greenspun
------------------------------
Date: Sat, 4 Oct 2003 15:44:27 -0400
From: "Jay W" <jandk1@nospanners.comcast.net>
Subject: Re: Unexplained Multiple Lauches of Script with NetBackup ... could it be PERL? (Thanks!!)
Message-Id: <YvCdnTYXwZOCvuKiXTWJkA@comcast.com>
Thanks to all!! The lockfile is a good idea, I'll pursue that. The script is
not doing any System or Forks, so I'm putting some debug code in the
"bpstart" pre-backup script. I've heard of bugs with NetBackup using policy
specific scripts. That's the direction I am heading.
"Jay W" <jandk1@nospanners.comcast.net> wrote in message
news:8_2cnfo5-731-uCiXTWJig@comcast.com...
> I have a PERL script that is executed by NetBackup "bpstart". From within
> the script two different lines are launched depending on the Policy passed
> to bpstart in %2. Only one of the two lines should be launched at any
given
> time.
>
> The problem is that shortly after launching the script (about 5 minutes),
a
> second occurrance starts, then a 3rd, then a 4th .... up to 29 occurances
in
> some cases. Usually this scenario ends with a Dr Watson abort. The odd
thing
> is that I use about 7 command line parameters that are identical in each
> launch, so a full command line is being "re-executed" :
>
> function: Perl_dounwind
> 280363f1 b903010000 mov ecx,0x103
> 280363f6 7417 jz Perl_sv_compile_2op+0x6fa0
> (2803ef0f)
>
> *----> Stack Back Trace <----*
>
> FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name
> 0140FD9C 2805D784 01B31308 015D41C4 28024499 015D41C4 !Perl_dounwind
> 0140FE24 280862DE 015D41C4 00000000 00000000 505C3A43
!Perl_runops_standard
> 0140FF3C 00401012 0000000C 015D24B0 015D2AF8 004010F9 !RunPerl
> 0140FFC0 77E9CA90 00000000 00000000 7FFDF000 C0000005 !<nosymbols>
> 0140FFF0 00000000 00401016 00000000 000000C8 00000100
> kernel32!CreateProcessW
>
> I guess, the questions are :
>
> 1. Has anyone else run into this?
> 2. Is there a syntax that may inadvertantly start another instance of the
> command that was originally launched? (I'm 1st year PERL)
>
> I'm trying to prove through debug code that it is NetBackup's fault and
not
> PERL
>
> Env :
>
> W2K AS - SP4
> ActiveState PERL 5.8.1
>
>
------------------------------
Date: Sat, 04 Oct 2003 13:15:48 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: waitpid and alarms
Message-Id: <vnti045h4pcubb@corp.supernews.com>
What OS? What version of Perl?
With 5.6.1 on Tru64, I get the following output:
Forking pid 605402
Forking pid 597267
Forking pid 638694
Forking pid 636141
Forking pid 612305
Forking pid 646038
Forking pid 525589
Forking pid 655048
pid = 605402, waitpid = 605402
Alarm signal
pid = 597267, waitpid = 597267
pid = 638694, waitpid = 638694
pid = 636141, waitpid = 636141
pid = 612305, waitpid = 612305
pid = 646038, waitpid = 646038
pid = 525589, waitpid = 525589
pid = 655048, waitpid = 655048
With 5.8.0 on Win32, I see
Forking pid -656169
Forking pid -658717
Forking pid -657601
Forking pid -658101
Forking pid -3427937
Forking pid -3426389
Forking pid -3426873
Forking pid -3437929
pid = -656169, waitpid = -656169
Alarm signal
pid = -658717, waitpid = -658717
pid = -657601, waitpid = -657601
pid = -658101, waitpid = -658101
pid = -3427937, waitpid = -3427937
pid = -3426389, waitpid = -3426389
pid = -3426873, waitpid = -3426873
pid = -3437929, waitpid = -3437929
Greg
--
The way to eternal peace does not lead through strengthening state and
central power, as socialism strives for.
-- Ludwig von Mises, *Nation, State, and Economy*
------------------------------
Date: Sat, 4 Oct 2003 10:16:26 -0500
From: "Steve East" <News@SteveNoWayEast.com>
Subject: Re: waitpid and alarms
Message-Id: <3f7ee459$0$41293$a1866201@newsreader.visi.com>
"Greg Bacon" <gbacon@hiwaay.net> wrote in message
news:vnti045h4pcubb@corp.supernews.com...
> What OS? What version of Perl?
It was Perl 5.8.0. Fails on Solaris, RH Linux and HP-UX.
Steve.
------------------------------
Date: Sat, 04 Oct 2003 15:00:59 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "Ryan" <cent@optushome.com.au>
Subject: Re: WWW::Mechanize .. anyone?
Message-Id: <c34bcd20492f4e7715d6b6e2006b1c8a@news.teranews.com>
>>>>> "Ryan" == Ryan <cent@optushome.com.au> writes:
Ryan> well the weird thing is, it is fetching images! and I have no idea how to
Ryan> stop it or turn it off, it's not saving the images anywhere but it is
Ryan> getting the contents of the images...
WWW::Mechanize does exactly what you tell it to do. What did you tell
it to do?
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
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 5615
***************************************