[19272] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1467 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 8 18:05:42 2001

Date: Wed, 8 Aug 2001 15:05:16 -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: <997308316-v10-i1467@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 8 Aug 2001     Volume: 10 Number: 1467

Today's topics:
    Re: $ENV{'HTTP_REFERER'} slash@dot.c.o.m.org
    Re: Another string manipulation question (Tad McClellan)
    Re: Another string manipulation question <sleddog@operamail.com>
    Re: Another string manipulation question <sleddog@operamail.com>
    Re: Another string manipulation question <ren@tivoli.com>
    Re: Another string manipulation question (Tad McClellan)
    Re: Another string manipulation question <sleddog@operamail.com>
    Re: copy files <goldbb2@earthlink.net>
        cross reference? <leary@foad.NOSPAM.org>
    Re: cross reference? (Malcolm Dew-Jones)
    Re: difference between using map {} or using CGI:: <patelnavin@icenet.net>
        FAQ: How do I determine whether a scalar is a number/wh <faq@denver.pm.org>
    Re: fd_set typemap <goldbb2@earthlink.net>
    Re: file existence w/ wild cards (Tad McClellan)
    Re: file existence w/ wild cards <bart.lateur@skynet.be>
    Re: FTP commands <gerard@NOSPAMlanois.com>
    Re: get rid of these leading zeros in Perl <ren@tivoli.com>
    Re: getting the name of a sub from a sub ref (Abigail)
    Re: how to validate a regular expression.. <goldbb2@earthlink.net>
    Re: Line counting in a file <joe+usenet@sunstarsys.com>
    Re: Line counting in a file <ren@tivoli.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 08 Aug 2001 22:00:51 GMT
From: slash@dot.c.o.m.org
Subject: Re: $ENV{'HTTP_REFERER'}
Message-Id: <3b71af23.7374703@news.freeserve.co.uk>

On Wed, 08 Aug 2001 15:45:45 GMT, Dan Wilga <dwilga-MUNGE@mtholyoke.edu> wrote:

>In article <3b70e8a6.48647218@news.freeserve.co.uk>, slash@dot.c.o.m.org 
>wrote:
>
>> If web site authors are 
>> not using
>> stylesheets to define the style of HTML pages these days they really should 
>> should
>> consider changing careers.
>
>If web site authors are not relying on style sheets, it may be because they 
>want to ensure the widest audience possible. By using both FONT tags (for what 
>they can control) and style sheets (for anything else) you're doing just that.
>
>When I design web pages, I try to make them viewable on everything from Lynx, 
>to Netscape 2 or 3, right up to the latest browser versions. Relying too 
>heavily on CSS makes the experience of users with older browsers less than 
>ideal.

There is a push to force people to upgrade at the moment, and I'm all for it. I work
with a team designing websites and web applications using a variety of technologies
(Flash,Java,Javascript/dHTML,Perl) and to be honest anyone who's bothered upgrading
their browser in the last 4 years should be able to see the vast majority of our
work. My Granny is 79 years old, and has IE5 on a Mac for christ-sakes!

I do ensure that people using browsers such as Lynx can see the content, as any
properly designed page should degrade gracefully, (and I myself use lynx to quickly
find and download files on the odd occasion) but I make no distinction between Lynx
and Netscape 2/3 - they can still see the content, properly formatted sans color or
font styles (the <h1></h1> <p></p> etc tags can be used over-ridden by CSS of
course).

Since IE4/5, Opera 4/5, Mozilla, WebTV and Netscape 4/6 (all CSS browsers) account
for virtually all web users there's no point designing a site to cater especially for
the 3 or 4 people bumbling around with Netscape 2 (I've designed and administer
several (large) sites (and by large, I'm talking over 1 million hits per day in one
case), and there just isn't any traffic from these old browsers even though they
could view the content.) 

There has to be a cut-off point, otherwise shop doorways would be 8 feet high in case
the tallest man in the world happened to call in, every gents toilet would have 100
urinals at different heights and we'd still have betamax VCRs in the stores.

As I say, most of the old tags are deprecated, and will hopefully soon disappear
altogether the way many old tags already have. I'm not as extreme as some, who favour
100% flash sites, or nothing but shockwave/Java/dHTML for everything, but I can't
understand people pandering to a few throwback browsers. Well, I can understand in
some cases - it's because some authors need an excuse to give the client when
presenting a poorly designed and ugly looking site "Sure, it looks shit with IE5.5,
but it DOES work with IE2, unlike the competition's attractive and interesting
sites!".



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

Date: Wed, 8 Aug 2001 13:03:34 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Another string manipulation question
Message-Id: <slrn9n2s76.n5u.tadmc@tadmc26.august.net>

Jasper McCrea <jasper@guideguide.com> wrote:
>Jasper McCrea wrote:
>> Jasper McCrea wrote:
>> > Tad McClellan wrote:
>> > > Doug Robbins <sleddog@operamail.com> wrote:

>> > > >Get's trickier
>> > > >when we get to 12:00...
>> > >
>> > > Only because of the need to switch between AM/PM (and that
>> > > is when the time is 11:00, not 12:00):
>> > >

>Saying the AM/PM change occurs at 11:00 is very misleading. 


You are right.

I should have instead said "the AM/PM change occurs at 11, not at 12":

   12:xx PM =>  01:xx PM         # no AM/PM change

   11:xx PM =>  12:xx AM         # AM/PM change required


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 08 Aug 2001 18:26:39 GMT
From: Doug Robbins <sleddog@operamail.com>
Subject: Re: Another string manipulation question
Message-Id: <MPG.15db639d2bbc0c659896a2@news1.ns.sympatico.ca>

In article <9krl1i$i1b$1@mamenchi.zrz.TU-Berlin.DE>, anno4000
@lublin.zrz.tu-berlin.de says...
> According to Doug Robbins  <sleddog@operamail.com>:
> > I have a string like this (for example) whic a perl script is getting 
> > from a generated text file:
> > 
> > 03:00 PM EST
> > 
> > Problem is, the hour is off by one hour (slow). Hour can I increment 
> > the hour by one? In other words, when the original string contains 
> > 03:00 I want 04:00, when its 06:00 I want 07:00, etc. Get's trickier 
> > when we get to 12:00...
> > 
> > Of course I could simply replace 'EST' with 'CST' but that would be too 
> > easy :)
>  
> You can do that locally, without upsetting the time zone for anyone
> else:
> 
>     sub otherlocaltime {
>         local $ENV{ TZ} = shift if @_;
>         localtime();
>     }
> 
> Of course, $ENV{ TZ} could also be local to a whole script.
> 
> I'd only do that if the clock skew is accurately described by a time
> zone transition.  If you have a fixed offset of an hour, rather use
> "localtime( 60*60 + time())".
> 
> All this, of course, assumes you are getting the time in your program
> yourself, as opposed to reading time strings from an external source.
> 
> Anno
> 

The time *is* coming from an external source as a text string.

I'm digesting the rest of the responses and will get back to the thread 
will some results tonight... (that's 'tonight' NDT :)

Thanks all.

-- 
Doug Robbins


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

Date: Wed, 08 Aug 2001 19:35:34 GMT
From: Doug Robbins <sleddog@operamail.com>
Subject: Re: Another string manipulation question
Message-Id: <MPG.15db73c0dc22e5719896a3@news1.ns.sympatico.ca>

In article <3B717754.D02AFA10@guideguide.com>, jasper@guideguide.com 
says...

> I'd swap the two lines around, and make it
> 
>   s/^(\d+)/ sprintf "%02d", $1 % 12 + 1 /e;
>   s/([AP]M)/ $1 eq 'AM' ? 'PM' : 'AM' /e if /^12/;

The hour increments fine but I can't get the AM/PM switch working. 
Here's what I've got... please bear with this newbie :)

---Data file (CYBX.TXT) from outside source---
Blanc Sablon, Que., Canada (CYBX) 51-27N 057-11W 36M
Aug 07, 2001 - 03:00 PM EST / 2001.08.07 2000 UTC
Wind: from the SSW (210 degrees) at 19 MPH (17 KT) gusting to 25 MPH 
(22 KT):0
Visibility: 2 1/2 mile(s):0
Sky conditions: overcast
Weather: mist
Temperature: 60 F (16 C)
Dew Point: 59 F (15 C)
Relative Humidity: 93%
Pressure (altimeter): 29.39 in. Hg (995 hPa)
ob: CYBX 072000Z 21017G22KT 2 1/2SM BR BKN004 OVC025 16/15 A2939 RMK 
SF6SC2 SLP954
cycle: 20
---End data file---

---My test script---
#!/usr/bin/perl
open(FILE,"CYBX.TXT")||die("Cannot open file!");
@lines=<FILE>;
close(FILE);
foreach $i (@lines) {
   if (grep(/UTC\n/, $i) eq "1") {
       $i =~ s/ \/.*//g; # Strip off the UTC time part
       ($date, $time) = split(/ - /,$i);
       $origtime = $time; # Just for test printing below
       $time =~ s/^(\d+)/ sprintf "%02d", $1 % 12 + 1 /e;
       $time =~ s/([AP]M)/ $1 eq 'AM' ? 'PM' : 'AM' /e if /^12/;
   }
}
print "Content-type: text/html\n\n";
print "<p>Unadjusted: $origtime\n<br>Adjusted: $time\n";
---End test script---

Regardless how I play with the time in the original datafile (setting 
it to 11:00 PM, 12:00 PM, 11:00 AM, etc., the AM/PM of the adjusted 
time doesn't change.
 
-- 
Doug Robbins


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

Date: 08 Aug 2001 14:43:15 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Another string manipulation question
Message-Id: <m3r8umcp7w.fsf@dhcp9-161.support.tivoli.com>

On Wed, 08 Aug 2001, sleddog@operamail.com wrote:

>        $time =~ s/^(\d+)/ sprintf "%02d", $1 % 12 + 1 /e;
>        $time =~ s/([AP]M)/ $1 eq 'AM' ? 'PM' : 'AM' /e if /^12/;

The "if /^12/" part needs to be "if $time =~ /^12/".

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 8 Aug 2001 15:57:37 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Another string manipulation question
Message-Id: <slrn9n36dh.np3.tadmc@tadmc26.august.net>

Doug Robbins <sleddog@operamail.com> wrote:
>In article <3B717754.D02AFA10@guideguide.com>, jasper@guideguide.com 
>says...
>
>> I'd swap the two lines around, and make it
>> 
>>   s/^(\d+)/ sprintf "%02d", $1 % 12 + 1 /e;
>>   s/([AP]M)/ $1 eq 'AM' ? 'PM' : 'AM' /e if /^12/;
>
>The hour increments fine but I can't get the AM/PM switch working. 
>Here's what I've got... please bear with this newbie :)


>Aug 07, 2001 - 03:00 PM EST / 2001.08.07 2000 UTC

>#!/usr/bin/perl


You should *always* enable warnings when developing Perl code.

It would have helped you to find the problem yourself...

   #!/usr/bin/perl -w
   use strict;

Enable strictures too. We want all the help that we can get.


>open(FILE,"CYBX.TXT")||die("Cannot open file!");
>@lines=<FILE>;
>close(FILE);
>foreach $i (@lines) {


Why waste memory by holding the entire file in memory?

You are processing it line-by-line, so why not read it line-by-line?

   while ( my $line = <FILE> ) {  # one-char variable names suck


>       $time =~ s/([AP]M)/ $1 eq 'AM' ? 'PM' : 'AM' /e if /^12/;


You would have gotten an "uninitialized value" warning on that
line if you had asked for one.

That final pattern match is against the $_ variable, you want
to bind it to $time instead:

   $time =~ s/([AP]M)/ .../e if $time =~ /^12/;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 08 Aug 2001 21:15:24 GMT
From: Doug Robbins <sleddog@operamail.com>
Subject: Re: Another string manipulation question
Message-Id: <MPG.15db8b2ae5a95aac9896a4@news1.ns.sympatico.ca>

All is well. Thanks for the help... and the lesson :)

-- 
Doug Robbins


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

Date: Wed, 08 Aug 2001 16:52:13 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: copy files
Message-Id: <3B71A67D.84F40A3C@earthlink.net>

pourki wrote:
> 
> Hello there!
> I've got 3 questions about copying and deleting files:
> 
> use File::Copy
> 
> 1. copy("dirPath1/x*"; "dirPath2"); ?
> 2. copy("dirPath/*x"; "dirPath2"); ?
> 3. chdir("dirPath");  unlink(<*>);
> 
> The statements 1&2 are wrong.What is the correct form for them?
> Can i write the 2 stataments under 3 in just one
> statement?

copy($_, "dirPath2") for(glob("dirPath/x*"));
copy($_, "dirPath2") for(glob("dirPath1/*x"));
unlink($_) for(glob("dirPath/*"));

You can combine the first two to:
copy($_, "dirPath2") for(glob("dirPath/x*"), glob("dirPath1/*x"));

You really should also include error checking:
for( glob("dirPath/x*"), glob("dirPath1/*x") ) {
	copy($_, "dirPath2") or die "Couldn't copy $_ : $!\n";
}
for( glob("dirPath/*") ) {
	unlink($_)  or die "Couldn't unlink $_ : $!\n";
}

-- 
I need more taglines. This one is getting old.


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

Date: Wed, 8 Aug 2001 16:13:20 -0500
From: "Leary" <leary@foad.NOSPAM.org>
Subject: cross reference?
Message-Id: <yWhc7.5075$V43.395422@e3500-atl1.usenetserver.com>

Is there such an animal as a cross reference of the sort;
in dos you could do this;
    for /f "tokens=1-3 delims=," %%g in (testdata.txt) do (some stuff)
in perl you would accomplish this by;
    blah blah...

any such site  out there?





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

Date: 8 Aug 2001 14:50:58 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: cross reference?
Message-Id: <3b71b442@news.victoria.tc.ca>

Leary (leary@foad.NOSPAM.org) wrote:
: Is there such an animal as a cross reference of the sort;
: in dos you could do this;
:     for /f "tokens=1-3 delims=," %%g in (testdata.txt) do (some stuff)
: in perl you would accomplish this by;
:     blah blah...


Unfortunately, being a perl programmer who only dabbles in NT, it is not
clear what the "for /f..." is doing.

If you explain what this does then I'm sure someone could show a simple
example of doing it in perl. 



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

Date: Thu, 9 Aug 2001 00:53:27 +0530
From: "Aman Patel" <patelnavin@icenet.net>
Subject: Re: difference between using map {} or using CGI::
Message-Id: <9ks3h6$67flc$1@ID-93885.news.dfncis.de>

try using POST method, and include hidden fields, and some <textarea>'s
You'll see some unexpected results...

PS: only check the %params hash variable, if you use the debugging methods
of CGI.pm like Dump() and others, they return correct results...

"gnari" <gnarinn@hotmail.com> wrote in message
news:997220598.554921558592469.gnarinn@hotmail.com...
> In article <9kp5in$5m5ko$2@ID-93885.news.dfncis.de>,
> Aman Patel <patelnavin@icenet.net> wrote:
> >Whats the exact difference between:
> >
> ># I want all CGI form parameters to be in %params hash
> >use CGI qw(:standard);
> >my $query = new CGI; my %params;
> >for ($query->param()) {
> >    $params{$_}=$query->param($_);
> >}
> >
> >AND:
> >use CGI qw(:standard);
> >my $query = new CGI;
> >my %params = map {$_ => $query->param($_)} $query->param();
> >
> >You might say that the later one is brief. But there is actually a
technical
> >difference between the two methods of "filling" %params. I dont know
what,
> >but when i executed under different post methods. The first one wored.
The
> >later one yeilded really really unexpected results. (FORM Method was
POST).
> >
>
> really? what input? what results?
> seems reasonable to me.
>
> although there is always:
>   use CGI qw(Vars);
>   my %params=Vars();
>
> gnari




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

Date: Wed, 08 Aug 2001 18:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I determine whether a scalar is a number/whole/integer/float?
Message-Id: <wmfc7.142$T3.170725376@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How do I determine whether a scalar is a number/whole/integer/float?

    Assuming that you don't care about IEEE notations like "NaN" or
    "Infinity", you probably just want to use a regular expression.

       if (/\D/)            { print "has nondigits\n" }
       if (/^\d+$/)         { print "is a whole number\n" }
       if (/^-?\d+$/)       { print "is an integer\n" }
       if (/^[+-]?\d+$/)    { print "is a +/- integer\n" }
       if (/^-?\d+\.?\d*$/) { print "is a real number\n" }
       if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal number" }
       if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)
                            { print "a C float" }

    If you're on a POSIX system, Perl's supports the "POSIX::strtod"
    function. Its semantics are somewhat cumbersome, so here's a "getnum"
    wrapper function for more convenient access. This function takes a
    string and returns the number it found, or "undef" for input that isn't
    a C float. The "is_numeric" function is a front end to "getnum" if you
    just want to say, ``Is this a float?''

        sub getnum {
            use POSIX qw(strtod);
            my $str = shift;
            $str =~ s/^\s+//;
            $str =~ s/\s+$//;
            $! = 0;
            my($num, $unparsed) = strtod($str);
            if (($str eq '') || ($unparsed != 0) || $!) {
                return undef;
            } else {
                return $num;
            } 
        } 

        sub is_numeric { defined getnum($_[0]) } 

    Or you could check out the String::Scanf module on CPAN instead. The
    POSIX module (part of the standard Perl distribution) provides the
    "strtod" and "strtol" for converting strings to double and longs,
    respectively.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           04.69
-- 
    This space intentionally left blank


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

Date: Wed, 08 Aug 2001 16:38:39 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: fd_set typemap
Message-Id: <3B71A34F.763E74FE@earthlink.net>

Glenn MacGregor wrote:
> 
> Hi All,
> 
> I am writing a perl module based on a c lib I write.  I am using XS
> (h2xs) to do this.  I have a function in the c lib that I need to
> implement in the perl module, that function takes as an argument
> fd_set *, does anyone know how to translate an fd_set * or fd_set from
> c to perl?

Use a string, initially empty, and use vec to set or clear it.

my $flags = '';
vec( $flags, 1, fileno $socket ) = 1;
my $nready = select( $flags, undef, undef, $timeout );
if( vec( $flags, 1, fileno $socket ) == 1 ) {
	sysread( $socket, $buffer, 4096, length $buffer );
}

You would be better off using IO::Select, though:
my $select = IO::Select->new( $socket );
my @ready = $select->can_read( $timeout );
if( grep { $_ eq $socket } @ready ) {
	sysread( $socket, $buffer, 4096, length $buffer );
}

-- 
I need more taglines. This one is getting old.


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

Date: Wed, 8 Aug 2001 13:16:17 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: file existence w/ wild cards
Message-Id: <slrn9n2sv1.n5u.tadmc@tadmc26.august.net>

Hubert Pan <hpan@stanford.edu> wrote:
>
>so i figured out you can do a simple -e to find out if a file exists or
>not, but how could one use pattern matching 
                            ^^^^^^^^^^^^^^^^

"pattern matching" in a Perl neighborhood is going to be taken
as "regular expression" or "match operator".

What you are speaking of above is called "filename globbing".

They are not at all the same thing.


>for the query? like, if you
>wanted to know if any file has a name that starts with a specified
>string?

   my @starts_with_abc = <abc*>;
or
   my @starts_with_abc = glob 'abc*';  # better than the above
or
   my @starts_with_abc = grep /^abc/, <*>;  # or glob('*')


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 08 Aug 2001 19:44:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: file existence w/ wild cards
Message-Id: <ek53nt0vq5bucthur4h9pdhmtupv0kc72j@4ax.com>

Hubert Pan wrote:

>so i figured out you can do a simple -e to find out if a file exists or
>not, but how could one use pattern matching for the query? like, if you
>wanted to know if any file has a name that starts with a specified
>string?

Look into glob().

	@files = glob("abc*");

lists files with names starting with "abc".

-- 
	Bart.


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

Date: 08 Aug 2001 12:00:19 -0700
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: FTP commands
Message-Id: <ulmkufkcc.fsf@NOSPAMlanois.com>

Jeroen <jeroen.erkens@ing-barings.com> writes:

> I have read the documentation. I've also asked colleagues and searched
> the web. No luck. The documentation says stuff all:
> 
> $ftp->quot(cmd[,arg])
> Sends s literal FTP protocol command to the server and waits for a
> response. Returns the most significant digit of the response code.
> 
> 
> What is the response code and what does each value indicate? 


http://www.faqs.org/rfcs/rfc959.html

Scroll way down to section 4.2.


> Do I use
> $ftp->quot( "authenticate", "blargh"), 

From looking at the source code (Cmd::command), I think this is 
probably the form you want.  

Be warned that the word "authenticate" does not appear 
in the RFC, so I assume this is some kind of extension
command your particular flavor of FTP server supports?

Or maybe you need to submit this via the SITE command, so 
maybe you need to do this:

  $ftp->quot( "SITE", "authenticate", "blargh");

Maybe your FTP server's documentation has some information
on how to execute extension commands?

In any case, see the documentation for "SITE" in section
4.1.3 of the above referenced RFC.


> or $ftp->quot( "quote authenticate", "blargh") 

Nope.

> or $ftp->quot( "authenticate blargh") or ...

Nope.

> 
> I use the newsgroup as a last resort for help, not as a first 
> step in getting an answer.

Admittedly, the documentation for the libnet family is
a little thin, but the RFCs are there, and there is
always the source code (FTP.pm and Cmd.pm, its base class).

Good luck, and please followup when you figure it out.


-Gerard
http://www.geocities.com/gerardlanois/perl/




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

Date: 08 Aug 2001 15:04:58 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: get rid of these leading zeros in Perl
Message-Id: <m3itfyco7p.fsf@dhcp9-161.support.tivoli.com>

On Wed, 08 Aug 2001, brentdax1@earthlink.net wrote:

>>         $id1 =~ s/^0+(?=\d)//; # Safest general solution?
> 
> Or avoid the lookahead:
> 
>     $id1 =~ s/^0+(\d+)$/$1/; #actually, the end anchor is redundant,
>     but
> whatever...
> 
> Or avoid either the lookahead or the $1 (but with /e):
> 
>     $id =~ s/^0+/length($&) == length($id) ? 0 : ''/e;
> 
> TMTWODI...

FWIW, a quick benchmark has the lookahead version as almost twice as
fast as these other two....

-- 
Ren Maddox
ren@tivoli.com


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

Date: 8 Aug 2001 20:19:47 GMT
From: abigail@foad.org (Abigail)
Subject: Re: getting the name of a sub from a sub ref
Message-Id: <slrn9n37nv.vbm.abigail@alexandra.xs4all.nl>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCCXCIX
September MCMXCIII in <URL:news:9krf09$b6j$1@mamenchi.zrz.TU-Berlin.DE>:
:: According to John Imrie  <john.imrie@pa.press.net>:
:: > is it possible to extract the name of the subrouteen pointed to by a sub ref
:: 
:: In general, no.  It may not have one (an anonymous sub) or it may have
:: more than one (exported subroutines frequently do).  You could probably
:: do an exhaustive search of all symbol tables and see what you come up
:: with, but that's hardly worth the effort.
:: 
:: If the subroutine is currently running, caller(0) gives you the name it
:: was called as, if there is one.


Hmmpf. Two days ago I really, really hoped that was the case. But, alas,
it doesn't.


    #!/opt/perl/bin/perl 

    use strict;
    use warnings 'all';

    sub calvin {print +(caller (0)) [3], "\n"}

    *hobbes = *calvin;

    calvin ();
    hobbes ();

    __END__
    main::calvin
    main::calvin



Abigail
-- 
perl -Mstrict -we '$_ = "goto _.print chop;\n=rekcaH lreP rehtona tsuJ";_1:eval'


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

Date: Wed, 08 Aug 2001 17:51:16 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how to validate a regular expression..
Message-Id: <3B71B454.3D0FC9C7@earthlink.net>

Bart Lateur wrote:
> 
> Sarah Lin wrote:
> 
> >Hi there. how do i validate a regular expression that entered by the
> >user? perl will die if "(q1" is entered, and that's the thing i try
> >to avoid.. any PM for this? any help?
> >thanks.
> 
>         $pat = '(q1';
>         eval q["" =~ /$pat/];
>         # use $@ as a flag (true -> error) + error message
> 
> or
> 
>         eval q[ qr/$pat/ ];
> 
> It's even safe with patterns like
> 
>         $pat = '@{[print "Hello!\n"]}';

Maybe n this case it's safe, but eval EXPR is less efficient than eval
BLOCK, and it is MUCH too easy for someone to mess up (eg, if you
replaced q with qq it would suddenly become hideously unsafe).

I would suggest:
	eval { qr/$pat/ };
instead.  Unless you're on a mac, in which case I suggest:
	eval { "" =~ /$pat/ };

-- 
I need more taglines. This one is getting old.


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

Date: 08 Aug 2001 15:33:30 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Line counting in a file
Message-Id: <m3r8umcpo5.fsf@mumonkan.sunstarsys.com>

demerphq@hotmail.com (Yves Orton) writes:

> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote...

> > > select FILE;
> > 
> > Select doesn't do what you think it does.  It only influences output.
> > 
> > > while (<>) {}
> > > print $.;
> > > 
> > > Doesnt that work as well?
> > 
> > What happened when you tried it?
> > 
> > Anno
> 
> It printed out the correct number of lines.  Is there a point there
> anno? :-)

I think his point was that 

  select FILE;

has no obvious relation to the rest of your code.

> As for the select, I somehow thought that to get $. to refer to
> correct filehandle you had to select().  Upon RTM I realize I was
> wrong, all you have to do is read() or equiv. Sorry.
                               ^^^^^^

Wrong- read() and $. are unrelated.

> 
> Anyway try this
> 
> my $lines=0;
> open (IN,$0) || die $!;
> while (<IN>) {$lines++};
> print "$.\t$lines\n";
> 
> When I run it it prints out the same number twice, so why other with
> $lines?

Because $. is poorly documented and more of a nuisance 
than it is worth.  $. appears in clp.misc with far greater 
frequency than it does in real perl code. To get some feel for this, 
try running the following program on a unix box to see how $. is 
actually used-

#!/usr/bin/perl -wT
local %ENV;
use strict;
my $PERLDIR = "/usr/lib/perl5/";  # location of install directory
my $RE = '[^\\$\\\]\\$\\\.';      # shell-escaped regex for $.

my %file;                         # under-used hash of grepped results
my (@pod, @loc, @asn, @lval, @warn, @nov); # $. usage type

for (`grep -r $RE $PERLDIR`) {
    local ($a,$b) = split /:/, $_, 2; # filename:line split
    next unless defined $b;           # avoids binary file matches
    $a =~ s{^$PERLDIR}{};             # drops directory prefix from grep
    push @{$file{$a}}, $b;

    if ($a =~ m{\.pod|man/man\d}) {
        # manpages can have '::' in filenames,
        # which can screw up the prior $a,$b split
        push @pod, $_;
    }
    else {
        for ($b) {
            chomp;
            /local/        and push(@loc, $b), last;
            /=[^"]*\$\./   and push(@asn, $b), last;
            /warn\b.*\$\./ and push(@warn,$b), last;
            /\$\.\s*=/     and push(@lval,$b), last;

            push @nov, [$a,$b];
        }
    }
}

$. = 0; $. += @$_ foreach values %file;
printf <<EOT => map scalar @$_, \@pod, \@loc, \@asn, \@lval, \@warn, \@nov;
WARNING: Usage of \$. should be avoided whenever possible.
Of the $. lines it appears in my perl5 tree, most of them are completely
inane:

    %2d of them are for pod or man documentation (in poor condition),
    %2d are for polite localization (typically the file's sole usage of \$.),
    %2d are for reassigning \$. to a less obscure variable name.

Some (rarely discussed) but more sophisticated usage of \$. are:
    %2d use the lvalue property to set \$., and
    %2d of them are for generating line numbers in warning messages.

The remaining %d novel appearances of \$. in my perl5 tree are listed below.

EOT

{
    local $,="\n";
    print map { sprintf "Match %2d, from file %s:\n>> %s\n" =>
                              $_+1, @{$nov[$_]} } 0..$#nov;
}

__END__

-- 
Joe Schaefer    "When the end of the world comes, I want to be in Cincinnati.
                          Everything happens ten years later there."
                                               --Mark Twain



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

Date: 08 Aug 2001 14:25:03 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Line counting in a file
Message-Id: <m3zo9acq28.fsf@dhcp9-161.support.tivoli.com>

On 8 Aug 2001, demerphq@hotmail.com wrote:

> Ahhh.  Finally the cobwebs clear.  You are in pedantic mode. :-)  I
> should have said
> 
> while (<FILE>) {}
> 
> Oh, and if you do run the second bit of code I provided you will see
> that the point is valid even if the first bit of code was slightly
> inconsistent.
> 
> And you _knew_ what I meant anyway.
> 
> Yves ps (And yes it DOES work from the command line.  If you pipe a
> file to the script I provided before it works fine.)

Actually, that's not what he meant.  Your original code included a
"select FILE".  While that did not have the desired effect, it did
change the destination of unqualified prints.  So when you later did a
"print $.", the output simply vanished.

That's what Anno meant.

-- 
Ren Maddox
ren@tivoli.com


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

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


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