[23230] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5451 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 6 00:05:48 2003

Date: Fri, 5 Sep 2003 21:05:07 -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           Fri, 5 Sep 2003     Volume: 10 Number: 5451

Today's topics:
        perl and bash about localization (Mi)
    Re: perl and bash about localization <emschwar@pobox.com>
        PHP vs Perl <taylorjo@collegesherbrooke.qc.ca>
    Re: PHP vs Perl (Jay Tilton)
    Re: PHP vs Perl <taylorjo@collegesherbrooke.qc.ca>
    Re: PHP vs Perl <cwilbur@mithril.chromatico.net>
    Re: PHP vs Perl (Jay Tilton)
    Re: problems with charsets <flavell@mail.cern.ch>
        read VB file with Perl <x12code-del@del-yahoo.com>
    Re: read VB file with Perl <afaust@aradyme.com.REMOVE>
    Re: read VB file with Perl <NOSPAM@bigpond.com>
    Re: read VB file with Perl <minceme@start.no>
    Re: read VB file with Perl <david-del@del-nonspiritual.com>
    Re: read VB file with Perl <minceme@start.no>
    Re: read VB file with Perl <krahnj@acm.org>
    Re: Regexp Help (Jay Tilton)
    Re: Regexp Help (raven)
    Re: Repost Search <krahnj@acm.org>
        uping and downing letters <wenjoh26@emNOSPAMail.pct.edu>
    Re: uping and downing letters (Jay Tilton)
    Re: View NG with Net::NNTP (Mike)
    Re: View NG with Net::NNTP <krahnj@acm.org>
    Re: Weird interaction between Net::FTP and DBI / DBD::O <r_reidy@comcast.net>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 Sep 2003 17:11:09 -0700
From: eastcapital@hotmail.com (Mi)
Subject: perl and bash about localization
Message-Id: <1ed28a22.0309051611.25df6b2c@posting.google.com>

I am quite a newbie.
When I use command "$cal" in console, I can see the calender which is
localized. However in a cgi script

print `$cal`;

the result(the calender) is not localized. I appreciate if anyone
could give advice. Thank you.


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

Date: Fri, 05 Sep 2003 18:18:02 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: perl and bash about localization
Message-Id: <etooexyrcqt.fsf@wormtongue.emschwar>

eastcapital@hotmail.com (Mi) writes:
> I am quite a newbie.
> When I use command "$cal" in console, I can see the calender which is
> localized. However in a cgi script
>
> print `$cal`;
>
> the result(the calender) is not localized. I appreciate if anyone
> could give advice. Thank you.

I'm sorry, that doesn't look like real code, or at least not all of
it.  $cal is a variable, and unless we know what's in it, we cannot
tell you what your problem is.

99% of the time, however, when the exact same code prints different
things between CGI and a command line, the difference is in the
environment.  I'd recommend verifying that it's the same, or if not,
making them the same.  Start with LC_* variables.

Also, 90% of the time, your problem isn't specific to Perl-- I'd bet
if you wrote this CGI program in, say, bash, you'd have the same
problem.  Try asking CGI questions in comp.infosystems.www.authoring.cgi.

-=Eric (what can I say, it's friday, I'm in a good mood)
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Sat, 06 Sep 2003 01:54:14 GMT
From: John Taylor-Johnston <taylorjo@collegesherbrooke.qc.ca>
Subject: PHP vs Perl
Message-Id: <3F593E88.23029739@collegesherbrooke.qc.ca>

Comparison study. Can this be done in Perl? How many lines?

<?php
$display_start = "2003-09-01";
$display_end = "2003-09-31";

echo "testing<br>";

$stuff = "$display_start - $display_end<br>";

if((date("Y-m-d") >= $display_start) && (date("Y-m-d") <= $display_end)){
        print($stuff);
}else{
echo "Date expired: ".date("Y-m-d");
}
?>



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

Date: Sat, 06 Sep 2003 02:04:22 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: PHP vs Perl
Message-Id: <3f594080.270731734@news.erols.com>

John Taylor-Johnston <taylorjo@collegesherbrooke.qc.ca> wrote:

: Comparison study. Can this be done in Perl?

Yes.

: How many lines?

How many do you want?



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

Date: Sat, 06 Sep 2003 02:08:31 GMT
From: John Taylor-Johnston <taylorjo@collegesherbrooke.qc.ca>
Subject: Re: PHP vs Perl
Message-Id: <3F5941E0.D2142E69@collegesherbrooke.qc.ca>

Shortest :) Seriously. Can someone show me?
Thanks,
J


> : How many lines?
> How many do you want?



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

Date: Sat, 06 Sep 2003 02:45:09 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: PHP vs Perl
Message-Id: <871xuu4p75.fsf@mithril.chromatico.net>

>>>>> "JTJ" == John Taylor-Johnston <taylorjo@collegesherbrooke.qc.ca> writes:

    JTJ> Comparison study. Can this be done in Perl? How many lines?
    JTJ> <?php 
    JTJ> $display_start = "2003-09-01"; 
    JTJ> $display_end = "2003-09-31";
    JTJ> echo "testing<br>";
    JTJ> $stuff = "$display_start - $display_end<br>";
    JTJ> if((date("Y-m-d") >= $display_start) 
    JTJ>   && (date("Y-m-d") <= $display_end))
    JTJ> { print($stuff); }else{ echo "Date expired:
    JTJ> ".date("Y-m-d"); } ?>

It's about as complex in Perl as it is in PHP, and you can even take
the same approach.  Here's a hint:  perldoc POSIX, look for strftime.

Charlton

-- 
cwilbur at chromatico dot net
cwilbur at mac dot com


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

Date: Sat, 06 Sep 2003 03:32:21 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: PHP vs Perl
Message-Id: <3f595277.275332265@news.erols.com>

In future, please don't top-post replies.

John Taylor-Johnston <taylorjo@collegesherbrooke.qc.ca> wrote:

: > : How many lines?
: > How many do you want?
: 
: Shortest :) 

Be careful.  Those are golfing words.  :)

: Seriously. Can someone show me?

PHP has an advantage with that nice date() function.  The strftime()
function in Perl's mountainous POSIX module has similar capabilities.

    use POSIX 'strftime';
    ($display_start, $display_end) = ("2003-09-01", "2003-09-31");
    print "testing<br>",
        ($n=strftime '%Y-%m-%d', localtime) ge $display_start
        && $n le $display_end
        ? "$display_start - $display_end<br>"
        : "Date expired: $n";



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

Date: Sat, 6 Sep 2003 00:23:04 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: problems with charsets
Message-Id: <Pine.LNX.4.53.0309060007350.7681@lxplus075.cern.ch>

On Fri, Sep 5, peter pilsl inscribed on the eternal scroll:

> I've a long csv-file that needs to be imported into a sql-database. My
> problem now is, that I dont know the charset this file is encoded in

Text files are meaningless without the accompanying character coding
(MIME terminology: "charset") meta-information, really.  That isn't a
Perl problem, no matter that you could use Perl as part of the
solution.

> afterwards I would not know how to convert it to what I need (latin1 for
> output and utf8 for storage).

Easy, once you identify the source coding.

> For current transformation unicode<->latin1 the Unicode::String-module is
> what I use but the file seems not to be latin1 after all. (It comes from a
> mac and I'm working on a linux-machine)

Sounds as if the coding is likely to be macRoman. Verdammt nochmal,
das isses auch.

> I'm aware of the fact that my problem is not really a perl-problem, but I
> use perl to detect and convert the charset, so I hope its ok here.

Not really, but by chance it happens to be one of my specialist
subjects...

> An example for the text I need to process is available at:
> http://www.goldfisch.at/temporary/text.cvs  for download (its only one line
> with 276 bytes).

What I did was simply to view it in Mozilla and play with the
view->coding settings until it started to make sense.

Now go to the Perl encoding pages to find out how to define the
encoding layer (5.8.0+) or the explicit en/de/coding calls to handle
it.  After that it's a doddle (=Spaziergang, Kleinigkeit, or
whatever).

see also: http://www.perldoc.com/perl5.8.0/lib/Encode.html
http://www.perldoc.com/perl5.8.0/lib/Encode/Supported.html

good luck


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

Date: Fri, 05 Sep 2003 17:09:20 -0500
From: David McDivitt <x12code-del@del-yahoo.com>
Subject: read VB file with Perl
Message-Id: <462ilvotf8jms9ti5sg2colos9q3t129q4@4ax.com>

I am experienced with VB and just starting to learn Perl. It's necessary for
me to read files written by VB and display from a CGI script. Changing the
VB app is not an option, so I need to get Perl to interpret VB data types
when read from the file.

This is the VB user defined type:

Public Const StatusMaxAppPointer = 57
Public Const StatusCommonPointer = 58
Public Const StatusResourcePointer = 59
Public Const StatusOnCallPointer = 60
'
Public Type ProcRec
    LastScanTime As Date
    NextExecuteTime As Date
    NextExecuteTimeSet As Integer
    MinutesToRun As Long
    TaskID As Double
    ID As String * 4
    ProcScheduler As String * 1
    ProcName As String * 30
    Active As Integer
    PassArguments As Integer
    OwnSection As String * 4
    OwnUnit As String * 4
    Executable As String * 256
    ExecutableType As Integer
    TextOffset(StatusOnCallPointer, 1) As Long
    End Type

This user defined type exists as a header at the front of a binary file.
TextOffset contains pointers and lengths of strings comprising the remainder
of the file. In VB the file is opened, the header read, and a sixty element
string array is populated using values from TextOffset in the header.

I thought about writing a VB program which would read the file and write
back out as text, but I would have to have some type of piping between Perl
and the VB program. I would prefer to read and interpret with Perl. Any
thoughts would be appreciated.



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

Date: Fri, 5 Sep 2003 16:47:43 -0600
From: "Andrew Faust" <afaust@aradyme.com.REMOVE>
Subject: Re: read VB file with Perl
Message-Id: <OAXS9#$cDHA.3240@TK2MSFTNGP11.phx.gbl>

"David McDivitt" <x12code-del@del-yahoo.com> wrote in message news:462ilvotf8jms9ti5sg2colos9q3t129q4@4ax.com...
<Snip A Question about how to read a binary file written in VB from Perl>

I haven't done much with Perl, but I have done enough to know that
what you propose is possible. However, you are asking in the wrong
forum. I would recommend finding a Perl forum and asking how to
read a binary file. There's no need to even mention it was written
in VB, as the same principles will apply no matter what language
your file was written in. Keep in mind though, that in many
languages Integers are 4 bytes instead of 2, so any response
you receive may need to be modified to take that in to account.

Andrew Faust

--
Andrew Faust

Where are we going and why am I in this handbasket?




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

Date: Sat, 6 Sep 2003 09:25:56 +1000
From: "Gregory Toomey" <NOSPAM@bigpond.com>
Subject: Re: read VB file with Perl
Message-Id: <bjb61u$hhmho$1@ID-202028.news.uni-berlin.de>

"David McDivitt" <x12code-del@del-yahoo.com> wrote in message
news:462ilvotf8jms9ti5sg2colos9q3t129q4@4ax.com...
> I am experienced with VB and just starting to learn Perl. It's necessary
for
> me to read files written by VB and display from a CGI script. Changing the
> VB app is not an option, so I need to get Perl to interpret VB data types
> when read from the file.
>
> This is the VB user defined type:
>

It's probably a one-liner in Perl if you use unpack:
http://www.perldoc.com/perl5.8.0/pod/func/unpack.html

gtoomey




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

Date: Fri, 5 Sep 2003 23:30:07 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: read VB file with Perl
Message-Id: <bjb69u$rk9$1@troll.powertech.no>

David McDivitt <x12code-del@del-yahoo.com> wrote:

 ...

> I need to get Perl to interpret VB data types when read from the file.
>
> This is the VB user defined type:
>
> Public Const StatusMaxAppPointer = 57
> Public Const StatusCommonPointer = 58
> Public Const StatusResourcePointer = 59
> Public Const StatusOnCallPointer = 60
> '
> Public Type ProcRec
>     LastScanTime As Date
>     NextExecuteTime As Date
>     NextExecuteTimeSet As Integer
>     MinutesToRun As Long
>     TaskID As Double
>     ID As String * 4
>     ProcScheduler As String * 1
>     ProcName As String * 30
>     Active As Integer
>     PassArguments As Integer
>     OwnSection As String * 4
>     OwnUnit As String * 4
>     Executable As String * 256
>     ExecutableType As Integer
>     TextOffset(StatusOnCallPointer, 1) As Long
>     End Type
>

This can be done with unpack(). I don't know enough details about vb types
to set up a correct $template, but this might get you started:

    # assuming vb Date is long int, strings are ascii, all ints are unsigned
    my $template = <<TMPL;
            L                #     LastScanTime As Date
            L                #     NextExecuteTime As Date
            I                #     NextExecuteTimeSet As Integer
            L                #     MinutesToRun As Long
            d                #     TaskID As Double
            A4               #     ID As String * 4
            A                #     ProcScheduler As String * 1
            A30              #     ProcName As String * 30
            I                #     Active As Integer
            I                #     PassArguments As Integer
            A4               #     OwnSection As String * 4
            A4               #     OwnUnit As String * 4
            A256             #     Executable As String * 256
            I                #     ExecutableType As Integer
            L                #     TextOffset(StatusOnCallPointer, 1) As Long
    TMPL

    open my $fh, "filename" or die "can't open file: $!";
    $/ = undef;
    my $filestr = <$fh>;

    my ( $LastScanTime,
         $NextExecuteTime,
         $NextExecuteTimeSet,
         $MinutesToRun,
         $TaskID,
         $ID,
         $ProcScheduler,
         $ProcName,
         $Active,
         $PassArguments,
         $OwnSection,
         $OwnUnit,
         $Executable,
         $ExecutableType,
         $TextOffset            ) = unpack $template, $filestr;


 ...

See   
    perldoc -f pack     for info about setting up $template
    perldoc -f read     for how to read a specific amount of bytes from a file
    perldoc perltoc     if there's something else you wonder about ...

HTH,
-- 
Vlad


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

Date: Fri, 05 Sep 2003 18:04:26 -0500
From: David McDivitt <david-del@del-nonspiritual.com>
Subject: Re: read VB file with Perl
Message-Id: <ia5ilvgcm7ul4dvkbt98cali6tjc7kqqgu@4ax.com>

I posted to VB and Perl forums. What I can tell Perl reads and writes
string ascii data natively, only. As I get further into the language I
am sure I can read a byte at a time from the header and reconstruct VB
data types with some algorithm. That would be a pain though. I am hoping
someone has some code or at least suggest methodology so I don't have to
reinvent the wheel. As prolific as these two languages are, surely
someone has done something similar.

>From: "Andrew Faust" <afaust@aradyme.com.REMOVE>
>Date: Fri, 5 Sep 2003 16:47:43 -0600
>Lines: 20
>
>"David McDivitt" <x12code-del@del-yahoo.com> wrote in message news:462ilvotf8jms9ti5sg2colos9q3t129q4@4ax.com...
><Snip A Question about how to read a binary file written in VB from Perl>
>
>I haven't done much with Perl, but I have done enough to know that
>what you propose is possible. However, you are asking in the wrong
>forum. I would recommend finding a Perl forum and asking how to
>read a binary file. There's no need to even mention it was written
>in VB, as the same principles will apply no matter what language
>your file was written in. Keep in mind though, that in many
>languages Integers are 4 bytes instead of 2, so any response
>you receive may need to be modified to take that in to account.
>
>Andrew Faust



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

Date: Sat, 6 Sep 2003 00:05:40 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: read VB file with Perl
Message-Id: <bjb8ck$sbh$1@troll.powertech.no>

Vlad Tepes <minceme@start.no> wrote:
> David McDivitt <x12code-del@del-yahoo.com> wrote:
>
>     open my $fh, "filename" or die "can't open file: $!";
>     $/ = undef;
>     my $filestr = <$fh>;
>

Oh, I forgot, if you're doing this on windows, you need to call binmode
before you read anything from the file:

>     open my $fh, "filename" or die "can't open file: $!";
binmode( $fh );
>     $/ = undef;
>     my $filestr = <$fh>;

If you're using this for cgi, you might look up on filelocking as well:
perldoc -f flock

Also, if you figure out how many bytes you want to read from the file,
drop the slurping ( $/ = undef, <$fh> ), and use read (you should make
a loop to read bytes until EOF ):

    use Fcntl ':flock'; # import LOCK_* constants
    open my $fh, "filename" or die "can't open file: $!";
    flock($fh,LOCK_EX); # exclusive lock
    # and, in case someone appended
    # while we were waiting...
    seek($fh, 0, 2);
    binmode $fh; # no automatic translation of newlines
    my $readno; # number of bytes to read
    my $chunk;  # scalar to hold what's been read
    my $actuallyread = read $fh, $chunk, $readno;
    warn "read(): $actuallyread bytes, wanted to read $readno"
        if ( $actuallyread != $readno );
    
    # ...

    my @values = unpack $template, $chunk;
    
    # ...
    flock($fh,LOCK_UN); # unlock the file
    close $fh;          # close file


( This is only meant as some quick notes to get you started.
  I'm just off to bed, and I'm often making mistakes when tired, so 
  might have forgotten something.
  Good luck. )
   
Regards,
-- 
Vlad


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

Date: Sat, 06 Sep 2003 03:13:09 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: read VB file with Perl
Message-Id: <3F5950A7.4B8A9790@acm.org>

Vlad Tepes wrote:
> 
> David McDivitt <x12code-del@del-yahoo.com> wrote:
> 
> > I need to get Perl to interpret VB data types when read from the file.
> >
> > This is the VB user defined type:
> >
> > Public Const StatusMaxAppPointer = 57
> > Public Const StatusCommonPointer = 58
> > Public Const StatusResourcePointer = 59
> > Public Const StatusOnCallPointer = 60
> > '
> > Public Type ProcRec
> >     LastScanTime As Date
> >     NextExecuteTime As Date
> >     NextExecuteTimeSet As Integer
> >     MinutesToRun As Long
> >     TaskID As Double
> >     ID As String * 4
> >     ProcScheduler As String * 1
> >     ProcName As String * 30
> >     Active As Integer
> >     PassArguments As Integer
> >     OwnSection As String * 4
> >     OwnUnit As String * 4
> >     Executable As String * 256
> >     ExecutableType As Integer
> >     TextOffset(StatusOnCallPointer, 1) As Long
> >     End Type
> >
> 
> This can be done with unpack(). I don't know enough details about vb types
> to set up a correct $template, but this might get you started:
> 
>     # assuming vb Date is long int, strings are ascii, all ints are unsigned
>     my $template = <<TMPL;
>             L                #     LastScanTime As Date
>             L                #     NextExecuteTime As Date
>             I                #     NextExecuteTimeSet As Integer
>             L                #     MinutesToRun As Long
>             d                #     TaskID As Double
>             A4               #     ID As String * 4
>             A                #     ProcScheduler As String * 1
>             A30              #     ProcName As String * 30
>             I                #     Active As Integer
>             I                #     PassArguments As Integer
>             A4               #     OwnSection As String * 4
>             A4               #     OwnUnit As String * 4
>             A256             #     Executable As String * 256
>             I                #     ExecutableType As Integer
>             L                #     TextOffset(StatusOnCallPointer, 1) As Long

AFAIK (it's been a long time :-) VB doesn't have any unsigned integer
types so you should use s, i and l instead of S, I and L and I'm not
sure if VB's INTEGER type is 16 or 32 bits however the strings look
fine.  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 05 Sep 2003 23:02:10 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Regexp Help
Message-Id: <3f5915d9.259811466@news.erols.com>

raven_riverwind@yahoo.com (raven) wrote:

: The output of lpstat -p on hpux returns this:
: 
: printer sacprn05 is idle.  enabled since Jul 30 12:23
:         fence priority : 0
: 
: I am attempting to grab the printer name and whether or not it is
: idle. The code to do this is:
: 
: if (/^printer (\w+).*(enabled|disabled)/)
: 
: Is there a more efficient way to obtain the desired information using
: a Perl regexp?

What is your gauge of efficiency?  I have to guess you want to
minimize runtime.

Why are you worrying about a match operation that takes microseconds
to perform?  Unless it's going to happen a quadrillion times a day,
fuggetaboutit.

Anyway, the real time-killer will be invoking the external 'lpstat'
command.



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

Date: 5 Sep 2003 16:31:46 -0700
From: raven_riverwind@yahoo.com (raven)
Subject: Re: Regexp Help
Message-Id: <7270d1f8.0309051531.56e6b3d1@posting.google.com>

Thanks for the enlightening reply. Sorry for being vague in my
specification. I am simply tracking the printers, their IPs and the
current disabled/enabled status. In the future I'm sure I'll add more
functionality. Below is the the output of the various commands and the
hack.

lpstat -vsacprn05
device for sacprn05: /dev/null
    remote to: RNP6C8BF9 on 192.168.25.73


#!/usr/contrib/bin/perl -w

# Printer interfaces directory
my $interface = "/etc/lp/interface";
# Printer Array
my @printers = ();

# Get a list of printers
open PRINTER, "lpstat -p |";
while (<PRINTER>) {
    if (/^printer (\w+).*?(enabled|disabled)/) {
        # Push an anonymous hash REFERENCE onto the array
        push @printers, { "name" => "$1", "ip" => "none", "status" =>
"$2" };
    }
}
close PRINTER;

# Gather the IP address of each printer
foreach $printer (@printers) {
    open PRINTER, "lpstat -v$$printer{name} |";
    while (<PRINTER>) {
        next if /^device.*/;
        if (/^\s+remote.*?(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})/) {
            $$printer{ip} = $1;
            last;
        }
    }
    close PRINTER;
    # We hope that the printers with 'none' for IP are JetDirect
    if ($$printer{ip} =~ /none/) {
            open INTERFACE, "$interfaces/$$printer{name}" || die
"Cannot open file!\n";
            while (<INTERFACE>) {
                if (/^PERIPH=(.*)/) {
                    $$printer{ip} = $1;
                    last;
                }
            }
            close INTERFACE;
    }
}

# Display the results
foreach $printer (@printers) {
    print "$$printer{name} / $$printer{ip} / $$printer{status}\n";
}


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

Date: Sat, 06 Sep 2003 03:52:11 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Repost Search
Message-Id: <3F5959CC.417A1932@acm.org>

Jimmy wrote:
> 
> while( <FILEHANDLE> or <FILEHANDLETWO>)
> {
>    $mesAlertes = <FILEHANDLE>;
>    $mesAlertesDeux = <FILEHANDLETWO>;
>    $final = ($mesAlertes, $mesAlertesDeux);
> 
>    print $final;
> }
> 
> Want to make a search in two files, and print data on screen. But if
> the files have the same data, the data will be display once. My code
> don't work. why?
> 
> BTW, i'm a newbie, so thanks to be patient :)

Well, the simple answer is:

@ARGV = ( 'file1', 'file2' );
my %seen;
while ( <> ) {
    print unless $seen{ $_ }++;
    }


John
-- 
use Perl;
program
fulfillment


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

Date: 5 Sep 2003 22:34:24 -0500
From: john <wenjoh26@emNOSPAMail.pct.edu>
Subject: uping and downing letters
Message-Id: <Xns93EDEFDD2B9BFwenjoh26emNOSPAMailp@216.65.98.9>

Howdy,

    looking for a way to change letter
 
# example
  # a would become b, A would become B, b=c, c=d etc for upping or
  # b would become a, B would become A, etc.

    	Ive tried a couple different things and just cant come up with a 
way to do it. Would converting it to hex then changing help. and if so 
how would i increment it. Or does there happento be a module with this 
already done. I can do it the long way with lots of ifs but was hoping 
there would be a less code intensive, simpler way to do it.
    	I have to be able to use a-z,A-Z,0-9, - and _ and after upping and 
downing I have to be able to get the original letter back.

    	code, links, manpages would be appreciated

thanks john 
   


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

Date: Sat, 06 Sep 2003 03:59:56 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: uping and downing letters
Message-Id: <3f595928.277044681@news.erols.com>

john <wenjoh26@emNOSPAMail.pct.edu> wrote:

:     looking for a way to change letter
:  
: # example
:   # a would become b, A would become B, b=c, c=d etc for upping or
:   # b would become a, B would become A, etc.
: 
:     	Ive tried a couple different things and just cant come up with a 
: way to do it.

What techniques have you tried?  How were those techniques
unacceptable?

:     	I have to be able to use a-z,A-Z,0-9, - and _ and after upping and 
: downing I have to be able to get the original letter back.

The spec needs a little more fleshing out.

How should the edge cases be handled?  For example, should an
incremented 'z' become whatever is next in the ASCII character set,
should it wrap back to 'a', turn into 'A', or something else?  What
should an incremented or decremented '-' or '_' become?

Do you wish to change all the characters in a string, or only one
character?

The chr() and ord() functions may be what you want.
Or the tr/// operator may be more useful.
It depends.



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

Date: 5 Sep 2003 18:33:54 -0700
From: csdude@hotmail.com (Mike)
Subject: Re: View NG with Net::NNTP
Message-Id: <46cdc619.0309051733.93357cf@posting.google.com>

> $msgid and *STDOUT are optional arguments. To capture the output from the
> function, you simply enter:
> my $text = $nntp->article;
> { do something with $text }


When I do that, the output I get is:
ARRAY(0x15f1a0c)

My exact code snippet is:
my $text = $nntp->article;
  $text =~ tr/\n/<br>/;
  # also tried using:
  # my @body =~ split(/\n/, $text);
  print "$text";

In fact, it actually prints the entire article without changing the \n
to <br>, as if it's ignoring the "my $text=" section, then after that
it prints "ARRAY(0x15f1a0c)".

I'm thinking that this would work if I could use articlefh instead,
but my server doesn't seem to recognize that. Or is there something
else that I'm noticing?

Thanks again for your help,

Mike


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

Date: Sat, 06 Sep 2003 03:32:16 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: View NG with Net::NNTP
Message-Id: <3F595521.F7CE89B3@acm.org>

Mike wrote:
> 
> > $msgid and *STDOUT are optional arguments. To capture the output from the
> > function, you simply enter:
> > my $text = $nntp->article;
> > { do something with $text }
> 
> When I do that, the output I get is:
> ARRAY(0x15f1a0c)

That is because $nntp->article returns a reference to an array.  You
have to dereference the array to access its contents.


> My exact code snippet is:
> my $text = $nntp->article;
>   $text =~ tr/\n/<br>/;
                   ^^^^
You can't use tr/// on strings.  That will replace all "\n" characters
with the '<' character.  The characters 'b', 'r' and '>' will be
ignored.


>   # also tried using:
>   # my @body =~ split(/\n/, $text);
>   print "$text";

s/\n/<br>/ for @$text;

print @$text;


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 05 Sep 2003 18:18:22 -0600
From: Ron Reidy <r_reidy@comcast.net>
Subject: Re: Weird interaction between Net::FTP and DBI / DBD::Oracle
Message-Id: <3F5927CE.4070304@comcast.net>

The database things do not have anything to do with this (my bet, 
anyway).  To make sure, have you tried tracing the db handle to see what 
is happening?

Maybe you could post some code here?

Peter Mutsaers wrote:
> Using perl 5.8.0 and latest versions of libnet and DBI:
> 
> The script did 
> 
> - open DBI to oracle
> - start queries and write in 2 files
> - close files
> - close DB
> - open FTP (Net::FTP->new)
> 
> result: the open FTP fails immediately with a connection timeout, even
> though the timeout is 120s (I also tried some other explicit settings
> and traced into IO::Socket).
> 
> When I reverse the 2 last steps, i.e. I close the DB handle after the
> Net::Ftp->new, there is no problem.
> 
> Note: the FTP->new fails only when the server takes more than about 1
> second to respond. For fast local servers the problem did not occur at
> all.
> 
> Someone has an idea how this can be? Could the closing of the
> DBD::Oracle handle throw some signal (this is on Solaris btw) after 1
> second which confuses IO::Socket?
> 
> Thanks,
> 
> Peter Mutsaers


-- 
Ron Reidy
Oracle DBA



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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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