Re: How do I understand this HTTP::Request->new(GET => $url);

2007-02-11 Thread Jeff Pang
> If *GET =>$url* is a method invocation here, what is the operator => stands > for? '=>' is equal to ',' in perl,so you can write it as: HTTP::Request->new('GET',$url); Here both 'GET' and $url are the arguments of new(). >What's it context? list or scalar? > These are the basic concepti

Re: How do I understand this HTTP::Request->new(GET => $url);

2007-02-11 Thread Owen Cook
On Mon, Feb 12, 2007 at 03:31:01PM +0800, Spark Shen wrote: > Hi: > > I am a fresh bird on perl. :-) Could gurus help me to understand this > statement. > > *HTTP::Request->new(GET => $url);* > > How does perl parse the struct *GET => $url* here. > > I found out GET is a method defined in HTTP:

Re: How do I understand this HTTP::Request->new(GET => $url);

2007-02-11 Thread John W. Krahn
Spark Shen wrote: > Hi: Hello, > I am a fresh bird on perl. :-) Could gurus help me to understand this > statement. > > *HTTP::Request->new(GET => $url);* > > How does perl parse the struct *GET => $url* here. (GET => $url) is a list of two elements. It could also be written as ('GET', $url)

How do I understand this HTTP::Request->new(GET => $url);

2007-02-11 Thread Spark Shen
Hi: I am a fresh bird on perl. :-) Could gurus help me to understand this statement. *HTTP::Request->new(GET => $url);* How does perl parse the struct *GET => $url* here. I found out GET is a method defined in HTTP::Request::Common. If *GET => $url* is a method invocation here, what is the ope

Re: DOS to Windows format tr/\n\r\t/ /

2007-02-11 Thread Xavier Noria
On Feb 11, 2007, at 9:39 PM, [EMAIL PROTECTED] wrote: Well, here's my problem: I have found a way to wrap a text file down to a narrower column width. But it looses paragraph formatting. What I need is the same thing as converting a file from DOS (line break after each line) to Windows (line

Re: DOS to Windows format tr/\n\r\t/ /

2007-02-11 Thread vjp2
Well, here's my problem: I have found a way to wrap a text file down to a narrower column width. But it looses paragraph formatting. What I need is the same thing as converting a file from DOS (line break after each line) to Windows (line break after each paragraph) format, no? > From: [EMAIL P

Re: Pipe inside perl one liner

2007-02-11 Thread vjp2
No, I hope to fix that, but I want to avoid having to save it in files. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: find user name

2007-02-11 Thread Jorge Almeida
On Sun, 11 Feb 2007, Peter Scott wrote: On Sun, 11 Feb 2007 13:42:39 +, Jorge Almeida wrote: Is there some efficient way to get a user/group name out of a numerical uid/gid (in Linux)? Why, yes. perldoc -f getpwuid, perldoc -f getgrgid. Thank you. -- Jorge Almeida -- To unsubscribe, e

Re: find user name

2007-02-11 Thread Peter Scott
On Sun, 11 Feb 2007 13:42:39 +, Jorge Almeida wrote: > Is there some efficient way to get a user/group name out of a numerical > uid/gid (in Linux)? > Something like > $username=getusername($uid) > > (Of course, one can parse /etc/passwd, build a hash, etc. Is there > something like this

Re: Pipe inside perl one liner

2007-02-11 Thread Peter Scott
On Sun, 11 Feb 2007 00:38:02 +, vjp2 wrote: > I wonder if it is possibl to merge these two perl one liners inside one perl > one liners, by putting the pipe statement inside? > > speach () { cat $1 | perl -n00e'tr/\t\r\n/ /s; print qq($1\n) while > s/^(.{0,36}\S)\s+//;print qq(\n)' | perl -pe

Re: Please help with convoluted script

2007-02-11 Thread Dr.Ruud
Mathew Snyder schreef: > I need to make sure $day and $month are in 2-digit format Don't mix value and presentation. Variant-1: perl -wle' my $i = 0; my ($day, $month, $year) = map $_ + (0, 1, 1900)[$i++], (localtime)[3..5]; printf qq/%04d %02d %02d\n/, $year, $month, $day; '

find user name

2007-02-11 Thread Jorge Almeida
Is there some efficient way to get a user/group name out of a numerical uid/gid (in Linux)? Something like $username=getusername($uid) (Of course, one can parse /etc/passwd, build a hash, etc. Is there something like this ready to use?) -- Jorge Almeida -- To unsubscribe, e-mail: [EMAI

Re: DOS to Windows format tr/\n\r\t/ /

2007-02-11 Thread Xavier Noria
On Feb 11, 2007, at 1:36 AM, [EMAIL PROTECTED] wrote: I wonder if there is a format that preserves paragraph breaks while it kills line breaks? How do you define a paragraph break. Why does the subject mentions DOS to Windows. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For add

Pipe inside perl one liner

2007-02-11 Thread vjp2
I wonder if it is possibl to merge these two perl one liners inside one perl one liners, by putting the pipe statement inside? speach () { cat $1 | perl -n00e'tr/\t\r\n/ /s; print qq($1\n) while s/^(.{0,36}\S)\s+//;print qq(\n)' | perl -pe 'if ($.%4==2) {$_ .= qq(\n).(q(-) x 37).qq(\n)} elsif (

DOS to Windows format tr/\n\r\t/ /

2007-02-11 Thread vjp2
I wonder if there is a format that preserves paragraph breaks while it kills line breaks? speach () { cat $1 | perl -n00e'tr/\t\r\n/ /s; print qq($1\n) while s/^(.{0,36}\S)\s+//;print qq(\n)' | perl -pe 'if ($.%4==2) {$_ .= qq(\n).(q(-) x 37).qq(\n)} elsif ($.%4==0) {$_ .= qq(\n).(q(=) x 37).q

Re: Please help with convoluted script

2007-02-11 Thread Mathew Snyder
Rob Dixon wrote: > Mathew Snyder wrote: >> Tom Phoenix wrote: >>> On 2/9/07, Mathew <[EMAIL PROTECTED]> wrote: >>> I'm running this as a cron job 1 minute after midnight on Saturday nights (Sunday morning) so as to cover all of Saturday back through the previous Sunday. Does your su

Re: Please help with convoluted script

2007-02-11 Thread Owen
On Sun, 11 Feb 2007 03:51:17 -0500 Mathew Snyder <[EMAIL PROTECTED]> wrote: > Jeff Pang wrote: > >> #!/usr/bin/perl > >> > >> use warnings; > >> use strict; > >> > >> my @date = (localtime (time - (24*60*60)))[3..5]; > >> > >> foreach my $i (@date) { > >>print $i . "\n"; > >> } > >> >

Re: Please help with convoluted script

2007-02-11 Thread Rob Dixon
Mathew Snyder wrote: > Tom Phoenix wrote: >> On 2/9/07, Mathew <[EMAIL PROTECTED]> wrote: >> >>> I'm running this as a cron job 1 minute after midnight on Saturday >>> nights (Sunday morning) so as to cover all of Saturday back through the >>> previous Sunday. Does your suggestion mean I'd have t

Re: Please help with convoluted script

2007-02-11 Thread Jeff Pang
> >I need to make sure $day and $month are in 2-digit format so that wouldn't >work. > At least, not anyway I'm presently familiar with. I tried to use sprintf in >there but it failed because of not enough arguments. $day = '0' . $day if length($day) < 2; $month = '0' . $month if length($month

Re: Please help with convoluted script

2007-02-11 Thread Mathew Snyder
Owen wrote: > On Sun, 11 Feb 2007 03:18:00 -0500 > Mathew Snyder <[EMAIL PROTECTED]> wrote: > >> Tom Phoenix wrote: >>> On 2/9/07, Mathew <[EMAIL PROTECTED]> wrote: >>> I'm running this as a cron job 1 minute after midnight on Saturday nights (Sunday morning) so as to cover all of Saturd

Re: Please help with convoluted script

2007-02-11 Thread Owen
On Sun, 11 Feb 2007 03:18:00 -0500 Mathew Snyder <[EMAIL PROTECTED]> wrote: > Tom Phoenix wrote: > > On 2/9/07, Mathew <[EMAIL PROTECTED]> wrote: > > > >> I'm running this as a cron job 1 minute after midnight on Saturday > >> nights (Sunday morning) so as to cover all of Saturday back through th

Re: Please help with convoluted script

2007-02-11 Thread Mathew Snyder
Jeff Pang wrote: >> #!/usr/bin/perl >> >> use warnings; >> use strict; >> >> my @date = (localtime (time - (24*60*60)))[3..5]; >> >> foreach my $i (@date) { >>print $i . "\n"; >> } >> >> exit; >> >> I get this: >> >> 10 >> 1 >> 107 >> >> >> I still have to add 1 to the month. Is that r

Re: Please help with convoluted script

2007-02-11 Thread Jeff Pang
> >#!/usr/bin/perl > >use warnings; >use strict; > >my @date = (localtime (time - (24*60*60)))[3..5]; > >foreach my $i (@date) { >print $i . "\n"; >} > >exit; > >I get this: > >10 >1 >107 > > >I still have to add 1 to the month. Is that right? Also, the year still needs >to be fixed

Re: Please help with convoluted script

2007-02-11 Thread Mathew Snyder
Tom Phoenix wrote: > On 2/9/07, Mathew <[EMAIL PROTECTED]> wrote: > >> I'm running this as a cron job 1 minute after midnight on Saturday >> nights (Sunday morning) so as to cover all of Saturday back through the >> previous Sunday. Does your suggestion mean I'd have to run it late >> Sunday nigh