[19386] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1581 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 21 18:10:53 2001

Date: Tue, 21 Aug 2001 15:10:13 -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: <998431813-v10-i1581@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 21 Aug 2001     Volume: 10 Number: 1581

Today's topics:
    Re: Looking for Script <hbae_@_nyc.rr.com.REMOVE_>
    Re: Microsoft Perl <wsegrave@mindspring.com>
    Re: Microsoft Perl <mazza@nospam.co.uk>
        need to reformat file from variable to fixed length is  (johnthan)
    Re: need to reformat file from variable to fixed length <cberry@cinenet.net>
    Re: Net::NNTP <gerard@NOSPAMlanois.com>
    Re: Net::NNTP <gnarinn@hotmail.com>
    Re: passing arrays to a subroutine (Abigail)
        regex to edit config variable <projectobjects@earthlink.net>
    Re: Structuring a program (if statements) <gnarinn@hotmail.com>
    Re: subroutines in @INC ? (Abigail)
    Re: System call (Abigail)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 21 Aug 2001 21:54:20 GMT
From: Hansang Bae <hbae_@_nyc.rr.com.REMOVE_>
Subject: Re: Looking for Script
Message-Id: <MPG.15eca28b82244322989738@news-server.nyc.rr.com>

> "T Mesbah" <tmesbah@hotmail.com> wrote in message
> news:6e9d9699.0108180631.5b238d48@posting.google.com...
> > 1)We need to use the path defined with the static route first because
> > of the bandwith (path defined with Encryptor)
> > 2) The backup for this path is frame-relay using OSPF
> >
> >
> >    =====          STATIC ROUTE
> >   |     |            =====             ===     ========
> >   | R1  |--- ENCRY--- ISP1----ENCRY----R3------|       |
> >   |     |            =====             ===     |       |
> >    =====                                       |       |
> >       |                                        |       |
> >       |OSPF                                    |Switch |
> >       |                                        |       |
> >    =======                                     |       |
> >   |       |            =====        ==         |       |
> >   |  R2   |------------ ISP2 -------R4--------|       |
> >   |       |            =====        ==         =========
> >    =======           Frame Relay



In article <Gpbg7.27677$7F.362418@e420r-sjo2.usenetserver.com>, 
dennis@noreplies.com says...
> Then you shouldn't have any problem.  A static route has a lower
> adminstrative distance than OSPF and will be choosen first.  When that route
> becomes unavailable it will drop from the routing table and the OSPF route
> will take over...


The problem is that this is a WAN link and has an encryptor in place.  So 
the static may never go away since the interface may never go down.  Why 
not just set the "ip ospf cost" on R1 and R3 to be lower than than of R2 
and R4?  That should be all that's required.  Let the routing protocol do 
its job! <G>



-- 

hsb

"Somehow I imagined this experience would be more rewarding"  Calvin
********************************************************************
Due to the volume of email that I receive, I may not not be able to
reply to emails sent to my account.  Please post a followup instead.
********************************************************************


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

Date: Tue, 21 Aug 2001 14:43:40 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Microsoft Perl
Message-Id: <9lue6n$kpa$1@nntp9.atl.mindspring.net>

> Phil Hibbs (phil.hibbs@capgemini.co.uk) wrote:
> : When I do "perl -v" I get this:
>
> : This is perl, version 5.001
>
> :         Unofficial patchlevel 1m.
>
> : Copyright 1987-1994, Larry Wall
> : Win32 port Copyright (c) 1995 Microsoft Corporation. All rights
> : reserved.
> :         Developed by hip communications inc.,
> : http://info.hip.com/info/
>
> :         Perl for Win32 Build 110
> :         Built Aug 13 1996@08:18:50
> : Perl may be copied only under the terms of either the Artistic License
> : or the
> : GNU General Public License, which may be found in the Perl 5.0 source
> : kit.
>
> : Is anyone familiar with this version of perl? I have to get to know
> : and love it, because it's installed on a customer site.
>
> : Phil.
>

IIRC, my copy was installed either as part of MS FrontPage 98 or with
Personal Web Server, from MSWord. When PWS trashed my network setup, I blew
all of the MS FrontPage and PWS stuff away, leaving Perl 5.001 as an
artifact. Since then, I've abandoned it's use in favor of later versions, to
resolve security issues with that version (See a FAQ post on "Which version
of Perl should I use", posted today).

BTW, I noted yesterday that IndigoStar, www.indigostar.com, distributes what
appears to be the same Perl v. 5.001 as
part of the shareware version of MicroWeb.

Bill Segraves
Auburn, AL








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

Date: Tue, 21 Aug 2001 22:26:34 +0100
From: "mazza" <mazza@nospam.co.uk>
Subject: Re: Microsoft Perl
Message-Id: <tmAg7.190$v45.331426@newsr2.u-net.net>

Perl 5.001 is included in the NTServer 4 Resouce Kit


Phil Hibbs <phil.hibbs@capgemini.co.uk> wrote in message
news:153e25f0.0108210710.549d1926@posting.google.com...
> When I do "perl -v" I get this:
>
> This is perl, version 5.001
>
>         Unofficial patchlevel 1m.
>
> Copyright 1987-1994, Larry Wall
> Win32 port Copyright (c) 1995 Microsoft Corporation. All rights
> reserved.
>         Developed by hip communications inc.,
> http://info.hip.com/info/
>
>         Perl for Win32 Build 110
>         Built Aug 13 1996@08:18:50
> Perl may be copied only under the terms of either the Artistic License
> or the
> GNU General Public License, which may be found in the Perl 5.0 source
> kit.
>
> Is anyone familiar with this version of perl? I have to get to know
> and love it, because it's installed on a customer site.
>
> Phil.




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

Date: 21 Aug 2001 13:40:08 -0500
From: jthn342@hotmail.com (johnthan)
Subject: need to reformat file from variable to fixed length is Perl the best way
Message-Id: <3b82aa4e$0$17990$45beb828@newscene.com>


We need to convert a file from a variable lenght delimted format to a fixed 
length format.


we have a 24 gig file in 12 pieces.  Currently the file is variable length 
delimited by |  with fields enclosed with ^
sample:
^717764002^|^71776401.^|^2000-09-11-19.23.00.000000^|^2000-05-25^
^300102^|^30011.^|^2000-06-28-19.57.29.670634^|^2000-05-30^

we need to convert this to a fixed lenght format with each field taking a 
certain predined lenght.  
sample
  717764002   71776401.    2000-09-11-19.23.00.000000           2000-05-25
       300102         30011.   2000-06-28-19.57.29.670634           2000-05-30


I am sure that this can be done in Perl  couple of questions:

1 - would this involved just using reading and then fprint to format.  How to 
handle the delimiters and ^.   Would every single character need to be 
processed and examined?  Is there are way to avoid that

2 - is Perl able to do this very quickly?  i am looking at around 20-25 mins 
per 2 gig file.


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

Date: Tue, 21 Aug 2001 19:20:21 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: need to reformat file from variable to fixed length is Perl the best way
Message-Id: <Xns91047D85CCDECcberrycinenetnet1@207.126.101.92>

jthn342@hotmail.com (johnthan) wrote in
news:3b82aa4e$0$17990$45beb828@newscene.com: 
> We need to convert a file from a variable lenght delimted format to a
> fixed length format.
> 
> we have a 24 gig file in 12 pieces.  Currently the file is variable
> length delimited by |  with fields enclosed with ^
> sample:
> ^717764002^|^71776401.^|^2000-09-11-19.23.00.000000^|^2000-05-25^
> ^300102^|^30011.^|^2000-06-28-19.57.29.670634^|^2000-05-30^
> 
> we need to convert this to a fixed lenght format with each field taking
> a certain predined lenght.  

If there are no ^ characters other than as field delimiters, this is pretty 
simple.  Define the output format you want, and then loop as follows:

  my $fmt = "%10s%-20s%20s%12s\n";  # Or whatever
  printf $fmt, m/\^(.*?)\^/g while <>;

> 1 - would this involved just using reading and then fprint to format. 
> How to handle the delimiters and ^.   Would every single character need
> to be processed and examined?  Is there are way to avoid that

Every single char will be visited by the regex engine, yes.  No real way to 
get around that, as you need to look for the next ^ to see where each field 
begins and ends.

> 2 - is Perl able to do this very quickly?  i am looking at around 20-25
> mins per 2 gig file.

On any reasonably fast hardware, that should not be a problem.  Only testing 
will tell for sure, however.

-- 
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake



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

Date: 21 Aug 2001 12:03:01 -0700
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: Net::NNTP
Message-Id: <u66bhxml6.fsf@NOSPAMlanois.com>

"S Warhurst" <bigusAT@btinternetDOT.com> writes:

> my @Message = ( "Newsgroups: $newsgroup\015\012",
>                 "From: email\@address.com\015\012",
>                 "Subject: Test Net-NNTP\015\012",
>                 "\015\012",
>                 "Hello world\015\012"
>                 );
> my $OK = $server->post(\@Message);
> ...
> Anyone got any ideas why it isn't working please?

Did you try it without the \015\012?

my @Message = ( "Newsgroups: $newsgroup",
                "From: email\@address.com",
                "Subject: Test Net-NNTP",
                "",
                "Hello world"
                );

Another thing to try if that doesn't work is to put your
own \n's in.  I noticed some code in Cmd.pm that substitutes
the \n's to \015\012 for you.

my @Message = ( "Newsgroups: $newsgroup\n",
                "From: email\@address.com\n",
                "Subject: Test Net-NNTP\n",
                "\n",
                "Hello world\n"
                );


Sorry, it's been a long time since I posted something
with Net::NNTP, but I think those two are worth a try.

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



-----=  Posted via Newsfeeds.Com, Uncensored Usenet News  =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
 Check out our new Unlimited Server. No Download or Time Limits!
-----==  Over 80,000 Newsgroups - 19 Different Servers!  ==-----


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

Date: Tue, 21 Aug 2001 19:19:57 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Net::NNTP
Message-Id: <998421597.371190984733403.gnarinn@hotmail.com>

In article <9lu6g2$sta$1@plutonium.btinternet.com>,
S Warhurst <bigusAT@btinternetDOT.com> wrote:
>I am trying to get a script working to enable me to post to a newsgroup (not
>for spamming purposes, but for a notification to a private newsgroup). Here
>is the code:

(snipped some code)

>my @Message = ( "Newsgroups: $newsgroup\015\012",
>                "From: email\@address.com\015\012",
>                "Subject: Test Net-NNTP\015\012",
>                "\015\012",
>                "Hello world\015\012"
>                );

i usually just use \n as line termination (i am on unix)
maybe your server needs more headers:
  Message-ID
  Date
but remember you need to format date correctly

hope this helps

gnari



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

Date: 21 Aug 2001 19:09:15 GMT
From: abigail@foad.org (Abigail)
Subject: Re: passing arrays to a subroutine
Message-Id: <slrn9o5cf9.6m2.abigail@alexandra.xs4all.nl>

Eli Bendersky (eliben@il.ibm.comNOSPAM) wrote on MMCMXII September
MCMXCIII in <URL:news:3B825C48.17A60983@il.ibm.comNOSPAM>:
$$     Hi,
$$ 
$$ I want a subroutine which receives 2 arrays as arguments
$$ and does some computing with them.
$$ 
$$ How can I achieve it ?


Either by passing references, or using prototypes.




Abigail
-- 
BEGIN {$^H {q} = sub {pop and pop and print pop}; $^H = 2**4.2**12}
"Just "; "another "; "Perl "; "Hacker\n";


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

Date: Tue, 21 Aug 2001 20:35:04 GMT
From: "Dale Henderson" <projectobjects@earthlink.net>
Subject: regex to edit config variable
Message-Id: <YBzg7.908$OG4.81926@newsread1.prod.itd.earthlink.net>

I know that App::Config can retrieve values from perl config variables. Is
there a known function that can change the value of the config variable in a
flat text file in the following format

$var = "value1";

or could someone post a regex that can do the replace for the value1.
Obviously, I am a novice with regex.

thanks for any replies,
dalehend@yahoo.com




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

Date: Tue, 21 Aug 2001 19:29:23 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Structuring a program (if statements)
Message-Id: <998422163.445656331721693.gnarinn@hotmail.com>

In article <9ls6or$bpr$1@neptunium.btinternet.com>,
Peter Mann <Pcmann1@btinternet.com> wrote:

(snip)
>
>@months = qw/All January February March April May June July August September
>October November December/;
>$monthCombo = $report_p->BrowseEntry(-textvariable =>
>\$month, -width=>'10')->place(-x=>40, -y=>200);
>$monthCombo->insert('end', @months);
>
>
>
>sub chooseMonth{
>  my $selectedMonth;
>
>  if ($month eq 'All') {
>    $selectedMonth = "All"
>  }
>  if ($month eq 'January') {
>    $selectedMonth = "January"
>  }
>..... etc (im sure u get the idea!)
>}
>

apart from the 
  $selectedMonth = $month 
that other have suggested, may i add
that in the case where $selectedMonth is not exactluy same as $month,
you should look a hashes. like:
  %selmon=(
            All=>'The whole damn year',
            January=>'the first month',
	    February=>'the short one',
	    ...
	  );
  $selectedMonth = $selmon{$month};
  

gnari


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

Date: 21 Aug 2001 18:38:56 GMT
From: abigail@foad.org (Abigail)
Subject: Re: subroutines in @INC ?
Message-Id: <slrn9o5amc.6m2.abigail@alexandra.xs4all.nl>

Bart Lateur (bart.lateur@skynet.be) wrote on MMCMXII September MCMXCIII
in <URL:news:90o4ot0a0v7fm6ninngt10kfeerruacbf7@4ax.com>:
&& Anno Siegel wrote:
&& 
&& >So it appears that it does indeed expect a filehandle to be returned,
&& >and a module is read from it if so.  No %INC entry is made.
&& 
&& A file handle?
&& 
&& This sounds like a feature to make tools like perl2exe and perlapp, that
&& include module source into the same file.
&& 
&& But I can imagine doing strange stuff like pulling in modules over a
&& network socket.


You mean as in the following CPAN module?


package The::Net;

#
#   $Id: Net.pm,v 1.1 2001/04/29 04:22:11 abigail Exp abigail $
#
#   $Log: Net.pm,v $
#   Revision 1.1  2001/04/29 04:22:11  abigail
#   Initial revision
#
#

use warnings 'all';
use strict;

use vars qw /$VERSION/;

($VERSION) =~ q $Revision: 1.1 $ =~ /([\d.]+)/;

push @INC => sub {
    require LWP::Simple;
    require IO::File;
    require Fcntl;

    my $url      = pop;

    return unless $url =~ m{^\w+://};

    my $document = LWP::Simple::get ($url) or die "Failed to fetch $url: $!\n";

    my $fh = IO::File -> new_tmpfile or die "Failed to create temp file: $!\n";
    $fh -> print ($document) or die "Failed to print: $!\n";
    $fh -> seek (0, Fcntl::SEEK_SET()) or die "Failed to seek: $!\n";

    $fh;
};


1;

__END__

=head1 NAME

The::Net  --  Use the Net to fetch your required modules.

=head1 SYNOPSIS

    use The::Net;

    require 'http://www.example.com/Module.pm';

=head1 DESCRIPTION

By using The::Net, you enable C<require> to fetch Modules using HTTP
or FTP, when given a URL as argument.

=head1 REVISION HISTORY

    $Log: Net.pm,v $
    Revision 1.1  2001/04/29 04:22:11  abigail
    Initial revision


=head1 AUTHOR

This package was written by Abigail, abigail@foad.org.

=head1 COPYRIGHT and LICENSE
    
This package is copyright 2001 by Abigail.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation 
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
        
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
    
=cut
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: 21 Aug 2001 19:06:18 GMT
From: abigail@foad.org (Abigail)
Subject: Re: System call
Message-Id: <slrn9o5c9n.6m2.abigail@alexandra.xs4all.nl>

agm@physics.berkeley.edu (agm@physics.berkeley.edu) wrote on MMCMXII
September MCMXCIII in <URL:news:3B81C9C1.4E7A2080@physics.berkeley.edu>:
() I make a system call of the form:
() 
() system "cd /home/john";
() 
() or
() 
() system "PATH=/usr/bin:/bin:";
() 
() and neither one seems to work.

Sure they do.

() The first gives me an error message of the form:
() unable to perform "cd" - file or directory not found.

That doesn't seem like a Perl error, or an error from any `cd' I ever
encountered.

() And the second just does not work.

As purl would say:

    Look buddy, doesn't work is a strong statement. Does it sit on
    the couch all day? Is it making faces at you? Does it want more
    money? Please be specific!

My bet is that it does work, but it does something you don't expect.
system() calls a shell, and has the shell execute the command. So,
the PATH is set for the new shell. Then the new shell exits. Pooooof,
the setting for PATH is gone, cause the shell is gone. And as you can
learn in the FAQ, variable settings don't propagate to the parent.

If you want to set environment variables for the current process, you
need to modify %ENV.



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

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


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