[24700] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6857 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 11 21:06:11 2004

Date: Wed, 11 Aug 2004 18:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 11 Aug 2004     Volume: 10 Number: 6857

Today's topics:
    Re: "Undefined subroutine &main:: called." from nowhere <smurf@smurf.noris.de>
        Camel book: why invoke in the manner @{[&whowasi]}? <initiallast-name@yahoo.xyz>
    Re: Camel book: why invoke in the manner @{[&whowasi]}? <noreply@gunnar.cc>
        Cron Job manipulation through Web Page (siddhartha mulpuru)
    Re: Cron Job manipulation through Web Page <clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
    Re: favorite perl IDE <tadmc@augustmail.com>
    Re: favorite perl IDE <postmaster@castleamber.com>
    Re: favorite perl IDE <abigail@abigail.nl>
        My own handy Pocket Reference notes (please share your  (David Filmer)
        Net::SMTP woes <admin@asarian-host.net>
    Re: Net::SMTP woes <Joe.Smith@inwap.com>
    Re: Net::SMTP woes <admin@asarian-host.net>
    Re: Perl PDF modules - help please <tadmc@augustmail.com>
    Re: Reading next line, finding missing number in sequen <andrewpalmer@email.com>
    Re: Reading next line, finding missing number in sequen <Joe.Smith@inwap.com>
    Re: Reading next line, finding missing number in sequen <matthew.garrish@sympatico.ca>
    Re: split inconsistency- why? <Joe.Smith@inwap.com>
    Re: split inconsistency- why? <nospam-abuse@ilyaz.org>
    Re: SSL Tunneling <tim@vegeta.ath.cx>
    Re: Statistics for comp.lang.perl.misc <dha@panix.com>
    Re: Statistics for comp.lang.perl.misc <matthew.garrish@sympatico.ca>
    Re: Validating email addresses <Joe.Smith@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Aug 2004 21:41:43 +0200
From: Matthias Urlichs <smurf@smurf.noris.de>
Subject: Re: "Undefined subroutine &main:: called." from nowhere??
Message-Id: <pan.2004.08.11.19.41.42.282690@smurf.noris.de>

Hi, Matthias Urlichs wrote:

Addendum2:

> Time to recompile with debugging support. With my luck the problem will
> then go away.

debugperl -DltorDRJ reported:
[... LOTS ...]
(tools/dbdiff:449)      print
Exiting
(tools/dbdiff:449)      leave
(tools/dbdiff:0)        POPBLOCK scope 2 at pp_hot.c:1800
Leaving block 0, type BLOCK
(tools/dbdiff:0)        LEAVE scope 2 at pp_hot.c:1837
(tools/dbdiff:0)        LEAVE scope 1 at perl.c:2257
(tools/dbdiff:0)        Setting up jumplevel bffff5d0, was bffffa10
(tools/dbdiff:0)        ENTER scope 1 at perl.c:2126
(tools/dbdiff:0)        ENTER scope 2 at perl.c:2176
Entering block 0, type EVAL
(tools/dbdiff:0)        Setting up jumplevel bffff430, was bffff5d0

 ... and here it exits.

Interesting.  :-/


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

Date: Wed, 11 Aug 2004 22:01:57 GMT
From: "Suresh Govindachar" <initiallast-name@yahoo.xyz>
Subject: Camel book: why invoke in the manner @{[&whowasi]}?
Message-Id: <pHwSc.7018$54.107406@typhoon.sonic.net>

#!/use/bin/perl
BEGIN {(*STDERR = *STDOUT) || die;}
use diagnostics;
use warnings;
use strict;

=head
Hello,

In the 'Tying Hashes' section of the Camel book (pg 378+),
a subroutine called whowasi is invoked in the
following two ways,

      1)  @{[&whowasi]}
and   2)  &whowasi

I could not figure out what the first method of
invocation does and so wrote this code to see
the difference in results.  But I find no
difference in the results of the two invocations!
(The output is given below after the __END__.)

Please explain what the first method of invocation
is all about.

Thanks,

--Suresh
=cut

use Carp;
sub whowasi { (caller(1))[3] . "()" }
my $DEBUG = 0;
sub debug { $DEBUG = @_ ? shift : 1 }

sub the_place
{
    print "\n",'carp "usage: @{[ &whowasi ]} [USER [DOTDIR]]";',"\n";
    carp "usage: @{[ &whowasi ]} [USER [DOTDIR]]";

    print "\n", 'carp "@{[&whowasi]}: ";', "\n";
    carp "@{[&whowasi]}: ";

    print "\n", 'carp &whowasi if $DEBUG;' ,"\n";
    carp &whowasi if $DEBUG;

    debug();
    print "\nafter setting DEBUG:\n";
    carp &whowasi if $DEBUG;

    print "\n",'croak "usage: @{[ &whowasi ]} [USER [DOTDIR]]";',"\n";
    croak "usage: @{[ &whowasi ]} [USER [DOTDIR]]";
    print "\nshould NOT see this\n";
}

sub the_caller
{
   the_place(53);
}

sub the_sub
{
   the_caller();
}

print "in main:\n";
the_sub();

__END__
Output is as follows:

in main:

carp "usage: @{[ &whowasi ]} [USER [DOTDIR]]";
usage: main::the_place() [USER [DOTDIR]] at ..\tms\drafts\current line 40
 main::the_place(53) called at ..\tms\drafts\current line 59
 main::the_caller() called at ..\tms\drafts\current line 64
 main::the_sub() called at ..\tms\drafts\current line 68

carp "@{[&whowasi]}: ";
main::the_place():  at ..\tms\drafts\current line 43
 main::the_place(53) called at ..\tms\drafts\current line 59
 main::the_caller() called at ..\tms\drafts\current line 64
 main::the_sub() called at ..\tms\drafts\current line 68

carp &whowasi if $DEBUG;

after setting DEBUG:
main::the_place() at ..\tms\drafts\current line 50
 main::the_place(53) called at ..\tms\drafts\current line 59
 main::the_caller() called at ..\tms\drafts\current line 64
 main::the_sub() called at ..\tms\drafts\current line 68

croak "usage: @{[ &whowasi ]} [USER [DOTDIR]]";
Uncaught exception from user code:
 usage: main::the_place() [USER [DOTDIR]] at ..\tms\drafts\current line 53
 main::the_place(53) called at ..\tms\drafts\current line 59
 main::the_caller() called at ..\tms\drafts\current line 64
 main::the_sub() called at ..\tms\drafts\current line 68
 main::the_place(53) called at ..\tms\drafts\current line 59
 main::the_caller() called at ..\tms\drafts\current line 64
 main::the_sub() called at ..\tms\drafts\current line 68




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

Date: Thu, 12 Aug 2004 00:13:54 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Camel book: why invoke in the manner @{[&whowasi]}?
Message-Id: <2nvk44F59u37U1@uni-berlin.de>

Suresh Govindachar wrote:
> In the 'Tying Hashes' section of the Camel book (pg 378+), a
> subroutine called whowasi is invoked in the following two ways,
> 
>       1)  @{[&whowasi]}
> and   2)  &whowasi
> 
> I could not figure out what the first method of invocation does

It gets interpolated in a doublequoted context.

> Please explain what the first method of invocation is all about.

     sub foo { "Now foo() was interpolated!" }
     print "foo()\n";
     print "@{ [foo()] }\n";

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 11 Aug 2004 11:27:44 -0700
From: justkule@yahoo.com (siddhartha mulpuru)
Subject: Cron Job manipulation through Web Page
Message-Id: <78e9cb22.0408111027.625038dc@posting.google.com>

On a given UNIX systems there is a CRONTAB with CRON entries.  I would
like to develop a web page that would Display the entries, allow
Editing of an entry, allow searching for a specific entry in CRON for
a given USERID and Password.  The returned page for each entry must
display the page in "laymens" english, not cryptically as found in
CRON (In other words a conversion must take place to and from the
format in CRON)

I wanted to know if anyone did something similar or had ideas about
how this could be implemented.


Thanks a lot for your time

Sid


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

Date: Wed, 11 Aug 2004 20:45:26 GMT
From: "Clyde Ingram" <clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
Subject: Re: Cron Job manipulation through Web Page
Message-Id: <GzvSc.318$rA4.245@newsfe2-gui.ntli.net>

Siddharta,

"siddhartha mulpuru" <justkule@yahoo.com> wrote in message
news:78e9cb22.0408111027.625038dc@posting.google.com...
<SNIP>
> I wanted to know if anyone did something similar or had ideas about
> how this could be implemented.

Yes - I have tackled adding, deleting, and modifying a specific subset of
crontab entries for scheduling particular applications.
The front end was HTML & JavaScript, controlled by a CGI program (using
Lincoln Stein's CGI.pm, naturally) to manage several databases -- including
crontab.
Interesting problems included the usual bread-and-butter issues of
concurrent access (by multiple networked clients), file locking, cookies,
etc.

On the topic of the crontab format, I simpified matters by only letting the
user choose between daily, weekly, and monthly scheduling -- nothing more
powerful was necessay at the time.  Also, my application managed its private
database including user specified schedules (hour:minute; day-or-week (if
weekly) or day-of-month (if monthly)).  So the application never needed to
read or analyse or validate timing info from a raw crontab entry, merely
overwrite the crontab entry with the latest changes in its database, as
received via CGI.  An unsophisticated and fairly common-place project.

How about you?  Have you encountered any specific Perl (rather than CGI
authoring or database) problems that this news group might be happy to get
its teeth into?  Without details, it is hard to know where to point you, but
you may get great value by starting with any of these:

http://www.stonehenge.com/merlyn/columns.html
http://stein.cshl.org/~lstein/
http://stein.cshl.org/WWW/CGI/

Regards,
Clyde




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

Date: Wed, 11 Aug 2004 14:18:15 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: favorite perl IDE
Message-Id: <slrnchks7n.7g1.tadmc@magna.augustmail.com>

dragonbide <allen.jordan@colorado.edu> wrote:

> I'm looking for a good perl IDE.


Linux or BSD.


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


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

Date: 11 Aug 2004 19:58:07 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: favorite perl IDE
Message-Id: <Xns95429842B17BAcastleamber@130.133.1.4>

Tad McClellan <tadmc@augustmail.com> wrote in > dragonbide 
<allen.jordan@colorado.edu> wrote:
> 
>> I'm looking for a good perl IDE.
> 
> Linux or BSD.

IRIX


-- 
John                    Small Perl scripts:http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 11 Aug 2004 22:09:28 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: favorite perl IDE
Message-Id: <slrnchl68o.ec9.abigail@alexandra.abigail.nl>

dragonbide (allen.jordan@colorado.edu) wrote on MMMCMXCVIII September
MCMXCIII in <URL:news:d5ef4ee9.0408110712.2517dd10@posting.google.com>:
::  Hi.  I'm looking for a good perl IDE.  What are some of your
::  favorites?  (preferably for windows, but list whatever ones you'd
::  like) .


vile or vi. 2 or 3 xterms. man. make. If the project involves C, a C
compiler.



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: 11 Aug 2004 17:52:43 -0700
From: IneverReadAnythingSentToMe@hotmail.com (David Filmer)
Subject: My own handy Pocket Reference notes (please share your own also)
Message-Id: <e4c916dd.0408111652.3099c07c@posting.google.com>

Over the past couple of years, I have made many little notes inside
the covers of my O'Reilly Perl Pocket Reference - mostly syntax
hints/reminders from books and other usenet posts. I thought I would
post my notes here; maybe others can benefit (gurus probably less so).
Do you have some handy notes scratched inside YOUR Perl book? Maybe
you can share them also. Here are my personal quick reference notes
(in no particular order):
======================================================================
To redirect STDOUT to a file (or any filehandle to another filehandle)
   *STDOUT = *OUT;
======================================================================
Instead of:  $answer = $var1 . func() . $var2; #Perl CookBook 1ed p.21
   $answer="$var1 ${\( SCALAR EXPR )} $var2"; #ie:"eat ${\($n+1)} pie"

   $answer = "$var1 @{[ LIST EXPR ]} $var2";
   (ie, $foo = "uppercase"; print "here is ${\( uc $foo )} text";)
OR (ie, $foo = "uppercase"; print "here is @{[uc $foo]} text";
======================================================================
Instead of: $a = $b; $a = s/foo/bar/; ($a as a modified version of $b)
   ($a = $b) =~ s/foo/bar/;
======================================================================
Instead of: $a =~ /foo(.*)/; $b = $1; (define $a as a substring of $b)
   ($b) = ($a =~ /foo(.*)/);
======================================================================
To strip leading/trailing spaces:
   $foo =~ s/^\s+//;    $foo =~ s/\s+$//;
======================================================================
To simulate UN*X `grep -v`
   grep (!/foo/, @foo);   #or (!/foo/i, @foo) to simulate `grep -vi`
======================================================================
To strip the path from a filename (such as $0) w/o File::Basename:
   print ($0 =~ /^.\/(.*)/)[0];
======================================================================
To simulate UN*X `uniq` (create @uniq w/distinct members of @orig)
   %seen=(); @uniq = grep{! $seen{$_}++} @orig;
======================================================================
To set a variable but only if it is currently undefined/zero/null:
   $foo ||= 'bar';
======================================================================
To print $number, but print a zero if the variable is undefined:
   print $number || '0';
======================================================================
To pass a only single hash to a subroutine (without using references):
   &MySubroutine(%foo);   #call the sub and pass it a hash directly
   sub MySubroutine () { my %bar = @_; }
======================================================================
To pass a hash from a subroutine (using references):
   %foo = %{&MySubroutine()};
   sub MySubroutine () { my $bar{'candy'}='chocolate'; return \%bar; }
======================================================================
To set a variable to the greater (larger) of two choices:
   $var = ($a > $b) ? $a : $b;
Similarly, to (for example) print if a number is even or odd:
   print "The number is ", ($num % 2) ? "odd" : "even";        #modulo
======================================================================
To round off a number to "n" decimal places (or use Number::Format)
   sprintf ("%.nf", $foo);   #replace "n" with a variable or constant
======================================================================
To pad text with spaces (or zeros) to make string "n" chars in length:
   padding on RIGHT:  sprintf("%-ns", $foo);
   padding on LEFT:   sprintf("%ns",  $foo);   #or ("%0nd") for zeros
======================================================================
To pass a filehandle (FH) the proper way, (for example with CGI.pm):
   $foo = new CGI (\*FH);
======================================================================
To embed a variable in a variable name (maybe bad practice):
   $foo = "foo"; print ${"${foo}bar"}; #same as ${'foobar'} or $foobar
======================================================================
To replace $foo with $bar across an array:
   map {s/$foo/$bar/} @list;    #no comma!
======================================================================
To indent a "here document" in code but not in output:
   ($var = <<'   HERE') =~ s/^\s+//gm;   #allow HERE target to indent!
      Lorem ipsum                        #Perl Cookbook 1ed p 23
      dolor sit amet
   HERE
======================================================================
To generate a random integer between 0 and 10 (inclusive):
   $foo = rand(11);  #or rand(10)+1 if between 1 and 10 inclusive
======================================================================
To print a hash in a prettified way:
   print map { "$_\t=>\t$hash{$_}\n" } sort keys %hash;
======================================================================
To sort an array numerically (instead of Perl default alpha sort):
   @sorted = sort { $a <=> $b } @unsorted;    #Perl Cookbook 1ed p115
======================================================================
To prevent output from being buffered:
   select(STDERR); $| = 1; select(STDOUT); $| = 1;
======================================================================
To have output go through pager program:
   $pager = $ENV{'PAGER'} || '/usr/bin/less';  #MAKE sure pager is OK
   open (STDOUT, "| $pager");   # terminal output one page at a time!
======================================================================
IO::All module is great! Instead of:
   open (IN,'<','./stuff')||die $!;local $/;my $stuff = <IN>;close IN;
DO use IO::All; my $stuff < io"./stuff";   #let IO::All do the work!

Other kewl things (per perldoc)
  #FILES
    $io = io 'file.txt';                # Create a new IO::All object 
    $contents = $io->all;               # read everything (or ->slurp)
    $contents = join '', $io->getlines; # Join the separate lines
    $content > io('file.txt');          # Print to file(>> for append)
    @lines  = io('file.txt')->chomp->slurp;     # Chomp as you slurp
    @chunks = io('file.txt')->separator('xxx')->slurp; #alt record sep
  #DIRS
    $io = io('my/directory/');          # Create new DIRECTORY object
    @contents = $io->all;               # Get all contents of dir
    @contents = @$io;                   # Directory as an array
    @contents = values %$io;            # Directory as a hash
  #STAT
    printf "%s %s %s\n",                # Print name, uid and size of 
      $_->name, $_->uid, $_->size       # contents of current dir
        for io('.')->all;
    print "$_\n" for sort               # Use mtime method to sort all
      {$b->mtime <=> $a->mtime}         # files under current
directory
        io('.')->All_Files;             # by recent modification time.
  #EXTERNAL
    io("myfile") > io->("ftp://store.org");     # Upload file via ftp
    $html < io->http("www.google.com");         # Grab a web page
    io('mailto:worst@enemy.net')->print($spam); # Email a "friend"
======================================================================
Schwartzian Transform: For example, to sort /etc/passwd file by fields
   print map { $_->[0] }             #Randall Schwartz Rocks!!!
      sort {    $a->[1] <=> $b->[1]  #numerically sort first  by gid
             || $a->[2] <=> $b->[2]  #numerically sort second by uid
             || $a->[3] <=> $b->[3]  #alphabedic sort by loginID last
      } map { [ $_, (split /:/)[3,2,0] ] } `cat /etc/passwd`;
======================================================================
To print current date in format "YYYY-MM-DD" (ISO 8601):
   ($day, $month, $year) = (localtime)[3,4,5];  #no modules
      printf("%04d-%02d-%02d", $year+1900, $month+1, $day);
OR printf("%04d-%02d-%02d",
       sub {($_[5]+1900,$_[4]+1,$_[3])}->(localtime)); #no temp vars
OR use POSIX qw/strftime/; print strftime "%Y-%m-%d", localtime;
OR use Time::localtime; $tm = localtime; 
    printf("%04d-%02d-%02d", $tm->year+1900, ($tm->mon)+1, $tm->mday);
OR use Date::Manip; print UnixDate(scalar localtime, "%Y-%m-%d");
======================================================================
To get the mtime (lmod) of a file:
   $mtime = (stat $file)[9];  #epoch time (1065381040). [8] = atime.
OR $mtime = localtime ((stat ($file))[9]); # Wed Aug 11 12:07:44 2004
OR $mtime = sprintf("%04d-%02d-%02d",      #ie, YYYY-MM-DD w/o modules
      sub{($_[5]+1900,$_[4]+1,$_[3])}->(localtime((stat($file))[9])));
======================================================================
To set file mtime (w/o File::Touch)(UTC: timegen instead of timelocal)
   use Time::Local;
   $mtime = timelocal($sec, $min, $hours, $mday, $month, $year);
   utime( (stat($file)[9]), $mtime, $file ); #must include atime
======================================================================
ARRAY OF ARRAYS (ie, $cars[0][1] eq 'yellow';ALT SYNTAX: $car[0]->[1])
   @cars =([qw/red yellow green/],[qw/ford chevy/],[qw/coupe sedan/]);
HASH OF ARRAYS  (ie, $car{'col'}[1] eq 'yellow')
   %cars = (col=>[qw/red yellow green/],
            make=>[qw/ford chevy/],body=>[qw/coupe sedan/]);
HASH OF HASHES (ie, $org{sales}{boss} eq 'Sue')
   %org = (sales=>{boss=>'Sue', peon=>'Rob'},
           mailroom=>{boss=>'Joe', peon => 'Jane'});
ARRAY OF HASHES (ie, $org[0]{boss} eq 'Sue'; $org[1]{peon} eq 'Jane')
   @org = ({boss=>'Sue', peon=>'Rob'}, {boss=>'Joe', peon => 'Jane'});
======================================================================

Please feel free to make corrections or add your own!   - DavidFilmer


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

Date: Wed, 11 Aug 2004 19:19:22 +0200
From: "Mark" <admin@asarian-host.net>
Subject: Net::SMTP woes
Message-Id: <a4ydncaUa7G4yIfcRVn-iQ@giganews.com>

Hello,

Using perl 5.8.4 (FreeBSD 4.10), I try to deliver a message to a local SMTP
server, as follows:

if (not ($smtp = Net::SMTP -> new (
                                Timeout => 10,
                               PeerAddr => 'localhost',
                               PeerPort => 5005,
                                  Debug => 1,
))) {
    print $@;
    exit 1;
}

I successfully sent the message; except, that Net::SMTP does not connect to
port 5005 on localhost at all! Instead, it just connects to port 25 of the
MX of the current host address.

What am I missing?

I appreciate any suggestion,

- Mark




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

Date: Wed, 11 Aug 2004 19:14:55 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Net::SMTP woes
Message-Id: <PeuSc.287513$Oq2.79271@attbi_s52>

Mark wrote:

> Hello,
> 
> Using perl 5.8.4 (FreeBSD 4.10), I try to deliver a message to a local SMTP
> server, as follows:
> 
> if (not ($smtp = Net::SMTP -> new (
>                                 Timeout => 10,
>                                PeerAddr => 'localhost',
>                                PeerPort => 5005,
>                                   Debug => 1,
> ))) {
>     print $@;
>     exit 1;
> }
> 
> I successfully sent the message; except, that Net::SMTP does not connect to
> port 5005 on localhost at all! Instead, it just connects to port 25 of the
> MX of the current host address.
> 
> What am I missing?

The docs for Net::SMTP say that new() takes Host, not PeerAddr.
Have you tried
	Host => 'localhost:5005',
?
	-Joe


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

Date: Wed, 11 Aug 2004 23:10:34 +0200
From: "Mark" <admin@asarian-host.net>
Subject: Re: Net::SMTP woes
Message-Id: <Hfudnb0piYrOFofcRVn-qg@giganews.com>

Joe Smith wrote:

>> Using perl 5.8.4 (FreeBSD 4.10), I try to deliver a message to a
>> local SMTP server, as follows:
>>
>> if (not ($smtp = Net::SMTP -> new (
>>                                 Timeout => 10,
>>                                PeerAddr => 'localhost',
>>                                PeerPort => 5005,
>>                                   Debug => 1,
>> ))) {
>>     print $@;
>>     exit 1;
>> }
>>
>> I successfully sent the message; except, that Net::SMTP does not
>> connect to port 5005 on localhost at all! Instead, it just connects
>> to port 25 of the MX of the current host address.
>>
>> What am I missing?
>
> The docs for Net::SMTP say that new() takes Host, not PeerAddr.
> Have you tried Host => 'localhost:5005',

That was it! :) It solved it immediately.

Thanks!

- Mark




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

Date: Wed, 11 Aug 2004 14:16:30 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl PDF modules - help please
Message-Id: <slrnchks4e.7g1.tadmc@magna.augustmail.com>

Geoff Wilkins <GeoffW@wordsmith.demon.co.uk> wrote:
> In message <2nui85F4th3dU1@uni-berlin.de>, Gunnar Hjalmarsson 
><noreply@gunnar.cc> writes
>>Geoff Wilkins wrote:
>>> Hi all.
>>
>>Do not multi-post!
>>
>>http://www.uwasa.fi/~ts/http/crospost.html
> 
> Thanks Gunnar.  I hope someone else can be more helpful.


Just because it does not help _you_ does not mean that it
was not helpful. You seem rather self-centered...

It will help any reader who would prefer to not be seen as rude.



I found Gunnar's post to be helpful.

There are too many daily posts here to read them all so I rely
on automated filtering of articles.

Adding another entry for the folks who insist on being rude helps
reduce my work load, which in turn helps to provide more time
for helping folks.


Thanks Gunnar for flushing out another me-me-me poster to ignore!


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


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

Date: Wed, 11 Aug 2004 13:18:48 -0500
From: "Andrew Palmer" <andrewpalmer@email.com>
Subject: Re: Reading next line, finding missing number in sequence
Message-Id: <qntSc.4462$5s3.37@fe40.usenetserver.com>


"Pea" <taralish@yahoo.com> wrote in message
news:f4bfa101.0408110640.2527ff61@posting.google.com...
> Thank you, Brian.  I used your suggestion and modification and it
> worked well, except when there were two numbers in a row missing.  For
> example, if I had
> 1
> 2
> 5
> 6
> 7
>
> It would list 3 as the missing number but not 4.  I can work with this
> though.  Thanks a bunch.
>
> Tara
>
> > "Brian Kell" <abodeman@yahoo.com> wrote in message
> > news:opscjh0fq0z772u5@pc0938...
> > > I modified it thus:
> >
> > my $expected = 1;
> > while(<DATA>) {
> >   if( $_ != $expected ) {
> >     print "Missing $expected\n";
> >   }
> >  $expected = $_ + 1;
> > }

Here's an idea

my $expected = 1;
while(<DATA>) {
  for(;$expected < $_;++$expected) {
   print "Missing $expected\n";
  }
  $expected=$_+1;
}

Some of the other solutions posted here, handle this scenario as well,
though.

> >
> > __DATA__
> > 1
> > 2
> > 3
> > 5
> > 6
> > 7
> > 9
> > 10
> >
> > > Brian





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

Date: Wed, 11 Aug 2004 18:44:22 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Reading next line, finding missing number in sequence
Message-Id: <9OtSc.237235$a24.62184@attbi_s03>

>>(Assuming, of course, that you modified it to print the missing number.)

I would expect to print out all the missing numbers when the increase
is more than two.  Why limit it to always start at 1?

linux% cat count.pl
#!/usr/bin/perl

my $expected;
while(<DATA>) {
   if (defined $expected) {
     die "Bad data: expected=$expected, read=$_" if $_ < $expected;
     print "Missing ",$expected++,"\n" while $expected < $_;
   }
   $expected = $_ + 1;
}

__DATA__
2
3
5
9
10
linux% perl count.pl
Missing 4
Missing 6
Missing 7
Missing 8

	-Joe


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

Date: Wed, 11 Aug 2004 18:26:20 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Reading next line, finding missing number in sequence
Message-Id: <c2xSc.14926$a65.728036@news20.bellglobal.com>


"Brian Kell" <abodeman@yahoo.com> wrote in message
news:opscjqgswiz772u5@ultramarine.unl.edu...
> On Tue, 10 Aug 2004 19:46:26 -0400, Matt Garrish
> <matthew.garrish@sympatico.ca> wrote:
>
> >> while (<FILE>) {
> >>    $currline = $_;
> >>    $nxtline=$currline++ ;
> >>    if ($_ != $nxtline) {
> >>        print MISSING "Missing occurrence is $_  \n";
> >>    }
> >> }
> >>
> >
> > In the above, you assign the value of the line to $currline, then add 1
> > and
> > assign it to $nxtline. You then test whether the value on the input line
> > equals the number you just incremented? This should fail for *all* cases
> > (i.e., 1+1 != 1, 2+1 != 2, etc.).:
>
> Not quite; $nxtline will get the value of $currline before the increment.
> So it will *succeed* for all cases.
>

First Dr. Seuss and now this. I need a vacation...

Matt




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

Date: Wed, 11 Aug 2004 18:59:02 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: split inconsistency- why?
Message-Id: <V%tSc.289201$XM6.198987@attbi_s53>

Sara wrote:

> I'm talking about the choice of the default operation of split.  I'm not
> suggesting that it didn't work with additional arguments (which I
> predect few if any of my programmers would recognize). I'm suggesting
> it was a poor language design choice, and asking what advantage(s)
> that choice has for the programmer. An entirely different question.

You've got to remember that Perl was designed to make life easier for
programmers processing data files.  The documented behavior of split()
is very handy, especially when writing one-liners.  Perl was not
designed to be a strict, straight-jacket type of language.

	-Joe


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

Date: Wed, 11 Aug 2004 19:34:43 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: split inconsistency- why?
Message-Id: <cfdscj$j96$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Alan J. Flavell
<flavell@ph.gla.ac.uk>], who wrote in article <Pine.LNX.4.61.0408110015100.18119@ppepc56.ph.gla.ac.uk>:
> > I think what you say does not make a lot of sense. 

> That depends on whether you are trying to design the language, or to 
> use it.

Do not think so: split() is not very usable if what you want is that
it does *exactly* what you want.

> > During one phase of cleanup of Perl REx' semantic I managed to remove
> > about a dozen different quirks of split().  The remaining ones could
> > not be removed without a major change of semantic.

> Nevertheless, if the function is doing what it currently says on the 
> tin, then any considerations of future cleanups are ultra vires, as 
> far as a /user/ of the language is concerned.

Do you claim that you, as a /user/, know exactly what split() will do
in each situation?

Do you claim that you, as a /user/, will be able to extract from the
docs (without experiments!) what split() will do in a particular
situation?

All I wanted was a way to *force* split() to behave without any quirk,
so that this particular mode of operation may be explained in one
short paragraph.  If you want 'diagonality', it may be much easier to
implement it in your code, than to understand/guess which quirks
happen in which situation.

> No matter that you /could/ see a way to make it better/simpler/
> more rational in the future.  With which I wouldn't presume to argue; 
> but meantime, the users have what they're offered, with its relevant 
> documentation, no?

No.  As I said, at some moment I updated the docs so that they
reflected my "current" understanding of the behaviour of split().
Unfortunately, even afer reading/cleaninig the source code, I could
not recognize all the quirks (boundary conditions!); so the
documentation is not fully "relevant".

Hope this helps,
Ilya


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

Date: Wed, 11 Aug 2004 20:14:44 -0000
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: SSL Tunneling
Message-Id: <slrnchkv6m.hgf.tim@vegeta.saiyix>

Andy80 <a.scolari@ticino.com> wrote:
>  I've to write a proxy perl script for the following purpose:
>  
>  
>                         _____________a single PC______________
>                        | _________                   _______  |
>  --------------------> | |        | --------------> |       | |
>  --- SSL traffic ----> | |My proxy| -- plain -----> |daemon | |
>  --------------------> | |_(perl)_| -- traffic ---> |_______| |
>                        |______________________________________|
>  
>  
>  I've to "convert" SSL traffic into plain traffic and send it on the
>  same machine but on another port. Is that possible??

Why can't you use openssh?  

Just curious,
Tim Hammerquist


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

Date: Wed, 11 Aug 2004 18:56:59 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <slrnchkqvr.m8l.dha@panix2.panix.com>

On 2004-08-11, Matt Garrish <matthew.garrish@sympatico.ca> wrote:
>
> If it's any help, Dr. Seuss wrote a book about a baby bird like you. It's
> called "Are you my mother?". I highly recommend it!

Sorry to have to bring this up, but it's not Dr. Seuss.  It's P. D.
Eastman.

Yes, I loved that book as a kid and actually *remembered* that, why do
you ask? :-)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Hey, Siegfried!  Pick an accent and stick with it!
	- Tom Servo, MST3K


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

Date: Wed, 11 Aug 2004 18:19:35 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <PZwSc.14921$a65.727807@news20.bellglobal.com>


"David H. Adler" <dha@panix.com> wrote in message
news:slrnchkqvr.m8l.dha@panix2.panix.com...
> On 2004-08-11, Matt Garrish <matthew.garrish@sympatico.ca> wrote:
> >
> > If it's any help, Dr. Seuss wrote a book about a baby bird like you.
It's
> > called "Are you my mother?". I highly recommend it!
>
> Sorry to have to bring this up, but it's not Dr. Seuss.  It's P. D.
> Eastman.
>

Right you are! I was going on memories of having been read it as a child,
and the artwork left the impression that it was a Dr. Seuss work. I'll check
my facts more thoroughly next time... : )

Matt




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

Date: Wed, 11 Aug 2004 18:53:58 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Validating email addresses
Message-Id: <aXtSc.287472$Oq2.202562@attbi_s52>

Arthur wrote:

> Even stranger, if the list of addresses I send all have an @ sign,
> then everything is flagged as valid, even if I have other symbols in
> the address, such as # or ( or *.

The e-mail address #&*@example.com is valid.  It's allowed by the RFC.
In certain contexts, ( and ) are allowed.
	-Joe


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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