[19134] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1329 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 18 18:15:41 2001

Date: Wed, 18 Jul 2001 15:15:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <995494519-v10-i1329@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 18 Jul 2001     Volume: 10 Number: 1329

Today's topics:
    Re: Removing .coms <pne-news-20010718@newton.digitalspace.net>
    Re: Removing .coms (Abigail)
    Re: Removing .coms (Abigail)
    Re: Removing .coms (Blstone77)
    Re: Replacing a specific line (Abigail)
    Re: Replacing a specific line (Craig Berry)
        Request for Comments ... ConvertColorspace.pm <mniles@itm.com>
    Re: Tail -f for NT <gregor.herrmann@eunet.at>
    Re: Tail -f for NT <krahnj@acm.org>
        timeout of gethostbyaddr and gethostbyname <schabernackel@hotmail.com>
    Re: timeout of gethostbyaddr and gethostbyname (Charles DeRykus)
    Re: trace function calls (Jennie)
    Re: trace function calls (Abigail)
    Re: Using a Perl module outside from Perl-dir? (Abigail)
    Re: Very Simple Socket Question (Jay Tilton)
    Re: Very Simple Socket Question <noemail@noemail.com>
    Re: Very Simple Socket Question (Jay Tilton)
    Re: Very Simple Socket Question <noemail@noemail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 18 Jul 2001 20:13:35 +0200
From: Philip Newton <pne-news-20010718@newton.digitalspace.net>
Subject: Re: Removing .coms
Message-Id: <5viblt4se5ai4i7k7ijurcfhmv5v88vcd7@4ax.com>

On 18 Jul 2001 13:38:11 GMT, blstone77@aol.com (Blstone77) wrote:

> 
> >$string =~ s/\.(com|net|org)//g;
> 
> This doesn't work, it does the same thing that my original substitution code
> did. namely, it removes the .com but leaves the domain. In other words,
> newbie.com becomes newbie. I am trying to remove the whole thing (newbie.com)
> or userplace.com when it is in a string such as a message.

Does it only include domains? Domain names can include only
[a-zA-Z0-9.-], so you should be able to

    $string =~ s/[a-zA-Z0-9.-]+\.(?:com|net|org)//g;

which should remove the longest contiguous substring (e.g.
subdomain.example.com and not just example.com).

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 18 Jul 2001 21:28:28 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Removing .coms
Message-Id: <slrn9lbvth.nor.abigail@alexandra.xs4all.nl>

Jay Tilton (tiltonj@erols.com) wrote on MMDCCCLXXVIII September MCMXCIII
in <URL:news:3b55a7e0.180285204@news.erols.com>:
:) On 18 Jul 2001 11:30:12 GMT, blstone77@aol.com (Blstone77) wrote:
:) 
:) >Newbie question. Does anyone know of a simple way to remove anything with the
:) >extentions .com, .org, or .net from a string? I tried substitution
:) >$string =~ s /s+.*?.com//sg;
:) >
:) >but this removes everything from first space. What am I missing, and is there a
:) >better way.
:) 
:) There are several mistakes.
:) 
:)    s/s+.*?.com//sg;
:)      ^ ^  ^     ^Useless unless you expect a newline to be
:)      ^ ^  ^      embedded within a domain name.
:)      ^ ^  ^Should be backslashed.
:)      ^ ^Matches anything including space. This is what's removing too much.
:)      ^Needs backslash.
:) 
:) Try this instead.
:) 
:)   $string =~ s/\s+\S*?\.(?:com|org|net)//g;


That would fail if a string starts with "foo.com", as there's no white-
space preceeding it. There's also no need to write '\S*?', the ? will
slow it down and if you have "foo.com.net", it will leave the ".net".
Not to mention that "gopher.commies.cu" will be translated to "mies.cu",
regardless whether you use '\S*' or '\S*?'.

Why not just:

    s/\S*\.(?:net|com|org)(?!\w)//g

Of course, if you have: "(foo.com)", this action will leave ")".
But that's due to the bad problem description "anything with the
extentions .com, .org, or .net". Where do anythings begin and end?


Abigail
-- 
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} #  Yet Another silly JAPH by Abigail
sub A::FETCH     {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}


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

Date: 18 Jul 2001 21:31:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Removing .coms
Message-Id: <slrn9lc02f.nor.abigail@alexandra.xs4all.nl>

Philip Newton (pne-news-20010718@newton.digitalspace.net) wrote on
MMDCCCLXXVIII September MCMXCIII in <URL:news:5viblt4se5ai4i7k7ijurcfhmv5v88vcd7@4ax.com>:
^^ On 18 Jul 2001 13:38:11 GMT, blstone77@aol.com (Blstone77) wrote:
^^ 
^^ > 
^^ > >$string =~ s/\.(com|net|org)//g;
^^ > 
^^ > This doesn't work, it does the same thing that my original substitution code
^^ > did. namely, it removes the .com but leaves the domain. In other words,
^^ > newbie.com becomes newbie. I am trying to remove the whole thing (newbie.com)
^^ > or userplace.com when it is in a string such as a message.
^^ 
^^ Does it only include domains? Domain names can include only
^^ [a-zA-Z0-9.-], so you should be able to
^^ 
^^     $string =~ s/[a-zA-Z0-9.-]+\.(?:com|net|org)//g;
^^ 
^^ which should remove the longest contiguous substring (e.g.
^^ subdomain.example.com and not just example.com).


And it will translate 'wais.netgods.mil' to 'gods.mil'.



Abigail
-- 
INIT  {print "Perl "   }  #  A pair of wolves watching
BEGIN {print "Just "   }  #  under a she-oak. The
END   {print "Hacker\n"}  #  Master departing.
CHECK {print "another "}


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

Date: 18 Jul 2001 21:34:02 GMT
From: blstone77@aol.com (Blstone77)
Subject: Re: Removing .coms
Message-Id: <20010718173402.19164.00000083@ng-fb1.aol.com>

>
>     ^ ^  ^      embedded within a domain name.
>     ^ ^  ^Should be backslashed.
>     ^ ^Matches anything including space. This is what's removing too much.
>     ^Needs backslash.


Thanks much, I'll learn this thing yet  ;)


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

Date: 18 Jul 2001 18:57:08 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Replacing a specific line
Message-Id: <slrn9lbn1o.nor.abigail@alexandra.xs4all.nl>

mc (nospam@home.com) wrote on MMDCCCLXXVIII September MCMXCIII in
<URL:news:3b550b57.388993515@news>:
)) On Tue, 17 Jul 2001 23:35:41 +0100, James Coupe <james@zephyr.org.uk>
)) wrote:
)) 
)) >In message <3b54ace7.364814287@news>, mc <nospam@home.com> writes
)) >>>                      if ($memsettings[($i-1)] != '') {
)) >>>                              print FILE "$memsettings[($i-1)]\n";
)) >>>                      } else {
)) >>>                              print FILE "\n";
)) >>>                      }
)) >>>
)) >>
)) >>Is this your actual code?  You're missing a closing double quote in
)) >>the first line above but I'd think this wouldn't get past the
)) >>compiler.
)) >
)) >The first line has two single quotes.
)) 
)) Oops.  Sorry about that.   In this font (MS Sans Serif), the two
)) single quotes look closer together than the marks in a single
)) double-quote!


Then you should use a better font!

6x13 doesn't have this problem.


Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


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

Date: Wed, 18 Jul 2001 20:51:56 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Replacing a specific line
Message-Id: <tlbtncibgfh3ac@corp.supernews.com>

Confused @ Times (confused@times.doh) wrote:
: Hi folks, I'm rather new to Perl, so forgive me idiocy I'm if missing 
: the obvious.
: 
: I want to replace a specific line in a text file with the current date, 
: however I first need to make sure the file contains the number of lines 
: I need (in this case 25).
: 
: If it's has less than 25 lines I need to write enough blank lines at the 
: end of the file and then write the current date on line 25.
: 
: If it has more than 25, I need to make sure I don't truncate the file.


: 
: Also, I need to make sure that the existing data in the file is 
: retained, so I'm loading the entire file into an array. I'm writing each 
: line back, as read (unless it's line 25) to a new file, but for some 
: reason only lines that start with numbers are being written.
: 
: Can a fresh pair of eyes take a look at my code and see what I'm doing 
: wrong?  Thanks in advance.
: 
: ------------------------
: sub WriteLastLogin {
: 
: # Open the existing user file and read it into an array
: 	fopen(FILE, "< $memberdir/$username.dat");
: 	@memsettings=<FILE>;
: 	fclose(FILE);

1) Always (always!!!) check the success of opening a file.
2) fopen/fclose, not open/close?  What are these?

: # Count the number of lines in the file
: 	$count = 0;
: 	foreach (@memsettings) {
: 		$_ =~ s~[\n\r]~~g;
: 		$count++;
: 	}

  chomp @memsettings;
  $count = @memsettings;

seems a bit easier. :)  Note that an array evaluated in scalar context
returns the number of items it contains.

: # If there are fewer lines in the profile than the line number for storing the 
: # last login, set the number of to be written to the profile to the same number 
: # as the line number for the last login (does that make sense?) =)
: 	if ($count < 25) { $count = 25}

Why not just push some blank lines onto the end of the array to bring it
up to 23?  (Item 24, 0-indexed, will be the time line.)

  push @memsettings, ('') x (23 - $count) if $count < 23;

: # Open the file for writing
: # TODO: change filename from temp.dat to actual username file
: 	
: 	fopen(FILE, "+> $memberdir/temp.dat");
: 
: # Loop thru each line as long as it is not the last line
: 	for ($i = 1; $i <= $count; $i++) {
: 	
: # If the line being written is NOT the line for storing the last login 
: date, 
: # write the value originally read in
: 		if ($i != 25) {
: 
: # If the line in the array isn't blank, then write the array value 
: # otherwise, write a blank line
: # using ($i-1) to compensate for the array starting at zero.
: 			if ($memsettings[($i-1)] != '') {
: 				print FILE "$memsettings[($i-1)]\n";
: 			} else {
: 				print FILE "\n";
: 			}
: 
: # If the line being written IS the line for storing the last login date,
: # write the current date/time
: 		} else {
: 			print FILE "$date\n";
: 		}

Replace all that with:

  $memsettings[24] = "$date\n";
  print FILE @memsettings;

Note that both your version and (since I followed your lead) mine strip
the newline off all the memsettings lines, so you'll get one long line
containing all the original lines 1-24 with the date at the end, then a
newline, then all the original lines 26+ in another long line.  This
probably isn't what you want, I'd guess.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Brute force done fast enough looks slick."
   |             - William Purves


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

Date: Wed, 18 Jul 2001 14:01:59 -0700
From: Melissa Niles <mniles@itm.com>
Subject: Request for Comments ... ConvertColorspace.pm
Message-Id: <3B55F946.BAD2E0F1@itm.com>

This is a multi-part message in MIME format.
--------------1B83EEB8797F0ECB1346CE54
Content-Type: text/plain; charset=x-user-defined
Content-Transfer-Encoding: 7bit

I would like comments on the following module. It is not completed as of
yet.

It's purpose is to allow the retrieval of colorspace values from a
different set of colorspace values, ie: get CMYK values from a set of
RGB values.

As far as I can find, there's no other module like it, but I have seen
others with a need for this sort of module.

As you are sure to see, this is the first perl module that I have
written, and would like suggestions/comments on making it better. The
main portion is included as text, and the full module is attached.

Thank you,

Melissa



package ConvertColorspace; # for testing
#package Image::ConvertColorspace;

# Copyright (c) 2001 Melissa Niles. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.

use strict;
use vars qw($VERSION);
$VERSION = "0.58";  # $Date: 2001/07/18 12:50:21 $

sub rgb2cmyk {
        my $self  = shift;
        my $class = ref($self) || $self;

        my ($r,$g,$b) = @_;

        #turn RGB values into decimal...
        $r = sprintf("%1.2f", $r/254);
        $g = sprintf("%1.2f", $g/254);
        $b = sprintf("%1.2f", $b/254);


        my $C = 0.00;
        my $M = 0.00;
        my $Y = 0.00;
        my $K = 0.00;

        # find the lowest value minimun(R,G,B)
        $K = 1-$r;
        $K = 1-$g if 1-$g < $K;
        $K = 1-$b if 1-$b < $K;

        $K = sprintf("%1.2f", $K);
        $C = sprintf("%1.2f", (1-$r-$K)/(1-$K));
        $M = sprintf("%1.2f", (1-$g-$K)/(1-$K));
        $Y = sprintf("%1.2f", (1-$b-$K)/(1-$K));
        $K = 0 if $K < 0; # adjust if neg number?

        return $C,$M,$Y,$K;
}

return 1;

__END__
--------------1B83EEB8797F0ECB1346CE54
Content-Type: text/plain; charset=x-user-defined;
 name="ConvertColorspace.pm"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ConvertColorspace.pm"

package ConvertColorspace;
#package Image::ConvertColorspace;

# Copyright (c) 2001 Melissa Niles. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.

use strict;
use vars qw($VERSION);
$VERSION = "0.58";  # $Date: 2001/07/18 12:50:21 $

sub rgb2cmyk {
	my $self  = shift;
	my $class = ref($self) || $self;

	my ($r,$g,$b) = @_;

	#turn RGB values into decimal...
	$r = sprintf("%1.2f", $r/254);
	$g = sprintf("%1.2f", $g/254);
	$b = sprintf("%1.2f", $b/254);


	my $C = 0.00;
	my $M = 0.00;
	my $Y = 0.00;
	my $K = 0.00; 
  
  	# find the lowest value minimun(R,G,B)
	$K = 1-$r;
	$K = 1-$g if 1-$g < $K;
	$K = 1-$b if 1-$b < $K;
  
	$K = sprintf("%1.2f", $K);
	$C = sprintf("%1.2f", (1-$r-$K)/(1-$K));
	$M = sprintf("%1.2f", (1-$g-$K)/(1-$K));
	$Y = sprintf("%1.2f", (1-$b-$K)/(1-$K));
	$K = 0 if $K < 0; # adjust if neg number?

	return $C,$M,$Y,$K;
}

return 1;

__END__

=head1 NAME

Image::ConvertColorspace - Colorspace value conversion

=head1 SYNOPSIS

use Image::ConvertColorspace;

($c,$m,$y,$k) = ConvertColorspace::rgb2cmyk($r,$g,$b);

=head1 DESCRIPTION

The purpose of this module is to provide the values of one colorspace when converted from another
colorspace. For example get the CMYK values for a set of RGB values.

=over 4

=item rgb2cmyk

Convert RGB values into CMYK. RGB values (0..254) are converted into RGB decimal (0;1) and output is
CMYK decimal (0;1).

=back

=head1 INFORMATION

Conversion information provided by the Color Space FAQ written by David Bourgin
which can be found on the B<comp.graphics> newsgroup, it is also available on B<rtfm.mit.edu>
as /pub/usenet/news.answers/graphics/colorspace-faq,  and at:

B<http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html>

=head1 BUGS

Many, I'm sure.
Add error checking.

=head1 TODO

Many.

Add more conversion routines. Only RGB -> CMYK is available now.

=head1 COPYRIGHT

Copyright 2001 Melissa Niles. All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

Melissa Niles (mniles@itm.com)

=cut


--------------1B83EEB8797F0ECB1346CE54--



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

Date: Wed, 18 Jul 2001 20:07:32 +0200
From: gregor herrmann <gregor.herrmann@eunet.at>
Subject: Re: Tail -f for NT
Message-Id: <3b55cc75.11520896@gregoa.austria.eu.net>

On 18 Jul 2001 06:17:39 -0700, Buck Turgidson wrote:

> I have been searching perldocs and newsgroups for a workable version
> of tail for NT.  I couldn't get the stuff that I did find to work.

the AINTX tools contain a tail too:
http://maxx.mc.net/~jlh/nttools/html/nttools.htm
  
gregor
-- 
http://members.eunet.at/gregor.herrmann/ | pgp-key:
http://certserver.pgp.com:11371/pks/lookup?op=get&search=0x00F3CFE4
member of https://www.vibe.at/ | how to reply: http://learn.to/quote/
infos zur usenet-hierarchie at.*: http://www.usenet.at/


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

Date: Wed, 18 Jul 2001 20:24:56 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Tail -f for NT
Message-Id: <3B55F0E8.C1F76223@acm.org>

Buck Turgidson wrote:
> 
> I have been searching perldocs and newsgroups for a workable version
> of tail for NT.  I couldn't get the stuff that I did find to work.
> 
> Does anyone have a simple way of doing tail -f on NT?

http://www.perl.com/language/ppt/src/tail/index.html



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 18 Jul 2001 18:26:38 GMT
From: Haber Schabernackel <schabernackel@hotmail.com>
Subject: timeout of gethostbyaddr and gethostbyname
Message-Id: <1105_995481181@f3bpc14>


I use these sub's to convert between, say 208.201.239.56 and www.perl.com:


print hostname_to_ipnumber("www.perl.com")."\n"; # 208.201.239.56

sub ipnumber_to_hostname{ gethostbyaddr(pack("C4",split("\\.",shift)),2) }
sub hostname_to_ipnumber{ join(".",unpack("C4",gethostbyname(shift))) }
 


But sometimes the sub's hangs "forever", often up to a minute.
How can i make them time out after 5 seconds?
(I'm not interested in the result if it takes longer to find it).





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

Date: Wed, 18 Jul 2001 21:18:45 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: timeout of gethostbyaddr and gethostbyname
Message-Id: <GGotv9.3p0@news.boeing.com>

In article <1105_995481181@f3bpc14>,
Haber Schabernackel  <schabernackel@hotmail.com> wrote:
>
>I use these sub's to convert between, say 208.201.239.56 and www.perl.com:
>
>
>print hostname_to_ipnumber("www.perl.com")."\n"; # 208.201.239.56
>
>sub ipnumber_to_hostname{ gethostbyaddr(pack("C4",split("\\.",shift)),2) }
>sub hostname_to_ipnumber{ join(".",unpack("C4",gethostbyname(shift))) }
> 
>
>
>But sometimes the sub's hangs "forever", often up to a minute.
>How can i make them time out after 5 seconds?
>(I'm not interested in the result if it takes longer to find it).
>

Sometimes wrapping with a block eval and using an alarm will work. 

perldoc -f alarm for an example.

--
Charles DeRykus


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

Date: 18 Jul 2001 11:40:45 -0700
From: ef-foto@softhome.net (Jennie)
Subject: Re: trace function calls
Message-Id: <86d749c8.0107181040.5934d475@posting.google.com>

Hi
look my web-site
 
Jennie

http://www.arttradeinternational.com


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

Date: 18 Jul 2001 19:02:01 GMT
From: abigail@foad.org (Abigail)
Subject: Re: trace function calls
Message-Id: <slrn9lbnau.nor.abigail@alexandra.xs4all.nl>

Gary Baker (bakerg@volpe.dot.gov) wrote on MMDCCCLXXVIII September
MCMXCIII in <URL:news:3580d191.0107180509.6cf46760@posting.google.com>:
;; I have a very large web application and would like to somehow create a list
;; ( automatically of course ) of javascript functions with the functions they
;; are calling and functions that call them
;; 
;; something like this :
;; 
;; function firstFunc(x,y,z)
;; 	calls :
;; 		ninthFunc()
;; 		eleventhFunc()
;; 	called by :
;; 		fifthFunc()
;; 		seventhFunc()
;; 
;; function ninthFunc()
;; 	calls:
;; 		tenthFunc()
;; 	called by :
;; 		firstFunc()
;; 
;; 
;; Any ideas?


Sure.


Write a Javascript parser.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: 18 Jul 2001 18:59:39 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Using a Perl module outside from Perl-dir?
Message-Id: <slrn9lbn6g.nor.abigail@alexandra.xs4all.nl>

T.Hopkins (boa@freemail.c3.hu) wrote on MMDCCCLXXVIII September MCMXCIII
in <URL:news:3b576f36.1589811@news.matav.hu>:
$$ Hi guys,
$$ how can I use a module (in my case: File::ReadBackwards.pm) from my
$$ own 'cgi-bin' (or other) directory directly that is not installed on
$$ the ISP's server?

You'd read the FAQ.

$$ Our ISP is an ugly face and lazy to install this module.

And I guess that makes you an ugly face too as you're too lazy to
switch ISPs.


Abigail
-- 
BEGIN {my $x = "Knuth heals rare project\n";
       $^H {integer} = sub {my $y = shift; $_ = substr $x => $y & 0x1F, 1;
       $y > 32 ? uc : lc}; $^H = hex join "" => 2, 1, 1, 0, 0}
print 52,2,10,23,16,8,1,19,3,6,15,12,5,49,21,14,9,11,36,13,22,32,7,18,24;


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

Date: Wed, 18 Jul 2001 18:14:40 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Very Simple Socket Question
Message-Id: <3b55d066.190661019@news.erols.com>

On Wed, 18 Jul 2001 17:47:27 GMT, "Thing" <noemail@noemail.com> wrote:

>great, it works, just one note, what does the "print; # prints $_" do ?

*chuckle*  That one's going in the scrapbook.

The '#' begins a comment that extends to the end of the line.
In this case, the comment is telling you what the statement does.
It prints the value of $_.



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

Date: Wed, 18 Jul 2001 18:23:44 GMT
From: "Thing" <noemail@noemail.com>
Subject: Re: Very Simple Socket Question
Message-Id: <Quk57.1589$Po6.133056@newsread2.prod.itd.earthlink.net>

omg this is so confusing, i write VB code where things are a lot less
cryptic.  WTF is $_ ???

"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3b55d066.190661019@news.erols.com...
> On Wed, 18 Jul 2001 17:47:27 GMT, "Thing" <noemail@noemail.com> wrote:
>
> >great, it works, just one note, what does the "print; # prints $_" do ?
>
> *chuckle*  That one's going in the scrapbook.
>
> The '#' begins a comment that extends to the end of the line.
> In this case, the comment is telling you what the statement does.
> It prints the value of $_.
>




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

Date: Wed, 18 Jul 2001 18:52:46 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Very Simple Socket Question
Message-Id: <3b55d8ce.192813219@news.erols.com>

On Wed, 18 Jul 2001 18:23:44 GMT, "Thing" <noemail@noemail.com> wrote:

>omg this is so confusing, i write VB code where things are a lot less
>cryptic.  WTF is $_ ???

Anno's original post explained that.  Quoting a piece from it...

>    while ( <$new_sock> )
>
>[...]the line it has read is now in $_.

Many perl operators and functions use this kind of implicit argument.
A look through perlvar, included with your perl documentation, may be
helpful.


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

Date: Wed, 18 Jul 2001 19:26:11 GMT
From: "Thing" <noemail@noemail.com>
Subject: Re: Very Simple Socket Question
Message-Id: <npl57.1696$Po6.141704@newsread2.prod.itd.earthlink.net>

ugh, thanks for taking the time, i did read that, but it doesnt stick when
you dont use or understand it.  its hard for me to picture using and
underscore as a variable name, and also if you just type print; then the $_
is implied i guess.  so i guess im going to think of it as keyword or
something...or a return var or something, i dunno...very odd...

> >omg this is so confusing, i write VB code where things are a lot less
> >cryptic.  WTF is $_ ???
>
> Anno's original post explained that.  Quoting a piece from it...
>
> >    while ( <$new_sock> )
> >
> >[...]the line it has read is now in $_.
>
> Many perl operators and functions use this kind of implicit argument.
> A look through perlvar, included with your perl documentation, may be
> helpful.




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

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.  

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


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