Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

perl m8

Name: Anonymous 2007-05-08 8:07 ID:JwUwwwvn

#!/usr/bin/perl -w

use LWP::Simple qw($ua get);

$ua->agent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3');

my @url = ("http://www.whatismyip.org"" target='_blank'>http://www.whatismyip.com","http://www.whatismyip.org";);
my $body = "";
my $exit = "";

print $url[0] . "\t(1)\n";
print $url[1] . "\t(2)\n";
print "Choose a website: ";
chop ($checker=<STDIN>);

if ($checker == 1){
    print "Checking: " . $url[0] . "\n";
    $body = get($url[0]);
}
if ($checker == 2){
    print "Checking: " . $url[1] . "\n";
    $body = get($url[1]);
    print "IP: " . $body;
    chop($exit=<STDIN>);
}
else{
    print "Choose either 1 or 2\n";
}
if($body =~ m/<TITLE>WhatIsMyIP.com -(.*?)<\/TITLE>/) {
    print "IP: " . $1;
    chop($exit=<STDIN>);
}

WHY DOES IT STILL
print "Choose either 1 or 2\n";

EVEN IF I CHOOSE 1! THANKS.

Name: Anonymous 2007-05-08 8:26 ID:Heaven

elsif

Name: Anonymous 2007-05-08 8:45 ID:8IC4OHJT

lol

explain what this insult to all perl users is supposed to do.

Name: Anonymous 2007-05-08 9:01 ID:Heaven

>>1
ELSIF YOU FAG

IF() {}
ELSIF() {}
ELSEIF() {}
ELSE {}

Name: Anonymous 2007-05-08 9:09 ID:8IC4OHJT

You don't do this with ifs in the first place.

$body=get($url[$checker] or print "Choose either 1 or 2\n" and exit)

Name: Anonymous 2007-05-08 9:31 ID:Heaven

>>5
bloated code

($body = get($url[$checker])) or print "Choose either 1 or 2\n" and exit;

Name: Anonymous 2007-05-08 9:35 ID:h81Chaz6

if ($checker eq "1") {

Name: Anonymous 2007-05-08 9:51 ID:g3mPz2uu

WHYYYYYYYYYYYYYY doesn't Perl have selects/switches/cases?

Name: Anonymous 2007-05-08 10:41 ID:8IC4OHJT

>>6
mine code checks if $url[$checker] is set, and exits in fot
your code first GETs link (even if it's empty string), then assigns result to $body, and only then exits if body is empty.
what is bloated again?

Name: Anonymous 2007-05-08 12:00 ID:NJmAENWC

>>8
Perl6 has

Name: Anonymous 2007-05-08 12:02 ID:NJmAENWC

>>8
Larry didn't want 'em

Name: Anonymous 2007-05-08 12:35 ID:3fKD8HPM

You can emulate switch in Perl5, but it's ugly: http://www.perl.com/doc/FMTEYEWTK/style/slide37.html

Name: Anonymous 2007-05-08 12:42 ID:oje2Uyo5

... but it's ugly
So, par for the course for Perl then.

Name: Anonymous 2007-05-08 13:52 ID:Heaven

>>12
for($somevar){
 /a/&&do{
  #do something here
  last;
 }
 /b/&&do{
  #do something else here
  last;
 }
 #do something for default case here
}


not much uglier than a switch in any other language... and it's a lot more flexible.

Name: Anonymous 2007-05-08 14:06 ID:NJmAENWC


use Switch;

switch ($somevar) {
    case 1: {
          # do something here
    }
    case /a/: {
          # do something else here
    }
    else {
         # do something for default case here
    }
}


pretty much the same as in any other language..


You can also do

use Switch qw(Perl6);

switch ($value) {
   when 1: { # do stuff }
   default: { # do stuff }
}

Name: Anonymous 2007-05-08 14:29 ID:g6Su44GH

else for default? ewww

Name: Anonymous 2007-05-08 14:38 ID:8IC4OHJT

>>16
does it really bother you so much?

Name: Anonymous 2007-05-08 14:56 ID:g6Su44GH

>>17

No, not really. I just wanted to comment.

Name: Anonymous 2007-05-08 17:45 ID:Heaven

>>14
Does it need the 'do'? I thought plain
/b/ && {
    stuff;
}

worked.

Maybe I'm thinking of sh, though.

Name: Anonymous 2007-05-08 23:45 ID:8IC4OHJT

>>19
$ perl -e "//&&{print qq{hello\n}}"
hello
$ perl -e "//&&{print qq{hello\n};print qq{world\n};}"
syntax error at -e line 1, near ";print"
Execution of -e aborted due to compilation errors.
$ perl -e "//&&do{print qq{hello\n};print qq{world\n};}"
hello
world

Name: Anonymous 2007-05-09 12:39 ID:HDEUARLh

Name: Anonymous 2007-05-10 12:41 ID:wfxNq8eu

STOP USING LWP

HAVE YOU LOOKED AT ITS INTERNALS AND THE HIDEOUS NETWORK OF MODULES (NET::, HTTP::, SPAGHETTI::) IT DEPENDS ON

once you see it, you will shit bricks.

Name: Anonymous 2007-05-10 12:46 ID:Heaven

i'd suggest doing `wget ...` instead.

Name: Anonymous 2007-05-10 13:09 ID:Xv5bqHo+

I don't know what this thread is about, but I found the following from my script directory:

#!/bin/sh

w3m -dump http://ipid.shat.net/iponly/

Name: Anonymous 2007-05-10 14:41 ID:zgk5Ns8m

Fuck wget, use bash.

exec 3<> /dev/tcp/dis.4chan.org/80 0<&3
(
        echo -ne "GET /prog/ HTTP/1.1\015\012"
        echo -ne "Host: dis.4chan.org\015\012"
        echo -ne "User-Agent: Mozilla/4.0 (compatible; bash/$BASH_VERSION)\015\012"
        echo -ne "Connection: close\015\012"
        echo -ne "\015\012"
) >&3
exec cat

Name: Anonymous 2007-05-10 14:44 ID:Heaven

>>25
ONE WORD, "\015\012", THREAD OVER.

Name: Anonymous 2007-05-10 17:02 ID:yc9mp8cB

>>25
godamn sancore perl

Name: Anonymous 2007-05-10 21:09 ID:zgk5Ns8m

>>26
What's really interesting about this is, discounting the trailing \0 at the end of the string, "\015\012" actually is a word by its technical definition.

Name: Anonymous 2007-05-11 11:04 ID:Heaven

>>28
That's not very interesting.

Name: Anonymous 2007-07-28 7:05 ID:NdvSMRz3

>>22

What's your alternative?

Name: Anonymous 2009-01-14 12:33

LISP

Name: Anonymous 2011-02-02 23:00

Name: Sgt.KabuﻜႩkimanꄽꍮ 2012-05-29 1:25

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List