[30928] in Perl-Users-Digest
Perl-Users Digest, Issue: 2173 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 30 18:09:43 2009
Date: Fri, 30 Jan 2009 15:09: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 Fri, 30 Jan 2009 Volume: 11 Number: 2173
Today's topics:
Constructing a scalar reference <invalid@invalid.invalid>
Re: FAQ 4.48 How do I shuffle my MP3 collection? <brian.d.foy@gmail.com>
Re: Function Application is not Currying <jon@ffconsultancy.com>
Re: Function Application is not Currying <tim@burlyhost.com>
Re: I need a job in C/C++/Perl immediately. Telecomute <brian.d.foy@gmail.com>
Re: I need a job in C/C++/Perl immediately. Telecomute <dha@panix.com>
Re: I need a job in C/C++/Perl immediately. Telecomute <andrex@deadspam.com>
Re: I need a job in C/C++/Perl immediately. Telecomute <tadmc@seesig.invalid>
Re: Perl Peeves <jjcassidy@gmail.com>
perl qt with cygwin? <rabbits77@my-deja.com>
Re: Text Print Entire Directory Tree including File Nam <jimsgibson@gmail.com>
Re: unix - rsync - filter question <jimsgibson@gmail.com>
Re: Want to write a script to do the batch conversion f <jurgenex@hotmail.com>
Re: Want to write a script to do the batch conversion f <tadmc@seesig.invalid>
Re: Want to write a script to do the batch conversion f <tadmc@seesig.invalid>
Re: Want to write a script to do the batch conversion f <tzz@lifelogs.com>
Re: Want to write a script to do the batch conversion f <someone@example.com>
Re: Want to write a script to do the batch conversion f <someone@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 30 Jan 2009 22:47:53 +0000
From: Chet Butcher <invalid@invalid.invalid>
Subject: Constructing a scalar reference
Message-Id: <gm002i$f2a$1@aioe.org>
Hi
In the following sequence
$r = {}; # a hashref
$r = []; # an arrayref
$r = ?; # a scalar ref
What is ? ? I want to pass a ref to a scalar (pass by reference)
without resorting to
my $r;
mySub( \$r );
I just want to use
my $r = (something);
mySub( $r );
to be consistent with
my $r = {}; # or my $r = [];
mySub( $r );
I know it's not a big drama on the surface, but I'm trying to overload
the method to return various results depending on the reference type,
and I dont want the \ in some calls and not others.
Thanks
------------------------------
Date: Fri, 30 Jan 2009 12:00:44 -0800
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 4.48 How do I shuffle my MP3 collection?
Message-Id: <300120091200444784%brian.d.foy@gmail.com>
In article <87d4e66nmr.fsf@jidanni.org>, <jidanni@jidanni.org> wrote:
> PS> FAQ 4.48 How do I shuffle an array randomly?
> PS> # shuffle my mpeg collection
> PS> my @mpeg = <audio/*/*.mp3>;
> PS> fisher_yates_shuffle( \@mpeg ); # randomize @mpeg in place
>
> Well OK, but how to also minimize two songs by the same artist
> (the /*/ in audio/*/*.mp3) ending up adjacent?
That's a different question since it removes the randomness :)
------------------------------
Date: Fri, 30 Jan 2009 19:12:49 +0000
From: Jon Harrop <jon@ffconsultancy.com>
Subject: Re: Function Application is not Currying
Message-Id: <4uedncuZN9ixzR7UnZ2dnUVZ8rKdnZ2d@posted.plusnet>
I had hoped someone else would correct you but they haven't. So...
Xah Lee wrote:
> Here are some examples of a function that returns a function as
> result, but is not currying.
>
> Mathematica example:
>
> f[n_]:=Function[n^#];
> f[7][2]
> (* returns 49 *)
>
> Emacs lisp example:
>
> (defmacro f (n) (list 'lambda (list 'x) (list 'expt n 'x) ) )
> (funcall (f 7) 2)
>
> Perl example:
>
> sub f {$n=$_[0]; sub { $n ** $_[0]} };
> print &{ f(7) } (2);
>
> Javascript example:
>
> function f(n) {return function (x) {return Math.pow(x,n);}; }
> alert (f(7) (2));
>
> However, the above are not languages that support currying,
That is incorrect. Mathematica, Lisp, Perl and Javascript all support
currying.
> which is a feature that Haskell & Ocaml has.
That is correct. Here is an OCaml equivalent:
let f =
fun n ->
fun m ->
n ** m
> To be more concrete, in the context of a given computer language, to
> say that it support curring, is to mean that the compiler understand
> the concept to certain degree. More to the point, the language is
> inherently able to take a function of more than one arg and
> deconstruct it to several functions of single arg.
That is incorrect. You only need a language with first-class functions.
I believe you are confusing the syntactic support in OCaml and Haskell for
something more. It simply allows you to rewrite the above as:
let f n m = n ** m
or:
let f = fun n m -> n ** n
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?u
------------------------------
Date: Fri, 30 Jan 2009 11:22:01 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Function Application is not Currying
Message-Id: <RtIgl.1787$_N1.1474@newsfe01.iad>
Jon Harrop wrote:
> I had hoped someone else would correct you but they haven't. So...
The lack of replies aren't about anyone correcting him or not, it's that
the guy just posts anything he can to spamvertize his site and tell
everyone how brilliant he thinks he is. It's just a method he uses to
try and feel important and also get people to his site (and for the
search engines to rank it higher). He's a known troll and spammer in a
lot of groups due to this. The guy rarely has anything relevant to the
groups he posts to. Most people I know of have come to just filter out
his posts.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Fri, 30 Jan 2009 12:02:59 -0800
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: I need a job in C/C++/Perl immediately. Telecomute only. Full-Time. Regex/XML/Database/Parsing(et all) Expert. Will work for 60k the first year guaranteed !!
Message-Id: <300120091202592908%brian.d.foy@gmail.com>
In article <n7o1o49vtdlfdkao9joh33a8p9oshnqaqo@4ax.com>,
<sln@netherlands.com> wrote:
> I am the most creative regular expression artist you will have the privelage
> to ever see. It comes from 25 years of parsing text, starting in assembly.
Actually, now that you've said that, Eli the Bearded has re-appeared,
and he's truly a regex artist.
------------------------------
Date: Fri, 30 Jan 2009 21:14:03 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: I need a job in C/C++/Perl immediately. Telecomute only. Full-Time. Regex/XML/Database/Parsing(et all) Expert. Will work for 60k the first year guaranteed !!
Message-Id: <slrngo6rct.7vr.dha@panix2.panix.com>
On 2009-01-30, brian d foy <brian.d.foy@gmail.com> wrote:
> In article <n7o1o49vtdlfdkao9joh33a8p9oshnqaqo@4ax.com>,
><sln@netherlands.com> wrote:
>
>
>> I am the most creative regular expression artist you will have the privelage
>> to ever see. It comes from 25 years of parsing text, starting in assembly.
>
> Actually, now that you've said that, Eli the Bearded has re-appeared,
> and he's truly a regex artist.
He has? where??
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
When I went to open my suitcase I found a lock on it, which I never
have. So I picked the lock, opened up the suitcase, and started pulling
out all these dresses. After like the 10th dress, I thought, These
aren't my dresses. - John Malkovich
------------------------------
Date: Fri, 30 Jan 2009 21:42:00 GMT
From: Andrew Schulman <andrex@deadspam.com>
Subject: Re: I need a job in C/C++/Perl immediately. Telecomute only. Full-Time. Regex/XML/Database/Parsing(et all) Expert. Will work for 60k the first year guaranteed !!
Message-Id: <m0t6o4d7fftaquhv75dkjsqph2vr6cm50i@4ax.com>
> Because son, I am so much your father here that I should and could spank your
> ass all day long, until I get employment. Back to class son ...
<plonk>
--
To reply by email, change "deadspam.com" to "alumni.utexas.net"
------------------------------
Date: Fri, 30 Jan 2009 14:38:50 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: I need a job in C/C++/Perl immediately. Telecomute only. Full-Time. Regex/XML/Database/Parsing(et all) Expert. Will work for 60k the first year guaranteed !!
Message-Id: <slrngo6paq.mpb.tadmc@tadmc30.sbcglobal.net>
brian d foy <brian.d.foy@gmail.com> wrote:
> Eli the Bearded has re-appeared,
I was thrilled to see him back.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 30 Jan 2009 14:50:18 -0800 (PST)
From: A Dude <jjcassidy@gmail.com>
Subject: Re: Perl Peeves
Message-Id: <7e76f741-a70d-473b-b1d4-ba1329c9bb76@z1g2000yqn.googlegroups.com>
On Jan 27, 11:47=A0pm, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "AD" =3D=3D A Dude <jjcass...@gmail.com> writes:
>
> =A0 AD> Then write (the perlish way)
>
> =A0 AD> =A0 =A0 my $output_value =3D CONDITION || '0';
>
> that is a poor choice of a false value. sure it works but 0 (no quotes)
> or '' would be better.
It wasn't meant to be a false value, just to indicate one when
*writing it out* to read it back in, later. I specified the string
'0'. If the condition is not true.
------------------------------
Date: Fri, 30 Jan 2009 17:15:28 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: perl qt with cygwin?
Message-Id: <8cb6a$49837c01$c650990a$6077@news.eurofeeds.com>
I am trying to get perl qt to work under cygwin
and am not having much luck.
I have KDE and QT installed. Everything should just compile and go
but this is not the case.
Googling reveals nothing but very old threads from various sources
that don't help.
Does anyone have any advice on how to get perl qt running under cygwin?
------------------------------
Date: Fri, 30 Jan 2009 09:21:38 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Text Print Entire Directory Tree including File Names from a FTP Directory
Message-Id: <300120090921381081%jimsgibson@gmail.com>
In article
<707ced5c-5f50-4470-83ae-ef8915e3a7c4@y23g2000pre.googlegroups.com>,
ifiaz <fiazidris@gmail.com> wrote:
> Hello,
>
> I am looking for a way to get the ENTIRE (or at a given depth)
> directory tree of a FTP folder and files from an FTP server. The
> listing should include file sizes and modified dates, etc. as much
> info as possible through some configurable parameters. The same script
> may be able to be used on a local drive as well.
>
> I have managed to do this FTP directory task using the
> http://www.ftprush.com/ftp-directory-tree.html application. This
> application is pretty cool and it did exactly what I wanted.
>
> **********
> My question is how can I do this using a Perl Script or any other free
> utility from command line.???
> **********
>
> I am sure someone out there who must have written such stuff already.
> I do not wish to reinvent the wheel and even I am not capable to write
> such a script myself.
>
> Any pointers and help is much appreciated. Thank you.
Use the Net::FTP module and its 'dir' command to get a directory
listing from an FTP server. To get a full directory tree, you will have
to parse the return from the dir command and follow directory links.
--
Jim Gibson
------------------------------
Date: Fri, 30 Jan 2009 09:17:08 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: unix - rsync - filter question
Message-Id: <300120090917084891%jimsgibson@gmail.com>
In article <slrngo4p1d.ahn.tadmc@tadmc30.sbcglobal.net>, Tad J
McClellan <tadmc@seesig.invalid> wrote:
> Jim Gibson <jimsgibson@gmail.com> wrote:
>
>
> > In Unix, errors are usually printed to STDERR, which is unbuffered (or,
> > for the pedantic among us, "autoflushed").
>
>
> Errr, no, STDERR is unbuffered if we're to believe the man page.
>
>
> > man 3 stderr
>
> ...
>
> CONSIDERATIONS
> The stream stderr is unbuffered.
I suspect that the term "unbuffered" means different things to
different people.
--
Jim Gibson
------------------------------
Date: Fri, 30 Jan 2009 04:42:17 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Want to write a script to do the batch conversion from domain name to IP.
Message-Id: <i8t5o41pp5iled4ea915lk02i41r4nj6je@4ax.com>
Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>cat cybersyndrome.pla5.txt | perl -MSocket -lne'
Of course this has nothing to do with Perl, nevertheless it's useless
use of cat, see http://partmaps.org/era/unix/award.html
jue
------------------------------
Date: Fri, 30 Jan 2009 08:52:33 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Want to write a script to do the batch conversion from domain name to IP.
Message-Id: <slrngo651h.hvf.tadmc@tadmc30.sbcglobal.net>
Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> On Fri, 30 Jan 2009 05:17:00 -0800, "John W. Krahn"
><someone@example.com> wrote:
>>#!/usr/bin/perl
>>use warnings;
>>use strict;
>>use Socket;
my $outfile = '/some/other/myIP.txt';
open my $OTHER, '>', $outfile or die "could not open '$outfile' $!";
>>while ( <> ) {
>> chomp;
>> my ( $address, $port ) = split /:/ or next;
>> my $number = inet_aton $address;
>> my $ip = inet_ntoa $number;
>> print "$address:$port -> $ip:$port\n";
print $OTHER "$address:$port -> $ip:$port\n";
>> }
>>
>>__END__
>>
>>
>>And then run it as:
>>
>>./11.pl mydomain.txt
>
> If I want to redirect the output to a file, say myIP.txt, I know that
> the following line will be OK:
>
> ./11.pl mydomain.txt > myIP.txt
>
> But, it should be also possiable to redirect the output to a file
> within the above perl script, any hints on this?
>
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 30 Jan 2009 11:27:44 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Want to write a script to do the batch conversion from domain name to IP.
Message-Id: <slrngo6e4g.k8p.tadmc@tadmc30.sbcglobal.net>
Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> On Fri, 30 Jan 2009 08:52:33 -0600, Tad J McClellan
><tadmc@seesig.invalid> wrote:
>> my $outfile = '/some/other/myIP.txt';
>> open my $OTHER, '>', $outfile or die "could not open '$outfile' $!";
>
> I use the following two lines:
>
> my $outfile = '~/myIP.txt';
> open my $OTHER, '>', $outfile or die "could not open '$outfile' $!";
Using tilde (~) to mean "home directory" is a shell feature.
Perl is not the shell, so that feature is not available.
my $outfile = '/home/zhao/myIP.txt';
or
my $outfile = 'myIP.txt'; # write to current directory
or
my $outfile = './myIP.txt'; # same thing
> But, I'll mee the errors like this:
>
> $ ./DomainName2IP.pl cybersyndrome.pla5.txt
> Missing comma after first argument to open function at
> ./DomainName2IP.pl line 1
> 3, near "'>>./you.txt';"
^^^^^^^
^^^^^^^
Where did "you.txt" come from?
Are you sure you have the right code going with the right error message?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 30 Jan 2009 13:05:31 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Want to write a script to do the batch conversion from domain name to IP.
Message-Id: <86fxj08vic.fsf@lifelogs.com>
On Fri, 30 Jan 2009 11:27:44 -0600 Tad J McClellan <tadmc@seesig.invalid> wrote:
TJM> Using tilde (~) to mean "home directory" is a shell feature.
TJM> Perl is not the shell, so that feature is not available.
Well, glob("~/.cshrc") works OK for me, so the feature is available. It
uses File::Glob in recent Perls...
Ted
------------------------------
Date: Fri, 30 Jan 2009 05:08:08 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: Want to write a script to do the batch conversion from domain name to IP.
Message-Id: <YYCgl.38630$1W7.35511@newsfe11.iad>
Hongyi Zhao wrote:
> On Fri, 30 Jan 2009 03:04:18 -0800, "John W. Krahn"
> <someone@example.com> wrote:
>> $ echo "
>> 116.52.155.237:80
>> ip-72-55-191-6.static.privatedns.com:3128
>> 222.124.135.40:80
>> 217.151.231.34:3128
>> 202.106.121.134:80
>> 211.161.197.182:80
>> hpc.be.itu.edu.tr:80
>> static3-117-183.worldinternetworkcorporation.com:80
>> " | perl -MSocket -lne'
>> my $address = ( split /:/ )[ 0 ] or next;
>> my $number = inet_aton $address;
>> my $ip = inet_ntoa $number;
>> print "$address -> $ip";
>> '
>> 116.52.155.237 -> 116.52.155.237
>> ip-72-55-191-6.static.privatedns.com -> 72.55.191.6
>> 222.124.135.40 -> 222.124.135.40
>> 217.151.231.34 -> 217.151.231.34
>> 202.106.121.134 -> 202.106.121.134
>> 211.161.197.182 -> 211.161.197.182
>> hpc.be.itu.edu.tr -> 160.75.90.69
>> static3-117-183.worldinternetworkcorporation.com -> 203.145.117.183
>
> In my case, I also want the port number be preserved in the result,
> i.e.,
>
> ip-72-55-191-6.static.privatedns.com:3128
>
> should be converted into the following:
>
> 72.55.191.6:3128
>
> What revision should be done on the above code to achieve this aim?
perl -MSocket -lne'
my ( $address, $port ) = split /:/ or next;
my $number = inet_aton $address;
my $ip = inet_ntoa $number;
print "$address -> $ip:$port";
'
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
------------------------------
Date: Fri, 30 Jan 2009 05:17:00 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: Want to write a script to do the batch conversion from domain name to IP.
Message-Id: <h5Dgl.38632$1W7.33712@newsfe11.iad>
Hongyi Zhao wrote:
> On Fri, 30 Jan 2009 03:04:18 -0800, "John W. Krahn"
> <someone@example.com> wrote:
>> $ echo "
>> 116.52.155.237:80
>> ip-72-55-191-6.static.privatedns.com:3128
>> 222.124.135.40:80
>> 217.151.231.34:3128
>> 202.106.121.134:80
>> 211.161.197.182:80
>> hpc.be.itu.edu.tr:80
>> static3-117-183.worldinternetworkcorporation.com:80
>> " | perl -MSocket -lne'
>> my $address = ( split /:/ )[ 0 ] or next;
>> my $number = inet_aton $address;
>> my $ip = inet_ntoa $number;
>> print "$address -> $ip";
>> '
>> 116.52.155.237 -> 116.52.155.237
>> ip-72-55-191-6.static.privatedns.com -> 72.55.191.6
>> 222.124.135.40 -> 222.124.135.40
>> 217.151.231.34 -> 217.151.231.34
>> 202.106.121.134 -> 202.106.121.134
>> 211.161.197.182 -> 211.161.197.182
>> hpc.be.itu.edu.tr -> 160.75.90.69
>> static3-117-183.worldinternetworkcorporation.com -> 203.145.117.183
>
> Based on your code, I use the following lines in my case:
>
> #!/usr/bin/perl
> cat mydomain.txt | perl -MSocket -lne'
> my $address = ( split /:/ )[ 0 ] or next;
> my $number = inet_aton $address;
> my $ip = inet_ntoa $number;
> print "$address -> $ip";
> '
> Where, mydomain.txt include all of the domain names and IP addresses
> which I want to deal with. Then, I meet the error like this:
>
> Bad name after lne' at ./11.pl line 2.
>
> On the other hand, if I remove the first line, i.e.,
>
> #!/usr/bin/perl
>
> it will works.
>
> Why?
Because with that line Perl will try to run it and fail but without that
line the shell will run it successfully.
If you want to save the program in the file '11.pl' then use this:
#!/usr/bin/perl
use warnings;
use strict;
use Socket;
while ( <> ) {
chomp;
my ( $address, $port ) = split /:/ or next;
my $number = inet_aton $address;
my $ip = inet_ntoa $number;
print "$address:$port -> $ip:$port\n";
}
__END__
And then run it as:
./11.pl mydomain.txt
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
------------------------------
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 V11 Issue 2173
***************************************