[8573] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2190 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 26 19:07:17 1998

Date: Thu, 26 Mar 98 16:00:29 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 26 Mar 1998     Volume: 8 Number: 2190

Today's topics:
        Abort, Retry .. message in Win95 arvind.chhabra@inference.com
        Announce: YAWP 0.04 maurice@hevanet.com
    Re: Bidirectional Filehandle??? <doug@weboneinc.net>
    Re: Copy file command. <jhi@alpha.hut.fi>
    Re: Copy file command. (Michael J Gebis)
    Re: Database vs. Flat-File Queue System hhernand@autrey.com
    Re: Days of the Week <rpsavage@ozemail.com.au>
    Re: find command equivalent in Perl <jkry3025@comenius.ms.mff.cuni.cz>
    Re: find command equivalent in Perl (David B. White)
    Re: help with Hardware ethernet addresses please <NerveGas@see_signature.com>
        Help: on "format" <tkho@technologist.com>
        How to generate a Cartesian product of a varying number <steve.tolkin@fmr.com>
    Re: HTML::Parse Won't pull data out of tables <keithmur@mindspring.com>
    Re: I'll try again... <sowmaster@juicepigs.com>
    Re: NNTP and Perl (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
        Perl internals (Tom Nurkkala)
    Re: Perl internals <aas@sn.no>
    Re: Perl internals <cmargoli@world.northgrum.com>
    Re: PROPOSAL: The Perl Dictionary <keithmur@mindspring.com>
        Replacing of line breaks! <pat@strom.clemson.edu>
    Re: Replacing of line breaks! <jkry3025@comenius.ms.mff.cuni.cz>
    Re: Replacing of line breaks! (Mike Stok)
        Still looking for a way to uninstall??? <doug@ccinet.com>
    Re: Storable problems on Solaris 2.5.1 & 2.6, related t <vandevegt@lucent.com>
    Re: ts: why have "push" and "unshift"? (Ken Fox)
    Re: ts: why have "push" and "unshift"? <stuartc@ind.tansu.com.au>
    Re: ts: why have "push" and "unshift"? (Jason Gloudon)
    Re: verifying email address -- how? <NerveGas@see_signature.com>
    Re: what is wrong with being a novice ?? <keithmur@mindspring.com>
    Re: WinAT Scheduling of perl scripts <jkry3025@comenius.ms.mff.cuni.cz>
    Re: WinAT Scheduling of perl scripts <beadles@nortel.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 26 Mar 1998 15:45:32 -0600
From: arvind.chhabra@inference.com
Subject: Abort, Retry .. message in Win95
Message-Id: <6fei5e$93m$1@nnrp1.dejanews.com>

I am having a very strange problem while running Perl programs under Win 95.
Any programs which have the "glob" function try to access the floppy drive,
even though the path in the "glob" function does not refer to A: drive (I
can hear the floppy drive making that sound) and I get an error message:

General failure reading device
Abort, Retry, Fail?

The sample code is:

    while (defined($in_file = <c:\\windows\\*.dll>))
    {
        print "Found file $in_file\n";
    }
    exit;

The output is:

General failure reading device
Abort, Retry, Fail?f
c:\windows\somedll.DLL c:\windows\anotherdll.DLL c:\windows\yetanother.DLL

The output should be:

Found file c:\windows\somedll.DLL
Found file c:\windows\anotherdll.DLL
Found file c:\windows\yetanother.DLL

Does anyone have an idea what is happening?

Similar thing happens when I try to run the following program:

    open (IN_BUFF, ".\\someprog.exe |");
    while (<IN_BUFF>)
    {
        print $_;
    }
    exit;

Any help would be greatly appreciated.

Thanks

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 26 Mar 1998 17:32:00 -0600
From: maurice@hevanet.com
Subject: Announce: YAWP 0.04
Message-Id: <6feog5$fv2$1@nnrp1.dejanews.com>

YAWP version 0.04 is now available at:

  http://olympia2.adhost.com/~maurice/YAWP-0.04.tar.gz

DESCRIPTION

  This module is an HTML pre-processor for use within CGI scripts.
  It accepts specially written HTML documents, transforms them, and
  then displays the resulting HTML.  This helps to separate the
  code from the display information, and often makes web sites more
  maintainable, flexible, and pretty.

  YAWP recognizes special, proprietary tags within your HTML
  documents which, when processed by this module, allow variable
  interpolation and encoding, flow-control, inclusion of other
  documents, and the execution of Perl code.

>From the Changes file:

0.04 Thu Mar 26 10:15:09 1998

        - Improved variable parsing.
        - Changed disk caching so it can be used in conjunction with
          memory caching.
        - Added aging algorithm to evict old cached documents if a
          user-definable memory limit is exceeded.
        - Paths are considered relative to $self->path() only
          if they are relative.
        - Moved initialization code into initialize().
        - Removed File::PathConvert dependency.  The cwd() calls were
          too slow ... we're doing it ourselves now.
        - path() changed to base()
        - base() defaults to current working directory now.

- Maurice Aubrey <maurice@hevanet.com>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 26 Mar 1998 17:17:23 -0500
From: Douglas Clifton <doug@weboneinc.net>
To: TobiasBugala@swol.de
Subject: Re: Bidirectional Filehandle???
Message-Id: <351AD3F3.D94A9EF8@weboneinc.net>

Tobias Bugala wrote:
> 
> Hi,
> 
> I have a file in wich a incremeting number is saved. Now I should open
> it once for Read AND Write.
> 
> I tested something like:
> 
> ...
> open (FILE, "+>$filename") or die ...
>   $number = <FILE>;
>   chop $number;
>   $number++;
>   print FILE "$number\n";
> close (FILE);
> ...
> 
> And in the $filename - File should be s.th. like:
> 
> Before:
> 
> 12345
> 
> After:
> 
> 12346

[posted and mailed]

If you open it for "+>" you get both read and write access
to the file, however the file will be truncated so a read
is impossible.

Use "+>>" (read and append) then seek to the beginning before
you read and again before write, ex.:

open FILE, "+>>$filename" or die "Can't open $filename: $!\n";

seek FILE, 0, 0;   # rewind file
$number = <FILE>;  # read first line
chomp $number;     # remove trailing newline
$number++;         # increment
seek FILE, 0, 0;   # rewind again

# now write and close
print FILE "$number\n";
close FILE;

-- 
Douglas Clifton
Unix/C/Perl/CGI/HTML Programmer
doug@weboneinc.com


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

Date: 27 Mar 1998 00:52:44 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Copy file command.
Message-Id: <oeevht1oyir.fsf@alpha.hut.fi>


jhunterj@lexis-nexis.com (Hunter Johnson) writes:
> In article <35186C32.91198B45@golden.net>,  <tufgar@golden.net> wrote:
> > Is there an actual command to copy or move files or do you have to
> > write a small program?
> 
> There's a rename function, or you can make system function calls.

Neither of which is a good idea.

rename() does work only within same filesystem.  (It's spec'ed
that way: not Perl's fault).

Calling system() is bad for two, well, three or four, reasons.

(1) It's kind of silly to call external program with all the
    power of Perl under our fingertips.

(2) It's also kind of slow to start external programs.

(3) The external program is going to be by definition quite
    non-portable between operating systems so if one day someone
    uses your script somewhere else, kaboom.

    Perl has been ported to about 20 different operating systems
    (and here I am counting all the about 50 different UNIX variants
    as one, and all the MS-DOS/Windows variants as one)

(4) Checking the exact return value of the external command is a bit
    trickier than usual (and again, system-dependent).

The solution?  perldoc File::Copy.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: 26 Mar 1998 23:39:20 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Copy file command.
Message-Id: <6feov8$2v1@mozo.cc.purdue.edu>

Jarkko Hietaniemi <jhi@alpha.hut.fi> writes:

}(1) It's kind of silly to call external program with all the
}    power of Perl under our fingertips.

Part of the power of perl is the ability to easily call external
programs.  It's the UNIX way.  It's simple.  It's code reuse!

}(2) It's also kind of slow to start external programs.

Yes, it may end up executing millions of instructions.  This
could take as long as .006 seconds on my computer.  (Of course,
if you're doing it in a loop, it becomes a concern, but calling
external programs a few times is almost always harmless.
Benchmarking/profiling is really the only way to be certain.)

}(3) The external program is going to be by definition quite
}    non-portable between operating systems so if one day someone
}    uses your script somewhere else, kaboom.

}    Perl has been ported to about 20 different operating systems
}    (and here I am counting all the about 50 different UNIX variants
}    as one, and all the MS-DOS/Windows variants as one)

}(4) Checking the exact return value of the external command is a bit
}    trickier than usual (and again, system-dependent).

These are indeed very good reasons, and are the right answer
as to why you should avoid system calls.

}The solution?  perldoc File::Copy.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Thu, 26 Mar 1998 17:01:29 -0600
From: hhernand@autrey.com
Subject: Re: Database vs. Flat-File Queue System
Message-Id: <6femmt$e9j$1@nnrp1.dejanews.com>

A couple of years ago I designed a messaging queue
system in Perl. Performance was important, so I used
the IPC message queues from operating system.

Later on, I had to distribute my aplications so I wrote
a C server that read from the messages queues and wrote
using sockets through the network. On the other side, messages
were read from the sockets and writen in to the message queue.

The problem with this aproach is that messages will be lost
if the machine goes down. It wasn4t a problem for me since
my data wasn4t that critical(it wasn4t a banking system :)

By the way, I will like to get something similiar, since I
I don4t want to write it again.

Regards,

--
  Humberto

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Fri, 27 Mar 1998 09:39:19 +1000
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Days of the Week
Message-Id: <351AE727.5DF3@ozemail.com.au>

Mike Barnes wrote:
> 
> Anyone out there got a neat little snippet of code, or just a method I can
> use to find out what day of the week a given date fell on?

[snip]

Sure - search the universe for "Zeller's Congruence".

-- 
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au
Web: http://www.ozemail.com.au/~rpsavage


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

Date: Thu, 26 Mar 1998 22:31:32 -0800
From: Jan Krynicky <jkry3025@comenius.ms.mff.cuni.cz>
Subject: Re: find command equivalent in Perl
Message-Id: <351B47C4.6455@comenius.ms.mff.cuni.cz>

sadri@macsch.com wrote:
> 
> Hello Folks;
> 
> I am writing my first Perl Script on WinNT to look inside my temp directory
> and list all files within the directory and subdirectories which are over 5
> days old. So far I could read the content of directory temp but not the
> subdirectories. Eventually I like to sort the content in reverse order and
> assign the result to an Array.
> Is there a nice and easy way of doing this without writing lines of code to do
> this task? I have a Korn Shell script that does that and I 'd like to do thee
> samething with Perl. I use something like this in Korn Shell:
> 
> find ./ -type d -a -mtime +5 -print | sort -u -r
> 
> I was wondering if there was an equivalent Korn shell command "find" in Perl.
> 
> I would appreciate any help.
> 
> Thanks in advance!!!

use File::Find;

sub to_do {
 whatever you want to do with the file whose name is in $_
}

find(\&to_do,'/tmp');

See the embeded docs.

HTH, Jenda


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

Date: 26 Mar 1998 21:33:19 GMT
From: dbwhite@vnet.ibm.com (David B. White)
Subject: Re: find command equivalent in Perl
Message-Id: <6fehiv$s4k$2@mdnews.btv.ibm.com>

In article <6fecui$470$1@nnrp1.dejanews.com>,
        sadri@macsch.com writes:
> samething with Perl. I use something like this in Korn Shell:
>
> find ./ -type d -a -mtime +5 -print | sort -u -r

find2perl ./ -type d -a -mtime +5 -print
returns the following code
which you'll have to adapt to do your own sorting...
------------- snip here -------------------
#!/usr/local/bin/perl
    eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
        if $running_under_some_shell;

require "find.pl";

# Traverse desired filesystems

&find('./');

exit;

sub wanted {
    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    -d _ &&
    (int(-M _) > 5) &&
    print("$name\n");
}
------------- snip here -------------------

> I was wondering if there was an equivalent Korn shell command "find" in Perl.

Yes. See http://www.perl.com/CPAN-local/doc/manual/html/lib/File/Find.html
or page 439 of Programming Perl, Second Edition.

--
David B. White
IBM Microelectronics, Circuit Verification & Design Tools
Internal: dbwhite@btv             Internet: dbwhite@vnet.ibm.com
Phone: 802-769-5671     (TieLine: 446)     Fax: 802-769-5722


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

Date: Thu, 26 Mar 1998 13:39:09 -0700
From: NerveGas <NerveGas@see_signature.com>
To: Doug Browne <dbrowne@indiana.edu>
Subject: Re: help with Hardware ethernet addresses please
Message-Id: <351ABCED.725A@see_signature.com>

> >>Actually i do know what i want from this application. i am looking for
> >>some sort of utility/function, like ping that will "ping a host, from
> >>its hostname"  and query the ethernet of that computer. 

<snip>

<snip>

> If they're NT machines, you can do it rather simply with a `getmac` command
> and format, print, etc with perl.

   If they are Unix machines, you could look into using "arp", or
finding a module that would allow an interface to the address resolution
protocol.

steve
-- 

----------------------------------------
Domain name for replying is "inconnect".
----------------------------------------


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

Date: Thu, 26 Mar 1998 15:03:32 -0800
From: Tommy <tkho@technologist.com>
Subject: Help: on "format"
Message-Id: <351ADEC4.2F1EF99B@technologist.com>

I have a question on "format". I had try to have a format print out.
However, lines are kept missing. Here is the script.

  #!/usr/local/bin/perl -w
  use strict;
  my $A="Test";
  my $B=" 12345678 \r 12345678 \r";
  $~= "A";
  write;

  $B=" 123456789 \r 123456789 \r abc";
  $~= "A";
  write;

  format A=
  @<<< = ^<<<<<<<<<<<<<<<<<<<<<<
  $A,    $B,
  ~      ^<<<<<<<<<<<<<<<<<<<<<<
         $B,
  ~      ^<<<<<<<<<<<<<<<<<<<<<<
         $B,
  ~      ^<<<<<<<<<<<<<<<<<<<<<<
         $B,
  .

  __END__

The actual result is very strange:

  Test =  12345678
  Test =  123456789
         123456789

If I am right, the result should be

  Test =  12345678
          12345678
  Test =  123456789
          123456789
          abc

Can anyone explain why the first one only show one line? Is that a bug
for Perl for Win32s?




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

Date: Thu, 26 Mar 1998 18:19:39 -0500
From: Steven Tolkin <steve.tolkin@fmr.com>
To: steve.tolkin@fmr.com
Subject: How to generate a Cartesian product of a varying number of sets?
Message-Id: <351AE28A.4ACDEA62@fmr.com>

The following snippet of code is an extract from a larger program
that must generate the Cartesian product of a list of sets.
The problem is that the number of sets is not known until runtime.
Two levels are temporarily hard coded.
The most I have (now) is 14, I could use loops nested 14 deep.
(But then need to edit the code if I ever have a few more.)
My approach is to initialize each set to have at least one member
with the magic value of NULL.
When I reach the innermost loop I remove any members that are NULL.
But this seems like such a kludge.
1. How can I handle a variable number of nested loops?
2. It also bothers me that I need to have a hard coded variable at each
level
e.g. $i0 and $i1.  But when I tried to use an array element $dimcol[0]
as
the VAR in a for loop I got a syntax error.  Is there any way around
this?
3. The syntax @{$i[0]} seems ungainly to get the list back from the list
ref,
but @$i[0] failed.  Why?
4. I use perl-mode in emacs.  If I am stuck with all the
loops is there an easy way to make them not indented?
5. I suppose I could dynamically generate the code,
but I have never done that in Perl (yet).
If that is the "right" way to approach this I'd appreciate if someone
could provide a code snippet.

# Prepopulate each level with the dummy value.
for (0..19) {$i[$_]=["NULL"];}

# Temporarily hard code two sets and create references to those lists.
@prod=qw(prod iob ff);
$i[0]=\@prod;
@period=qw(mon qtr yr);
$i[1]=\@period;

my $maxdimcols = 3; # change to allow more -- keep in synch with loop

####  Main Loop -- Produce a Cartesian product of the dimension columns.

for $i0 (@{$i[0]}) {
    $dimcol[0] = $i0;
    for $i1 (@{$i[1]}) {
        $dimcol[1] = $i1;
        for $i2 (@{$i[2]}) {
            $dimcol[2] = $i2;
            # There might be about 20 nested loops
            # but finally we reach the innermost.
            # It is possible that there are non-NULL values after
            # the first NULL.
            for ($j = 0; $j < $maxdimcols; $j ++) {
                if ($dimcol[$j] ne 'NULL') {
                    # Do stuff we want to do
                }
            }
        }
    }
}

Steve
---
Steven Tolkin          steve.tolkin@fmr.com      617-563-0516
Fidelity Investments   82 Devonshire St. R27C    Boston MA 02109
There is nothing so practical as a good theory.  Comments are by me,
not Fidelity Investments, its subsidiaries or affiliates.




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

Date: Thu, 26 Mar 1998 17:09:09 -0600
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: HTML::Parse Won't pull data out of tables
Message-Id: <351AE015.F4F54996@mindspring.com>

Are you sure?  Care to post some code?  Seems to be working for me.  Are
you using TreeBuilder and traversing the whole document?

Jerry Pank wrote:
> 
> I'm Using HTML::Parse to strip tags out so I can build plain text
> versions of web pages to ``feed'' search engines but it ignores text
> within tables.  As > 50% of the data is within tables this presents a
> problem!
> 
> Is there a way using HTML::* that will do this for me?
> 
> I originally tried Tom C's striphtml but I got the following error
> running the file as a pipe or pasting the code directly into my script.
> 
> / <                    # opening angle bracket
> 
>     (?:                 # Non-backreffing grouping paren
>          [^>'"] *      /: regexp *+ operand could be empty at
> striphtml.p
> 53.
> 
> Answers to either would be appreciated.
> --
> Jerry Pank           mailto:jerryp.usenet@connected.demon.co.uk
> 
> And we can always supply them with a program that makes identical files
> into links to a single file.
> -- Larry Wall in <199709292012.NAA09616@wall.org>


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

Date: Thu, 26 Mar 1998 17:56:46 -0500
From: Bob Trieger <sowmaster@juicepigs.com>
To: Jay and/or Blaise <jay.blaise@clear.net.nz>
Subject: Re: I'll try again...
Message-Id: <351ADD2D.6CAE@juicepigs.com>

Jay and/or Blaise wrote:
> 
> Anybody successfully installed the win32 version of Perl?

No! Millions of people don't use perl on win32 machines. You may be the
first if you get it working.

> I'm having a couple of problems that I could use some help with.
> I have read the FAQ, the manual, the readme etc etc.

Not many mind readers in this group. You forgot to mention:
- Which version of perl you are trying to install.
- Where you got your perl distribution.
- Whether the distribution was a precompiled binary.
- Which M$ OS you are trying to install it on.
- What problems you are encountering.
- Did you follow the README to a "T"?


HTH
Bob Trieger
sowmaster@juicepigs.com


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

Date: Thu, 26 Mar 1998 23:35:31 +0200
From: lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
Subject: Re: NNTP and Perl
Message-Id: <lassehp-2603982335320001@ygdrasil.imv.aau.dk>

In article <1d6hq3e.jobk8118phmioN@roxboro0-039.dyn.interpath.net>,
phenix@interpath.com (John Moreno) wrote:
>I've been looking and couldn't find a MacPerl version of libnet, would

MacPerl libnet is at:
ftp://sunsite.cnlab-switch.ch/software/platform/macos/perl/scripts/contrib/schinder

Paul Schinder probably also has a place closer to you, but I couldn't find
the address.

-Lasse


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

Date: 26 Mar 1998 21:31:34 GMT
From: nurkkala@mirage.skypoint.net (Tom Nurkkala)
Subject: Perl internals
Message-Id: <6fehfm$s6t$1@shadow.skypoint.net>

Does there exist any internals documentation for Perl, beyond what's
int the perlguts man page?  I'm interested in learning how things like
arrays of lists of hashes, etc. are actually constructed under the 
hood.  Comments in the source are few.  Is there anything else out 
there that tells more??

thanks,
nurk.

--
Tom Nurkkala, Ph.D.
nurkkala@cs.umn.edu


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

Date: 27 Mar 1998 00:22:34 +0100
From: Gisle Aas <aas@sn.no>
Subject: Re: Perl internals
Message-Id: <m3hg4l2g1x.fsf@furu.g.aas.no>

nurkkala@mirage.skypoint.net (Tom Nurkkala) writes:

> Does there exist any internals documentation for Perl, beyond what's
> int the perlguts man page?  I'm interested in learning how things like
> arrays of lists of hashes, etc. are actually constructed under the 
> hood.  Comments in the source are few.  Is there anything else out 
> there that tells more??

You can perhaps take a look at: http://home.sol.no/~aas/perl/guts/

-- 
Gisle Aas


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

Date: Thu, 26 Mar 1998 22:53:59 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Perl internals
Message-Id: <351ADC87.3275@world.northgrum.com>

Tom Nurkkala wrote:
> 
> Does there exist any internals documentation for Perl, beyond what's
> int the perlguts man page?  I'm interested in learning how things like
> arrays of lists of hashes, etc. are actually constructed under the
> hood.  Comments in the source are few.  Is there anything else out
> there that tells more??
> 

Try "Advanced Perl Programming" by Sriram Srinivasan,
published by O'Reilly.

-- 
Charles G. Margolin                   DSSD Internal Information Services
cmargoli@world.northgrum.com          Northrop Grumman Corp. 0624/23
margolin@acm.org                      Hawthorne, California 90250-3277


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

Date: Thu, 26 Mar 1998 17:23:59 -0600
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: PROPOSAL: The Perl Dictionary
Message-Id: <351AE38F.C81F9BA3@mindspring.com>

Tushar Samant wrote:
> 
> comdog@computerdog.com writes:
> >
> >perlturbation - smalls tweaks in a script.
> 
> I think I know just which word this was really derived from.

No, you're thinking of /.../: matchturbation...


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

Date: Thu, 26 Mar 1998 16:09:21 +0000
From: Patrick Harris <pat@strom.clemson.edu>
Subject: Replacing of line breaks!
Message-Id: <351A7D9F.F77139C5@strom.clemson.edu>

This seemed like a simple problem but it has had me stumped.  I am
taking data from a form on an html page and inserting it into a
database.  One of the fields could be rather long and may contain
returns for formatting.  Since I am later pulling this data back out of
the database for use in a web page, I would like to retain the line
formatting.  After looking at the data, it appears to have the old '^M'
for a line break.  I would like to replace all '^M's with <BR>s.  I am
looking for a regex to handle this or someother way or replacing the
line break characters befor insertion into the database.

Any hints, clues or suggestions welcomed!

pat



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

Date: Thu, 26 Mar 1998 22:41:32 -0800
From: Jan Krynicky <jkry3025@comenius.ms.mff.cuni.cz>
Subject: Re: Replacing of line breaks!
Message-Id: <351B4A1C.55F1@comenius.ms.mff.cuni.cz>

Patrick Harris wrote:
> 
> This seemed like a simple problem but it has had me stumped.  I am
> taking data from a form on an html page and inserting it into a
> database.  One of the fields could be rather long and may contain
> returns for formatting.  Since I am later pulling this data back out of
> the database for use in a web page, I would like to retain the line
> formatting.  After looking at the data, it appears to have the old '^M'
> for a line break.  I would like to replace all '^M's with <BR>s.  I am
> looking for a regex to handle this or someother way or replacing the
> line break characters befor insertion into the database.
> 
> Any hints, clues or suggestions welcomed!
> 
> pat

$string =~ s/\n/<BR>\n/gm;

HTH, Jenda


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

Date: 26 Mar 1998 22:05:58 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Replacing of line breaks!
Message-Id: <6fejg6$2m3@news-central.tiac.net>

In article <351A7D9F.F77139C5@strom.clemson.edu>,
Patrick Harris  <pat@strom.clemson.edu> wrote:

>the database for use in a web page, I would like to retain the line
>formatting.  After looking at the data, it appears to have the old '^M'
>for a line break.  I would like to replace all '^M's with <BR>s.  I am
>looking for a regex to handle this or someother way or replacing the
>line break characters befor insertion into the database.

  $data =~ s/\cM/<BR>/g;

Might be one way to do it if they really are Control-M characters.  The
perlop man page mentions several ways or escaping characters in
double-quotish contexts:

      \033        octal char
      \x1b        hex char
      \c[         control char

  DB<1> $data = "Fin\015de\x0dSihcle"

  DB<2> X data
$data = "Fin\cMde\cMSihcle"
  DB<3> $data =~ s/\cM/<BR>/g 

  DB<4> X data
$data = 'Fin<BR>de<BR>Sihcle'

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Thu, 26 Mar 1998 23:28:31 GMT
From: "Doug Evans" <doug@ccinet.com>
Subject: Still looking for a way to uninstall???
Message-Id: <zwBS.1748$732.104018@katana>

I have the Standard version installed, and would like to change to,
activestate, but am ignorant of how to uninstall the standard version.

Can someone give me directions, as there is no uninstall program, as is
suggested in the FAQ.

Thanks, Doug




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

Date: Thu, 26 Mar 1998 16:40:41 -0600
From: Jim VandeVegt <vandevegt@lucent.com>
To: raphael_manfredi@grenoble.hp.com, wiedmann@neckar-alb.de
Subject: Re: Storable problems on Solaris 2.5.1 & 2.6, related to pRPC.
Message-Id: <351AD969.B3BEBAC2@lucent.com>

Hold everything!

Enabling taint checks causes the error to surface.  I took the -T out of the
perl command line on the scripts that weren't working, and now they all
work.

Hopefully this will point to where the problem is originating.

Thanks for a great RPC system!

I wrote:

> I am using Jochen Wiedmann's pRPC and pNET packages to (attempt) remote
> network connections.
>
> The error I am receiving is "Not a scalar string at
> .../Storable/thaw.al, line 13, at pClient.pm line 304.  I've tracked
> this error message to Storable.xs line 208 inside the MBUF_LOAD macro.
> This macro is being called by the mretrieve function at line 1761.

--Jim VandeVegt
vandevegt@lucent.com



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

Date: 26 Mar 1998 21:19:22 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: ts: why have "push" and "unshift"?
Message-Id: <6fegoq$kjc5@eccws1.dearborn.ford.com>

tsatan@hotmail.com writes:
> Why does perl have the "push" and "unshift" functions? ...
> push @nums, 4; is the same as @nums = (@nums, 4);

What do you want, Scheme? ;)

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: 27 Mar 1998 09:40:22 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: ts: why have "push" and "unshift"?
Message-Id: <yeozpid6mxl.fsf@kudu.ind.tansu.com.au>

tsatan@hotmail.com writes:

> Why does perl have the "push" and "unshift" functions?
> Consider an array: @nums = (1, 2, 3);
> Then: push @nums, 4; is the same as @nums= (@nums, 4);
>  and: unshift @nums, 0; is the same as @nums= (0, @nums);

According to the Blue Camel book, or perldoc -f push :

push ARRAY, LIST

has the same effect as  

for $value (LIST) {
	$ARRAY[++$#ARRAY] = $value;
}

Doing it this way saves copying out the elements of the array like
your implementation does:

@ARRAY = (@ARRAY, @LIST); 
presumably has to copy all the elements of @ARRAY into the RHS.
It still works, just I think it eat up a bit more memory.

Perl has nice pop and shift elements; which can't be written in terms
of a one line array assignment.

$tmp = pop ARRAY; <=> $tmp = $ARRAY[$#ARRAY--];
doesn't look nice in code at all.

The push/pop, shift/unshift operators are provided so that arrays can be 
easily used as stacks. For this purpose they are very useful.

> I know perl's motto is "There's more than one way to do it",
> but these two functions seem especially unnecessary. 
It's nice to be able to complain about there being too many functions
in a language and not too few.

Hope these musings help,

Stuart Cooper
stuartc@ind.tansu.com.au


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

Date: Thu, 26 Mar 1998 23:48:18 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: ts: why have "push" and "unshift"?
Message-Id: <slrn6hlq7f.6e.jgloudon@manitoba.bbn.com>

tsatan@hotmail.com <tsatan@hotmail.com> wrote:
>[sorry, lynx doesn't give me much room to quote]
>Thanks Jarkko and Mike Stok for the speedy responses!
>One follow-up question: any ideas why the perl compiler doesn't
>optimize "@arr = ($x, @arr)" into "unshift @arr, $x"?

Compilers usual attempt to optimize things that occur frequently.

I don't think @arr = ($x, @arr) would be a frequently used construct
among programmers who have read enough to know what unshift and shift do. 
It's certainly easier to type.

Of course, if someone wrote that in a perl program they'd most likely 
be doing much more inefficient things, like doing print "$number", and
passing large hashses to subs without using references.

>Here's a PerlTip: put striped output in your HTML tables like this:
>my @colors = ("#cccccc", "#ccccff"); my $i = 0;

my @colors = ("#cccccc", "#ccccff");
for (my $i=0; $i < @colors; $i++) {
   print qq(<tr bgcolor="$colors[$i % @colors)]"><td>$_</td></tr>);
}

This is more flexible because you can add colors to @colors without touching
anything else. I typically use for instead of foreach when i need to know 
something about the index.

-- 
Jason Gloudon


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

Date: Thu, 26 Mar 1998 13:36:41 -0700
From: NerveGas <NerveGas@see_signature.com>
Subject: Re: verifying email address -- how?
Message-Id: <351ABC59.25CB@see_signature.com>

> > could you provide a suggestion about how to verify the validity of
> > an email address?
> 
> A. Don't bother trying.

  But DO bother to check for shell escapes in their address, if your
script will be working with system commands.  If you do something (very
undesirable) like:

system("cat temp.txt | mail $email_addr");

then all the person has to do is put in the email address
"noone@nobody.net;/bin/rm -r ~/*" .

steve

-- 

----------------------------------------
Domain name for replying is "inconnect".
----------------------------------------


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

Date: Thu, 26 Mar 1998 17:28:47 -0600
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: what is wrong with being a novice ??
Message-Id: <351AE4AF.6048A360@mindspring.com>

Hmmm...  Thanks, I might try it.  I've had some goofy bugs going on with
ActiveState.  I wonder...

Georg Bauer wrote:
> 
> Hi!
> 
> > converters.  I have the ActiveState distribution on Win95, and *damned*
> > if I can find perldoc, pod2*, or any such thing.
> 
> Ok, I should have said "in all complete Perl implementations" :-)
> 
> The ActiveState is hopelessly broken, IMO. I prefer the core
> distribution, especially when you try to build extensions from CPAN. And
> ActiveState is still 5.003, while 5.004 is out quite some time. And the
> core distribution includes all that nice Win32-stuff, too. And, of
> course, perldoc and *.pod.
> 
> bye, Georg
> 
> --
> http://www.westfalen.de/hugo/


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

Date: Thu, 26 Mar 1998 22:49:48 -0800
From: Jan Krynicky <jkry3025@comenius.ms.mff.cuni.cz>
Subject: Re: WinAT Scheduling of perl scripts
Message-Id: <351B4C0C.1991@comenius.ms.mff.cuni.cz>

mlayten@maerskdata-usa.com wrote:
> 
> Yes I've checked the FAQs, yes I've searched the DejaNews archives and found
> only an unresolved post in German which I had translated.
> 
> That said, does anyone know of any quirks of running a Perl script with the
> WinAT scheduler under Windows NT?  I'm successfully running two other jobs
> with WinAT, but the command "c:\perl\bin\perl c:\perl\bin\Create.pl" is not
> creating the appropiate file output (the same command works when typed at the
> c: level of the command prompt).
> 
> Any ideas?
 
Review the account under which the scheduler service runs.
Try to change it to your account to see if it helps.
Is so it may be either permissions issue 
(not very likely but recheck anyway), 
or a "per user" system variables issue 
( Review them in the Properties of My computer/Environment.
  For some reason I cannot grip WinNT set TEMP as an User variable 
  instead of a System one.)
Also notice that the LocalSystem account, Sheduler by default runs 
under, doesn't have access to network.


> Also, I'm running into serious hard drive limitations on my "production"
> machine.  What is the minimum NT install of Perl to run a script?
> (Programming, debugging, etc done on another machine)
> 
> -Melinda Layten

Documents and the sources of Perl if you compiled your perl 
and still have them there. That's about it.

Jenda


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

Date: Thu, 26 Mar 1998 17:16:32 -0600
From: "John T. Beadles" <beadles@nortel.com>
To: mlayten@maerskdata-usa.com
Subject: Re: WinAT Scheduling of perl scripts
Message-Id: <351AE1D0.B1593155@nortel.com>

mlayten@maerskdata-usa.com wrote:
> 
> Yes I've checked the FAQs, yes I've searched the DejaNews archives and found
> only an unresolved post in German which I had translated.
> 
> That said, does anyone know of any quirks of running a Perl script with the
> WinAT scheduler under Windows NT?  I'm successfully running two other jobs
> with WinAT, but the command "c:\perl\bin\perl c:\perl\bin\Create.pl" is not
> creating the appropiate file output (the same command works when typed at the
> c: level of the command prompt).
> 
> Any ideas?
> 

I put the perl call and the script name in a .CMD file, then call the
 .CMD file from the scheduler.  Have a substantial amount of experience
doing this, works fine.


-- 
------------------------------------------------
John T. Beadles            Nortel CDMA RF Design                       
Office: 972-685-7813           Fax: 972-684-3767 
Email (office):    beadles@removethis.nortel.com  
Any opinions are mine and to do not represent
             those of my employer
------------------------------------------------


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2190
**************************************

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