Re: localtime
use POSIX's function strftime: perl -le 'use POSIX qw/strftime/;$time = strftime "%Y%m%d",localtime; print $time' --- On Wed, 10/6/09, Rick wrote: > From: Rick > Subject: localtime > To: "Perl Beginners" > Received: Wednesday, 10 June, 2009, 9:55 AM > below is working code but is there > way to shorten this code in more perlish way? > > my($DAY, $MONTH , $YEAR ) = (localtime)[3,4,5]; > > my $day = sprintf("%02d",$DAY); > my $month = sprintf("%02d", ($MONTH + '1')); > my $year = sprintf("%04d", ($YEAR + '1900')); > > my $current_dir = join('', $year, $month, $day); > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
about system()
Hi, what's the difference between these two calling for system() function? system "command","-a","-b","-c"; system "command -a -b -c"; and, which is better? Thanks. Wah. Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: about system()
Thanks John and Chas. I have got it. Wah. --- On Fri, 12/6/09, John W. Krahn wrote: If there are no shell metacharacters > > > > in the argument, > it is split into words and passed directly > > ^^^ > to "execvp", > which is more efficient. > > ^ > > Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Request for code feedback
--- On Sat, 13/6/09, John W. Krahn wrote: > When you say > > $scalar = (2, 5, 7, 9); > > you’re using the comma operator in scalar > context, so it uses the > scalar comma operator. Here, what is the "scalar comma operator"? I can't understand for that. Thanks. Regards, Wah. Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
UDP port scanning with IO::Socket
Hello, Is it possible to implement an UDP port scanning with IO::Socket? I want to verify a remote UDP port is opened or not. Thanks. Access Yahoo!7 Mail on your mobile. Anytime. Anywhere. Show me how: http://au.mobile.yahoo.com/mail -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
about "\r\n" or "\n"
Hello, I created a script for checking HTTP like below: use strict; use IO::Socket; my $host = shift || '127.0.0.1'; my $port = shift || 80; my $sock=IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto=> 'tcp'); unless (defined $sock) { exit -1; } print $sock "GET / HTTP/1.0\n\n"; ... For above line, if the remote server OS is Windows, should I send "GET / HTTP/1.0\r\n\r\n" instead of "GET / HTTP/1.0\n\n" ? If yes, then the check script seems not useful, because before each checking, we must know what the OS of remote server is. Please give the suggestion. Thanks. Access Yahoo!7 Mail on your mobile. Anytime. Anywhere. Show me how: http://au.mobile.yahoo.com/mail -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: about "\r\n" or "\n"
Thanks John and others, I have got it, thank you. --- On Mon, 22/6/09, John W. Krahn wrote: > > According to RFC 2616 (http://www.rfc-editor.org/rfc/rfc2616.txt) the > end-of-line marker is CRLF which is not dependent on the > OS. > > AFAIK most TCP protocols use this end-of-line marker. > Access Yahoo!7 Mail on your mobile. Anytime. Anywhere. Show me how: http://au.mobile.yahoo.com/mail -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/