[26319] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8496 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 7 10:31:21 2005

Date: Fri, 7 Oct 2005 06:05:08 -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           Fri, 7 Oct 2005     Volume: 10 Number: 8496

Today's topics:
        Help with simple script (laser4000)
    Re: Help with simple script (Anno Siegel)
    Re: Help with simple script <noreply@gunnar.cc>
    Re: Help with simple script <1usa@llenroc.ude.invalid>
    Re: Help with simple script <noreply@gunnar.cc>
    Re: Help with simple script <1usa@llenroc.ude.invalid>
    Re: how to randomize List::Util::shuffle() better? <nobody@dizum.com>
    Re: Is there a Perl Module The Does GCC like precompile <tadmc@augustmail.com>
        print prints things in strange order. <bogus.address@no.spam.com>
    Re: print prints things in strange order. <1usa@llenroc.ude.invalid>
    Re: print prints things in strange order. <someone@example.com>
    Re: Problem with perl & google <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 07 Oct 2005 10:23:01 GMT
From: rv@bakker-sl-dot-nl.no-spam.invalid (laser4000)
Subject: Help with simple script
Message-Id: <43464c85$0$59303$892e7fe2@authen.white.readfreenews.net>

I need a simple perl script that read in a txt file.
and if it find a text wich I fill in a varialble it must print OK to
dstout.



------------------------------

Date: 7 Oct 2005 10:35:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help with simple script
Message-Id: <di5j22$ndn$1@mamenchi.zrz.TU-Berlin.DE>

laser4000 <rv@bakker-sl-dot-nl.no-spam.invalid> wrote in comp.lang.perl.misc:
> I need a simple perl script that read in a txt file.
> and if it find a text wich I fill in a varialble it must print OK to
> dstout.

You don't want help with your script, you want it written for you.
That's not what we do here.  Make an effort of your own.  If you have
problems, show what you have and we may help you correct it.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


------------------------------

Date: Fri, 07 Oct 2005 12:39:40 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help with simple script
Message-Id: <3qn1fkFfpcg3U1@individual.net>

laser4000 wrote:
> I need a simple perl script that read in a txt file.
> and if it find a text wich I fill in a varialble it must print OK to
> dstout.

Thanks for letting us know about your needs.

Would you mind showing us the code you have written so far, and letting 
us know which difficulties you encountered?

If you post again, please follow the posting guidelines for this group: 
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Fri, 07 Oct 2005 10:56:29 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Help with simple script
Message-Id: <Xns96E8469EE55F6asu1cornelledu@127.0.0.1>

rv@bakker-sl-dot-nl.no-spam.invalid (laser4000) wrote in news:43464c85$0
$59303$892e7fe2@authen.white.readfreenews.net:

> I need a simple perl script that read in a txt file.
> and if it find a text wich I fill in a varialble it must print OK to
> dstout.

Perl is not really the right language for this. Consider using Ruby.

http://www.ruby-lang.org/en/

;-)

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


------------------------------

Date: Fri, 07 Oct 2005 13:34:25 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help with simple script
Message-Id: <3qn4m9FfgkgnU1@individual.net>

A. Sinan Unur wrote:
> Perl is not really the right language for this. Consider using Ruby.

Please don't nudge it so it returns!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Fri, 07 Oct 2005 11:38:09 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Help with simple script
Message-Id: <Xns96E84DAEB84F0asu1cornelledu@127.0.0.1>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in news:3qn4m9FfgkgnU1
@individual.net:

> A. Sinan Unur wrote:
>> Perl is not really the right language for this. ....
> 
> Please don't nudge it so it returns!

You are right. I should know better.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


------------------------------

Date: Fri,  7 Oct 2005 14:00:02 +0200 (CEST)
From: Nomen Nescio <nobody@dizum.com>
Subject: Re: how to randomize List::Util::shuffle() better?
Message-Id: <892b8330d7771685d519671c9853cedd@dizum.com>

> ..  I want to pick three things at random from a list, so:
> ..  
> ..  use List::Util 'shuffle';
 ..
> ..  but every time I call this (repeatedly within the same run) with the
> ..   same input list, I get the same three items back out.
> 
> 
> Really? Do you have a *complete* program (not longer than about 20 lines)
> that shows this behaviour?

Sorry. When I started condensing my (long) program to post the
relevant parts, I found a stupid mistake.


> No. There are things you can do to make it *less* random, like resetting
> the random seed. Are you sure you aren't calling srand before each call
> to pick()?

Doing something else stupid.

Thanks for your help!




------------------------------

Date: Fri, 7 Oct 2005 07:14:39 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Is there a Perl Module The Does GCC like precompile on C++ files ?
Message-Id: <slrndkcplf.4fs.tadmc@magna.augustmail.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
>> Random Task <Random@Task.be> wrote:
>> 
>> > Is there a Perl Module The Does GCC like precompile on C++ files ?
>> 
>> 
>> If you mean a preprocessor, then see the -P switch in
>> 
>>    perldoc perlrun
> 
> You have occasionally pointed out that you are not clairvoyant.  You
> just proved the opposite!


I knew you were going to say that!


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 07 Oct 2005 10:50:24 GMT
From: "Robbie Hatley" <bogus.address@no.spam.com>
Subject: print prints things in strange order.
Message-Id: <Qps1f.13033$6e1.1196@newssvr14.news.prodigy.com>

Howdy.  I'm trying to get this (should be) simple test
program to work, but it does different things on different
perl implimentations:


#!/bin/perl
open my $F, $0 or die $!;
while (<$F>)
{
   chomp;
   print ("one two three " . "$_" . " DEF \n");
}
close $F;



Here's the output with djgpp's version of perl:


wd=C:\scripts
%

wd=C:\scripts
%perl dollscor
one two three #!/bin/perl DEF
one two three open my $F, $0 or die $!; DEF
one two three while (<$F>) DEF
one two three { DEF
one two three    chomp; DEF
one two three    print ("one two three " . $_ . " DEF \n"); DEF
one two three } DEF
one two three close $F; DEF

wd=C:\scripts
%


Pretty much what you'd expect.  BUT...
But here's the output with cygwin's version of perl:


bash-3.00
/cygdrive/c/scripts
%dollscor
 DEF wo three #!/bin/perl
 DEF wo three open my $F, $0 or die $!;
 DEF wo three while (<$F>)
 DEF wo three {
 DEF wo three    chomp;
 DEF wo three    print ("one two three " . $_ . " DEF \n");
 DEF wo three }
 DEF wo three close $F;

bash-3.00
/cygdrive/c/scripts
%


What's going on there???  The DEF should print at the end of the
line, but is over-writing the beginning instead.

Is one of my perl implimentations broken, or am I doing something
"undefined"?  Perhaps something about the way I'm using $_ ?
I can't figure it out.


For reference, here's the version info:

djgpp:
%perl -v
This is perl, v5.6.1 built for dos-djgpp
Copyright 1987-2001, Larry Wall
MS-DOS port Copyright (c) 1989, 1990, Diomidis Spinellis
djgpp v2 port (jpl5003c) by Hirofumi Watanabe, 1996
djgpp v2 port (perl5004+) by Laszlo Molnar, 1997-1999

cygwin:
%perl -v
This is perl, v5.8.7 built for cygwin-thread-multi-64int
Copyright 1987-2005, Larry Wall




Puzzled,
Robbie Hatley
Tustin, CA, USA
email: lonewolfintj at pacbell dot net
web:   home dot pacbell dot net slant earnur slant




------------------------------

Date: Fri, 07 Oct 2005 11:10:44 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: print prints things in strange order.
Message-Id: <Xns96E849095D77Fasu1cornelledu@127.0.0.1>

"Robbie Hatley" <bogus.address@no.spam.com> wrote in news:Qps1f.13033
$6e1.1196@newssvr14.news.prodigy.com:

> Howdy.  I'm trying to get this (should be) simple test
> program to work, but it does different things on different
> perl implimentations:

 ...

> #!/bin/perl
> open my $F, $0 or die $!;
> while (<$F>)
> {
>    chomp;
>    print ("one two three " . "$_" . " DEF \n");
> }
> close $F;


That is what you see on the screen. Do you know what is in the file?

Save the source file Unix line endings (LF) rather than MSDOS line 
endings, and then try. Alternatively,

#!/usr/bin/perl

use strict;
use warnings;

open my $F, $0 or die $!;
binmode $F;
while (<$F>) {
   s/(:?\015\012)|(:?\015)|(:?\012)// ;
   print ("one two three " . "$_" . " DEF \n");
}
close $F;

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


------------------------------

Date: Fri, 07 Oct 2005 11:24:22 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: print prints things in strange order.
Message-Id: <GVs1f.11098$ir4.6932@edtnps90>

Robbie Hatley wrote:
> Howdy.  I'm trying to get this (should be) simple test
> program to work, but it does different things on different
> perl implimentations:
> 
> 
> #!/bin/perl
> open my $F, $0 or die $!;
> while (<$F>)
> {
>    chomp;
>    print ("one two three " . "$_" . " DEF \n");
> }
> close $F;
> 
> 
> 
> Here's the output with djgpp's version of perl:
> 
> 
> wd=C:\scripts
> %
> 
> wd=C:\scripts
> %perl dollscor
> one two three #!/bin/perl DEF
> one two three open my $F, $0 or die $!; DEF
> one two three while (<$F>) DEF
> one two three { DEF
> one two three    chomp; DEF
> one two three    print ("one two three " . $_ . " DEF \n"); DEF
> one two three } DEF
> one two three close $F; DEF
> 
> wd=C:\scripts
> %
> 
> 
> Pretty much what you'd expect.  BUT...
> But here's the output with cygwin's version of perl:
> 
> 
> bash-3.00
> /cygdrive/c/scripts
> %dollscor
>  DEF wo three #!/bin/perl
>  DEF wo three open my $F, $0 or die $!;
>  DEF wo three while (<$F>)
>  DEF wo three {
>  DEF wo three    chomp;
>  DEF wo three    print ("one two three " . $_ . " DEF \n");
>  DEF wo three }
>  DEF wo three close $F;
> 
> bash-3.00
> /cygdrive/c/scripts
> %
> 
> 
> What's going on there???  The DEF should print at the end of the
> line, but is over-writing the beginning instead.

Your perl program is stored on disk in a DOS text format that has a carriage
return and line feed at the end of the line and the djgpp version's chomp()
removes these correctly however cygwin is a UNIX enviroment so it only removes
the line feed but not the carriage return.

perldoc perlport
perldoc perldos
perldoc perlcygwin



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Fri, 07 Oct 2005 11:24:51 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Problem with perl & google
Message-Id: <Xns96E84B6E4C007asu1cornelledu@127.0.0.1>

"Paul" <info@toplice.com.remove> wrote in
news:di58tk$gbv$1@ss405.t-com.hr: 

> This sample work:
> 
> $URL="http://search.yahoo.com/search?p=perl&fr=FP-tab-web-t&toggle=1
&co
> p=&ei =UTF-8";
>           use LWP::Simple;
>           unless (defined ($webstr = get $URL)){die "could not get
>           $URL\n";} print $webstr;
> But this don't:
>           $URL="http://www.google.com/search?hl=hr&q=perl&lr=";
>           use LWP::Simple;
>           unless (defined ($webstr = get $URL)){die "could not get
>           $URL\n";} print $webstr;
> Why is problem with google?

You should always ask the computer *why* something failed, and report it
when you are posting here. 

D:\Home\asu1\UseNet\clpmisc> wget
"http://www.google.com/search?hl=hr&q=perl&lr= "
--07:23:55--  http://www.google.com/search?hl=hr&q=perl&lr=
           => `search@hl=hr&q=perl&lr='
Resolving www.google.com... 64.233.161.99, 64.233.161.104,
64.233.161.147 Connecting to www.google.com|64.233.161.99|:80...
connected. HTTP request sent, awaiting response... 403 Forbidden
07:23:56 ERROR 403: Forbidden.

You are violating the Google TOS.

http://www.google.com/apis/

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


------------------------------

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 8496
***************************************


home help back first fref pref prev next nref lref last post