[17922] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 82 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 17 18:06:21 2001

Date: Wed, 17 Jan 2001 15:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979772715-v10-i82@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 17 Jan 2001     Volume: 10 Number: 82

Today's topics:
    Re: $foo{$bar}={x=>$x,y=>$y} v. $foo{$bar}{x}=$x etc? gnari@my-deja.com
    Re: converting Internet Explorer 'favorites' to Netscap (Monte Phillips)
        excel to csv tools rbfitzpa@my-deja.com
    Re: FAQ 9.10:   How do I redirect to another page? <flavell@mail.cern.ch>
    Re: File info on win32 grehom@my-deja.com
        Flow Chart <mysangam@my-deja.com>
    Re: Forwarding NT Event Log to Syslog <lmoran@wtsg.com>
    Re: How to convert a double-spaced file to single space (Ben Okopnik)
    Re: How to convert a double-spaced file to single space (Colin Watson)
    Re: How to Create a Perl Shared Library (.so file) ? hmug@my-deja.com
    Re: How to Create a Perl Shared Library (.so file) ? hmug@my-deja.com
        Keyboard Character Map Conversion <ncharette@earthlink.net>
    Re: Multiple Substitution <ken.chesak@dhs.state.tx.us>
    Re: Multiple Substitution <ken.chesak@dhs.state.tx.us>
    Re: Multiple Substitution <ren.maddox@tivoli.com>
    Re: Multiple Substitution <ronnie@catlover.com>
    Re: Need some expert guidance with HTTP::Request (LWP,  Lee.Lindley@bigfoot.com
    Re: newbie question mike_solomon@lineone.net
    Re: One line file doesn't work... <ethan@suttung.gso.saic.com>
    Re: Passing a parameter to a "sort" sub? <joe+usenet@sunstarsys.com>
    Re: passing a variable... what am i doing wrong??? <ronnie@catlover.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Jan 2001 19:29:05 GMT
From: gnari@my-deja.com
Subject: Re: $foo{$bar}={x=>$x,y=>$y} v. $foo{$bar}{x}=$x etc?
Message-Id: <944rpk$di7$1@nnrp1.deja.com>

In article <Pine.WNT.4.30.0101171332230.163-100000@supc16.rdg.ac.uk>,
  John Stumbles <visstmbl@reading.ac.uk> wrote:

> Yes I do have a loop: I'm querying a mySQL database using the DBI:
>
> while ($sth->fetch)
> {
> #    $ifTable{$ifIndex} = {
> #            Name            =>  $Name,
> #            Speed           =>  $Speed,
> #        } ;
>     $ifTable{$ifIndex}{Name}            =   $Name ;
>     $ifTable{$ifIndex}{Speed}           =   $Speed ;
>
snip

the difference between these two is that the first one creates
a new hash with only 2 members ,but the second one adds/changes 2
members of a hash that may already exist and leaves any other members
unchanged, for example $ifTable{$ifIndex}{dot1d}

so if you are also setting $ifTable{$ifIndex}{dot1d}{$MAC} with
different values for $MAC within the loop, and expect to collect
them all, you should not use the first method.

hope this makes it clear

gnari



Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 17 Jan 2001 19:16:25 GMT
From: montep@hal-pc.org (Monte Phillips)
Subject: Re: converting Internet Explorer 'favorites' to Netscape bookmark file
Message-Id: <3a65eeff.45166285@news.hal-pc.org>

On Wed, 17 Jan 2001 12:32:20 +0000, rob <nospam@ireland.com> wrote:

>Hi
>I'm trying to import the favourites I've created in IE to Netscape.  IE
>uses a .url file for the actual link, so in my favourites, I can click
>"MSN" which uses information from the file below.

Although IE has an Export option<grin>  You might look at the
following for some interesting methods.
You simply place this file in the Favorites directory you want to
convert, and run it.

----------------------------------------------
#!/usr/bin/perl
#
# BM.PL 1.0 May 26, 1997
# Copyright (C) 1997 John Watson
# email: john@watson-net.com
#
# -----About BM.PL-----
# BM.PL converts between Internet Explorer Favorites and Navigator
# Bookmarks.  This is almost essential if you, like me, use both
# browsers.  BM.PL will convert a Navigator bookmark file into
# favorites and favorites into a Navigator bookmark file.
#
# BM.PL was developed and tested on a Windows 95 system.  It may or
may
# not work on other operating systems although I don't think I did
anything
# Windows 95 specific that would prevent it.  Let me know if it didn't
work
# OOTB and what you had to do to get it to work so I can fix it.
# 
# The latest copy of this script and documentation can be obtained
from
# http://www.watson-net.com/
#
# -----Distribution-----
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

require 'newgetopt.pl';

# get program name and strip off path
$progname = $0;
$progname =~ s#^(.*)/##i;

$credit = <<EOT;
BM.PL 1.0 by John Watson (john\@watson-net.com)
Copyright (C) 1997 John Watson
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License.
This program comes with absolutely no warranty.
EOT

print "$credit\n";

# get options
#
# -fav2bm = convert IE favorites to Navigator bookmarks
# -bm2fav = convert Navigator bookmarks to IE favorites
# -d      = depth (0..x).  how many folder levels deep to go.
# -dir    = starting directory for -fav2bm
# -sort   = sort bookmarks for -fav2bm
# -t      = title for bookmark file for -fav2bm
# -u      = usage
NGetOpt('fav2bm', 'bm2fav', 'd:i', 'dir:s', 'sort', 'u', 't:s');
$opt_f = $ARGV[0];

# if -u show usage info and quit
if ($opt_u) {
    usage();
    exit;
}

# if no -dir then default dir is current
if (!defined($opt_dir) || $opt_dir eq "") { $opt_dir = "."; }

# if no -f or no filename then error, usage, and quit
if (!defined($opt_f) || $opt_f eq "") {
    print "Error: You must specify a filename.\n\n";
    usage();
    exit;
}

# if no -fav2bm or -bm2fav then error, usage, and quit
if (!defined($opt_fav2bm) && !defined($opt_bm2fav)) {
    print "Error: You must specify either -fav2bm or -bm2fav.\n\n";
    usage();
    exit;
}

if (!defined($opt_t) || $opt_t eq "") {
    $opt_t = "Converted Favorites"
}

# convert favorites to bookmarks (-fav2bm)
if ($opt_fav2bm) {
    # if file already exists then error, usage, and quit
    if (-e $opt_f) {
        print "Error: The file you specified already exists.\n\n";
        usage();
        exit;
    }

    # else open output file for writing
    open(FILE,">$opt_f") || die "Can't open output file $opt_f ";
    
    print "Working...";

    # print bookmark header info
    print FILE "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n";
    print FILE "<title>$opt_t</title>\n";
    print FILE "<h1>$opt_t</h1>\n";
    print FILE "<dl><p>\n";
    
    # call fav2bm which actually does the conversion
    fav2bm($opt_dir, 0);
    
    print FILE "</dl><p>\n";

    print "done.\n";

    # close output file
    close(FILE);
    
    exit;
}

# convert bookmark file to favorites (-bm2fav)
if ($opt_bm2fav) {
    # open bookmark file for reading and read all lines
    open(FILE,"<$opt_f") || die "Can't open input file $opt_f ";
    @bmfile = <FILE>;
    close(FILE);

    # if the first line is not <!DOCTYPE NETSCAPE-Bookmark-file-1>
    # then this is not a Netscape bookmark file.  Error, usage, quit.
    if ($bmfile[0] !~ /NETSCAPE-Bookmark-file/i) {
        print "Error: You must specify a valid Netscape bookmark
file.\n\n";
        usage();
        exit;
    }

    print "Working...";
    
    # call bm2fav which actually does the conversion
    bm2fav();
    
    print "done.\n";
    
    exit;
}

# recursive subroutine which converts favorites to bookmarks by
# traversing all directories and sub-directories of the starting
# dir (current or -dir) and reading every .url file.
sub fav2bm {
    # get parameters
    my ($dir, $level) = @_;

    # get list of directories in this directory
    my @dirs = getdirs($dir);
    # if we are at max depth then go no farther
    if (defined($opt_d) && $opt_d >= 0 && $opt_d == $level) {
        @dirs = ();
    }

    # for each directory...
    foreach(@dirs) {
        print ".";
        
        # print title for bookmark folder
        $title = "$dir/$_";
        $title =~ s@^(.*)/@@ig;
        # create a folder if not the root dir
        if ($title ne $opt_dir) {
            print FILE "<dt><h3>$title</h3>\n";
            print FILE "<dl><p>\n";
        };
        # recurse into this directory
        fav2bm("$dir/$_", $level + 1);
    }

    # make a bookmark for each .url file in this directory
    foreach(getfiles("$dir")) {
        print FILE "<dt><a
href=\"",geturl("$dir/$_.url"),"\">$_</a>\n";
    }

    # don't create a folder for the root dir
    if ($title ne $opt_dir) { print FILE "</dl><p>\n"; }
    
    return;
}

# converts a bookmark file into the many .url files and folders
# that make up favorites.  @bmfile contains each line of the
# bookmark file.
sub bm2fav {
    # illegal file characters stripped out of bookmarks
    $ILLEGAL_FILE_CHARS = '(\%|\*|\||;|:|\"|<|>|\/|\?|=)';

    $level = -1;

    # for each line in the bookmark file
    foreach(@bmfile) {
        $title = "";
        $url = "";
        $urltitle = "";

        # if the current line has <h3> in it then this is a folder
        $line = $_;
        $line =~ s@.*?<h3.*?>(.*?)</h3>.*?@$title=$1@ie;

        # if the current line has <a> in it then this is a bookmark
        $line = $_;
        $line =~ s@.*?<a.*?>(.*?)</a>.*?@$urltitle=$1@ie;

        # get the address of the bookmark
        $line = $_;
        $line =~ s@.*?href="(.*?)".*?@$url=$1@ie;

        # bookmark files are loose <dl> structures.  each
        # <dl> signifies a following list of sub-objects.
        # increase level for each <dl>
        if ($_ =~ m@<dl>@i) {
            $level++;
        }

        # decrease level for each </dl>. also move back up a
        # directory if we are still within our depth
        if ($_ =~ m@</dl>@i) {
            $level--;
            if ((defined($opt_d) && $opt_d >= 0 && $level < $opt_d) ||
!defined($opt_d)) {
                chdir("../");
            }
        }

        # if we are within our depth then make a directory for
        # this bookmark folder and change the working dir
        if ((defined($opt_d) && $opt_d >= 0 && $level < $opt_d) ||
!defined($opt_d)) {
            if ($title) {
                print ".";
                
                # remove invalid characters
                $title =~ s@$ILLEGAL_FILE_CHARS@@ig;
                
                mkdir($title, 0);
                chdir($title);
            }
        }

        # if we are within our depth then create a .url file for
        # this bookmark.  note that a folders bookmarks are at
        # one level deeper than the folder itself.  therefore, since
        # we do not want to create empty folders, the check for
        # depth is <= instead of just < .
        if ((defined($opt_d) && $opt_d >= 0 && $level <= $opt_d) ||
!defined($opt_d)) {
            if ($url) {
                # remove invalid characters
                $urltitle =~ s@$ILLEGAL_FILE_CHARS@@ig;
                
                open(URLFILE,">$urltitle.url") || die "Can't create
file $urltitle.url ";
                print URLFILE "[InternetShortcut]\n";
                print URLFILE "URL=$url";
                close(URLFILE)
            }
        }
    }
}

# given a directory as a parameter, return a list of its immediate
# sub-directories.
sub getdirs {
    my $dir = $_[0];
    my @list = ();
    my @dirs = ();
    
    opendir(DIR,"$dir");
    @list = readdir(DIR);
    closedir(DIR);

    # remove . and .. dirs
    foreach(@list) {
        if (-d "$dir/$_" and $_ ne "." and $_ ne "..") { push(@dirs,
$_); }
    }

    # sort if -sort
    @dirs = sort(@dirs) if $opt_sort;
    
    return(@dirs);
}

# given a directory as a parameter, return a list of its files
sub getfiles {
    my $dir = $_[0];
    my @list = ();
    my @files = ();
    
    opendir(DIR,"$dir");
    @list = readdir(DIR);
    closedir(DIR);

    # filter out everything except .url files
    foreach(@list) {
        if (-f "$dir/$_" and $_ =~ /\.url$/i) {
            $_ =~ s/\.url$//i;
            push(@files, $_);
        }
    }

    # sort if -sort
    @files = sort(@files) if $opt_sort;
    
    return(@files);
}

# given a .url file, return the actual URL
sub geturl {
    my $file = $_[0];
    my $junk, $url;

    # read the .url file. .url files have the following format
    #
    # [InternetShortcut]
    # URL=http://.../...
    #
    open(URLFILE,"<$file");
    $junk = <URLFILE>;
    $url = <URLFILE>;
    # strip everything but the URL itself
    $url =~ s/(^url=|\n|\r)//ig;
    close(URLFILE);

    return($url);
}

# usage information
sub usage {
    print <<EOT;
Usage: $progname [switches] filename

You must specify either -fav2bm or -bm2fav and a filename.
All other switches are optional.

Switches:
    -fav2bm     Convert IE favorites to Navigator bookmarks
    -bm2fav     Convert Navigator bookmarks to IE favorites
    -d <n>      Depth to search for folders (default: no limit)
    -dir <dir>  Starting directory for -fav2bm (default: current)
    -sort       Sort bookmarks for -fav2bm
    -t          Boomark file title for -fav2bm (default: Converted
Favorites)
    -u          This usage information
    
EOT
}



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

Date: Wed, 17 Jan 2001 19:49:44 GMT
From: rbfitzpa@my-deja.com
Subject: excel to csv tools
Message-Id: <944t0k$eoc$1@nnrp1.deja.com>

I've seen some perl tools in the past which convert excel spreadsheets
to csv delimited text files, does anyone know where I can find them and
or any documentation?

Unfortunately savine the file in.csv format is not an option.


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 17 Jan 2001 21:55:03 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
To:  <faq@denver.pm.org>
Subject: Re: FAQ 9.10:   How do I redirect to another page?
Message-Id: <Pine.LNX.4.30.0101172115150.23243-100000@lxplus003.cern.ch>

On Wed, 17 Jan 2001, PerlFAQ Server wrote:

>   How do I redirect to another page?
>
>     Instead of sending back a `Content-Type' as the headers of your reply,
>     send back a `Location:' header. Officially this should be a `URI:'
>     header,

Oh, scream.  The robot still has an obsolete version of this FAQ.

That claim about "URI:" doesn't ever seem to have been true in
published HTTP protocols, although it's rumoured that it was a
proposal at one time, many years back.  A URI: header does actually
exist in HTTP/1.0 (though not in 1.1), but it is documented as
informatory - it definitely could not be used as a substitute for the
Location: header.

> so the CGI.pm module (available from CPAN) sends back both:
>
>         Location: http://www.domain.com/newpage
>         URI: http://www.domain.com/newpage

No, it doesn't send URI:, and hasn't done for quite a number of years,
as I understand it (although that misleading old remark had been
present in the POD, unnoticed by the author, until relatively
recently).

This simple detail was reported in Perlbug 20000409.001, and finally
got fixed in the FAQ, but it looks as if it hasn't made it to here.

There's other things that seem to be wrong with this FAQ, but after
I'd tried to raise them a few times, and in fact put some effort into
writing some new text based on some very helpful discussions here with
the regulars, it seemed to fly like a lead balloon when I tried to
raise it with the Perlbugs folks, so I got dispirited.

Look, I _know_ that CGI issues aren't welcome on c.l.p.m, but if FAQs
about it are going to get posted here, I _do_ think it would be useful
if they were accurate in what they say, and not misleading in what
they seem to imply.  I'm a great believer in FAQs and have found the
Perl ones to be most useful to me; I hate to see it when the barrel is
at risk of being spoiled by just a few bad apples, that nobody
seems to be bothered to pull out.


Is there any point in copying this posting to the apparent posting
address?  Well, I suppose I could try.

all the best



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

Date: Wed, 17 Jan 2001 19:36:39 GMT
From: grehom@my-deja.com
Subject: Re: File info on win32
Message-Id: <944s86$e2j$1@nnrp1.deja.com>

#!perl -w

    use strict;

    my $file_name = "/autoexec.bat";

    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,
$size,$atime,$mtime,$ctime,$blksize,$blocks)
        = stat($file_name);
      print "$dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks\n";

    # or better still use this standard module
    use File::stat;

    my $stats = stat($file_name);
    # can now refer to parameters by name!
    print $stats->mtime, ",", $stats->size, ",", $stats->ino, "\n";

    # the modify time is the time in seconds since the epoch!
    # To quote 'Programming Perl' Not all fields are supported on all
    # file system types; unsupported fields return 0.
    1;

Example output on my Windows 98 machine:
C:\perlSrcs\test>perl -w test_stat.pl
2,0,33279,1,0,0,2,1103,979689600,979378902,962135366,,
979378902,1103,0

In article <3A6231B4.76862318@patriot.net>,
  H C <carvdawg@patriot.net> wrote:
> perlfunc stat
>
> Rob wrote:
>
> > Does anyone know how to get the created, accessed and modified times
> > for a file on NT 4?  I checked deja and the Perl documentation but
> > didn't find anything.
> >
> > Thanks,
> > Rob
>
> --
> Q: Why is Batman better than Bill Gates?
> A: Batman was able to beat the Penguin.
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 17 Jan 2001 19:31:55 GMT
From: Sangam <mysangam@my-deja.com>
Subject: Flow Chart
Message-Id: <944rvb$dm1$1@nnrp1.deja.com>

 Hi,
 I am looking for utility which can convert perl program into a flow
chart.. ie.. making decsion tree, subroutine calling etc..
I appriciate any pointers.

Thanks..




--
 .
 .
 .
Sangam


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 17 Jan 2001 17:14:28 -0500
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Forwarding NT Event Log to Syslog
Message-Id: <m05c6tc12prkb8shqkkqkt22mdbrekuv7t@4ax.com>

On Wed, 17 Jan 2001 14:54:32 GMT, RUATurtle <jack.haberle@bigfoot.com>
wrote wonderful things about sparkplugs:

>Hi,
>
>I'm looking for a way to forward NT Eventlogs to a syslog on a Linux
>box.  I've found some shareware (Adiscon EventReporter; $29/license) but
>no luck thus far finding something completely free.

<rant>
Hint:  Writing Software is hard work.  $29 bucks is "practically"
free.  Assuming the product works I would suggest you purchase it.

Open Source does not me Free...
</rant>

>
>Any hints that anyone might offer will be appreciated.
>
>TIA,
>-J
>
>
>Sent via Deja.com
>http://www.deja.com/


lmoran@wtsgSPAM.com
print "\x{263a}"


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

Date: 17 Jan 2001 20:45:42 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: How to convert a double-spaced file to single spaced?
Message-Id: <slrn96c186.2b5.ben-fuzzybear@Odin.Thor>

The ancient archives of Wed, 17 Jan 2001 05:15:32 GMT showed
Uri Guttman of comp.lang.perl.misc speaking thus:
>>>>>> "BO" == Ben Okopnik <ben-fuzzybear@geocities.com> writes:
>
>  >>> perl -pi~ -wp0e's/\n\n/\n/g' in
>  >> 
>  >> The only thing I see that could be `wrong' is that -p is included
>  >> twice. 
>
>  BO> Believe it or not, up until now, I thought that the 'pi' switch
>  BO> had nothing to do with 'p' (I've actually got a Perl book I can
>  BO> blame this on, though. :\) Testing shows me wrong.
>
>all of perl's command line options are single chars. which book had that
>stupidity? and you should always refer to perlrun for that anyway to be
>sure.


Nowadays, "perldoc" is the first (and usually the only) place I go for that
kind of info. I've been very cautiously grepping here for anybody knocking
the Camel or the Sheep, and have tentatively decided to buy them. My
"Complete Reference" and the Quigley book are already slotted for the Oval
File. <sigh> What a waste.


Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Make things as simple as possible, but not simpler. -- Albert Einstein


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

Date: 17 Jan 2001 22:10:45 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: How to convert a double-spaced file to single spaced?
Message-Id: <945595$ra2$1@riva.ucam.org>

Stephen Kloder <stephenk@cc.gatech.edu> wrote:
>Colin Watson wrote:
>> Either of these, depending on which way round your spacing is:
>>
>>   perl -ne 'print if $i = !$i'
>>   perl -ne 'print unless $i = !$i'
>
>Slightly shorter and cleverer:
>perl -pe '$_ x=$.%2'
>perl -pe '$_ x=!($.%2)'

Cute. These take fewer strokes, though they're less symmetric:

  perl -pe '$_=<>'
  perl -ne 'print;$_=<>'

For the second of those, this is longer, but amusing if you haven't seen
it before:

  perl -ne 'print}continue{$_=<>'

-- 
Colin Watson                                     [cjw44@flatline.org.uk]
"However, most netters acknowledge the offline world's advantages,
 despite the fact that it is slow, clunky, and hogs bandwidth."
  - "Surfing on the Internet", J.C. Herz


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

Date: Wed, 17 Jan 2001 19:14:34 GMT
From: hmug@my-deja.com
Subject: Re: How to Create a Perl Shared Library (.so file) ?
Message-Id: <944qui$cop$1@nnrp1.deja.com>

Hi Anno,

Many Thanks!! I was nearly running mad!


Might you know how I can embed perl in C? Or do you have any nice
pointers?

Your help is highly appreciated

Henry



In article <9448mu$h91$1@mamenchi.zrz.TU-Berlin.DE>,
  anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>  <hmug@my-deja.com> wrote in comp.lang.perl.misc:
> >Hi
> >
> >I would like to create a shared library (.so file) from a prel script
> >which I would like to use inn my PL/SQL procedure.
> >
> >Can someone educate me on how I can go about creating the .so file
> >given the perl script. Do I need to add anything in the perl script
to
> >make creation of the shared library feasible?
>
> Can't be done.  You need a language that compiles to native machine
> code to make a shared library.  Perl isn't one of those languages.
>
> It may be possible to embed perl in another language to finally
> arrive at a shared library that *behaves* as if it defined Perl
> functions for other programs to use, but that would be, umm,
> adventurous.
>
> Anno
>


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 17 Jan 2001 19:23:34 GMT
From: hmug@my-deja.com
Subject: Re: How to Create a Perl Shared Library (.so file) ?
Message-Id: <944rfb$das$1@nnrp1.deja.com>

Hey buddy,

Dont worry. I found it. Thanks for the help.

In case you are as crazy, find it at:

http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlembed.html#Compiling_your
_C_program

Henry




In article <944qui$cop$1@nnrp1.deja.com>,
  hmug@my-deja.com wrote:
> Hi Anno,
>
> Many Thanks!! I was nearly running mad!
>
> Might you know how I can embed perl in C? Or do you have any nice
> pointers?
>
> Your help is highly appreciated
>
> Henry
>
> In article <9448mu$h91$1@mamenchi.zrz.TU-Berlin.DE>,
>   anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> >  <hmug@my-deja.com> wrote in comp.lang.perl.misc:
> > >Hi
> > >
> > >I would like to create a shared library (.so file) from a prel
script
> > >which I would like to use inn my PL/SQL procedure.
> > >
> > >Can someone educate me on how I can go about creating the .so file
> > >given the perl script. Do I need to add anything in the perl script
> to
> > >make creation of the shared library feasible?
> >
> > Can't be done.  You need a language that compiles to native machine
> > code to make a shared library.  Perl isn't one of those languages.
> >
> > It may be possible to embed perl in another language to finally
> > arrive at a shared library that *behaves* as if it defined Perl
> > functions for other programs to use, but that would be, umm,
> > adventurous.
> >
> > Anno
> >
>
> Sent via Deja.com
> http://www.deja.com/
>


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 17 Jan 2001 20:03:27 GMT
From: "Norm" <ncharette@earthlink.net>
Subject: Keyboard Character Map Conversion
Message-Id: <jUm96.6796$KE.484528@newsread2.prod.itd.earthlink.net>

Hi Everyone,

Is there a module available for Perl that would addapt the Korean characters
entered through the keyboard to be properly read and writen by Perl?

I have a Korean client that when he submit an online form to my Perl script
where the information get stored in the flat database Perl file all mangle
where it does not make sense.

What if the fix for that is there any add on modules?

Thank you in advance for your time in replying to my request.

Normand Charette




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

Date: Wed, 17 Jan 2001 15:16:20 -0600
From: "Ken Chesak" <ken.chesak@dhs.state.tx.us>
Subject: Re: Multiple Substitution
Message-Id: <94525c$ab4$1@goblin.tdh.state.tx.us>

I believe the single quote is part of %encode, see the last line.

%encode = ( '&' => '&amp;',
         '<' => '&lt;',
         '>' => '&gt;',
         '"' => '&quot;',
         '\'' => '&singleq;' );

Ren Maddox wrote in message ...
>"Ken Chesak" <ken.chesak@dhs.state.tx.us> writes:
>
>> $data =~ s/([&<">])/$::encode{$1}/g;
>
>This stuff     ^^^^  is a list of characters to replace.  Notably, '
>is not included in that list.  Include it and all should be well.
>
>--
>Ren Maddox
>ren@tivoli.com




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

Date: Wed, 17 Jan 2001 15:20:32 -0600
From: "Ken Chesak" <ken.chesak@dhs.state.tx.us>
Subject: Re: Multiple Substitution
Message-Id: <9452d8$ajr$1@goblin.tdh.state.tx.us>

Thanks for your reply.  I dont understand the "no Single quote there"
comment.  The single quote is included in %encode.

I changed to your code;
$data =~ s/(.)/defined($encode{$1})?$encode{$1}:$1/eg;
And this works for all items.

Of course this is another regular expression to figure out, but what the
heck.

Thanks again.

>>
>> $data =~ s/([&<">])/$::encode{$1}/g;
>               ^^^^
>
>No single quote there.
>





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

Date: 17 Jan 2001 15:21:36 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Multiple Substitution
Message-Id: <m3n1cpyivz.fsf@dhcp11-177.support.tivoli.com>

[Jeopardectomy]

"Ken Chesak" <ken.chesak@dhs.state.tx.us> writes:

> Ren Maddox wrote in message ...
> >"Ken Chesak" <ken.chesak@dhs.state.tx.us> writes:
> >
> >> $data =~ s/([&<">])/$::encode{$1}/g;
> >
> >This stuff     ^^^^  is a list of characters to replace.  Notably, '
> >is not included in that list.  Include it and all should be well.
> 
> 
> I believe the single quote is part of %encode, see the last line.

Yes, it is part of %encode, but it is not included in the pattern of
characters to match in the line above, so it is never replaced.
Change the substitution to:

  $data =~ s/([&<>"'])/$::encode{$1}/g;

(I would also declare %encode with a "my %encode" above so that I
could leave out the "::" bit here.)

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 17 Jan 2001 17:05:56 -0500
From: Ron Grabowski <ronnie@catlover.com>
Subject: Re: Multiple Substitution
Message-Id: <3A661744.47A0A2A2@catlover.com>

> I believe the single quote is part of %encode, see the last line.
> 
> %encode = ( '&' => '&amp;',
>          '<' => '&lt;',
>          '>' => '&gt;',
>          '"' => '&quot;',
>          '\'' => '&singleq;' );

No, its a slash followed by a single quote as everything between single
quotes are literals.

 "'" => '&signleq;'

should do it. qq|'| or q|'| would also work.

- Ron


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

Date: Wed, 17 Jan 2001 21:49:38 GMT
From: Lee.Lindley@bigfoot.com
Subject: Re: Need some expert guidance with HTTP::Request (LWP, libwww) and returned error. Short test code included
Message-Id: <94541f$lso$1@nnrp1.deja.com>

In article <kUq86.25$CM6.7001@nsw.nnrp.telstra.net>,
  "Merlin" <robert@chalmers.com.au> wrote:
>
> This is a little strange. I'm sure I'm missing something simple here.
>
> If I put this little bit of code into a script of it's own. test.pl
say,
> with #!/usr/local/bin/perl at the start etc. remove the 'sub esecpay
{' and
> closing '}', and run it, it works - returning the appropriate
response. In
> other words, it appears to work fine, and do what it's suposed to do.
> however, .... when I call it as  subroutine it comes up with the error
shown
> just below the code..

Are you sure that it works fine? Is there more code that you are not
showing?
>
> =================================
> sub esecpay {
>
> use LWP::UserAgent;
> my $ua = new LWP::UserAgent;
> $ua->agent("AgentName/0.1 " . $ua->agent);
> #create request
> my $req = new HTTP::Request POST =>

Where is the subroutine named POST defined?  I don't see a
use HTTP::Request::Common

Did you try running it through the debugger?

--
// Lee.Lindley@Bigfoot.com


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 17 Jan 2001 18:55:15 GMT
From: mike_solomon@lineone.net
Subject: Re: newbie question
Message-Id: <944pqe$bmm$1@nnrp1.deja.com>

In article <3A65D6F1.66C58F5C@bc.edu>,
  kevin lary <laryk@bc.edu> wrote:
> I am new to both PERL and this list, so am sure I am asking the most
> basic of questions - but since I can't find the syntax in either
printed
> or online documentation I thought this august group would probably
have
> the answer.
>
> Q: What is the syntax for running a C program from within a batch PERL
> file?
>
> The syntax I use to execute the program from the command line is
>
> csh -f $someprogram/someoption
> parameter1,parameter2,parameter3,parameter4,parameter5,parameter6
>
> when I put this in a .pl file and try to run it I get error messages:
>
> Unquoted string "csh" may clash with future reserved word at
> pliftest01.pl line 1.
>
> I have tried putting various parts of the string in quotes which
results
> in _different_ error messages, but I can't get the thing to work.
>
> Any help would be greatly appreciated.  Also fyi in case it is
> significant, parameters 5 & 6 are the percent sign (%) and the plus
> sign(+).
>
> Thank you,
>
> k.lary
>
> --
>
> K.Lary / Applications Developer / Boston College
>

try looking at

perldoc -f system


Regards


Mike Solomon


Sent via Deja.com
http://www.deja.com/


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

Date: 17 Jan 2001 13:31:58 -0800
From: Ethan Brown <ethan@suttung.gso.saic.com>
Subject: Re: One line file doesn't work...
Message-Id: <vrwvbtsw4x.fsf@suttung.gso.saic.com>

>>>>> "Brett" == br  <br@centurytel.net> writes:

    Brett> I have this in my CGI file #!/usr/local/bin/perl

    Brett> I'm trying to figure out why it won't execute and have
    Brett> taken everything out except that one header.  I have given
    Brett> the directory and file 755 permission.  What am I doing
    Brett> wrong?

    Brett> Thanks, brettr


Sometimes the server configuration requires a "known" file extension
for scripts.  Try ending your file in ".pl" (e.g. foo.pl).  Other
things to check are the location of perl (are you sure it's at
/usr/local/bin/perl), and whether the server will even allow scripts
to be run.

Good luck,

--Ethan Brown
ethan.NOSPAM@ethanbrown.org.NOSPAM


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

Date: 17 Jan 2001 14:42:02 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Passing a parameter to a "sort" sub?
Message-Id: <m3n1cqvud1.fsf@mumonkan.sunstarsys.com>

adelton@fi.muni.cz (Honza Pazdziora) writes:

> You should specify a block and you need to access the magic $a and $b
> in that block. 

$a and $b are package globals, so why do they need to be "accessed" for
sub's in the same package as the "sort" call?

> Along the lines of
> 
> 	foreach my $key ( sort { bytime('total', $a, $b) } ( keys %results )) {
        
What's wrong with 

        foreach my $key ( sort { bytime('total') } keys %results ) {

?


-- 
Joe Schaefer



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

Date: Wed, 17 Jan 2001 17:01:23 -0500
From: Ron Grabowski <ronnie@catlover.com>
Subject: Re: passing a variable... what am i doing wrong???
Message-Id: <3A661633.1C59A87B@catlover.com>

>       print OUT1 ("
> <td ALIGN=LEFT WIDTH=\"84\" BGCOLOR=\"#FFFFFF\" rowspan=\"4\">
> <form method=\"POST\" style=\"float:
> left\"action=\"http://zeus.nhlbi.nih.gov/cgi-bin/pape/save.pl\">
> <p><input type=\"submit\" value=\"Save Changes\" name=\"$dir\"
> style=\"border-style: solid; border-width: 1\"></p>
> <input type=\"hidden\" name=\"$dir\" value=\"$dir\"></form>
> <form method=\"POST\" style=\"float: left\"
> action=\"http://zeus.nhlbi.nih.gov/cgi-bin/pape/delete.pl\">
> <p><input type=\"submit\" value=\"Delete\" name=\"$dir\" style=\"border-
> style: solid; border-width: 1\"></p>
> <input type=\"hidden\" name=\"$dir\" value=\"$dir\"></form>
> </td> \n
> ");

print OUT1 <<END_OF_HTML;
<td ALIGN=LEFT WIDTH="84" BGCOLOR="#FFFFFF" rowspan="4">
  <form method="POST" style="float:left" action="save.pl">
END_OF_HTML

Now you don't have those annoying backslashes everywhere.

> #!/usr/local/bin/perl -w
> use File::Copy;
> use CGI qw(:standard);

use strict;

> my $dir = param("$dir");

my $dir = param($dir);

> printf "$bakfile\n";
> printf $original;

'perldoc -f printf' says:

 Don't fall into the trap of using a printf() when a simple
 print() would do.  The print() is more efficient and less
 error prone.

> copy ("$bakfile", "$original");

Does this return an error on failure? 

copy( $bakfile, $original ) || warn("error with copy(): $!");

> I know there are 2 forms in the first statement, but i want to pass the
> variable to both of them. I thought that this was the way to do it
> because i've done it in a way similar to this, but now it's not working.
> can anyone tell me why?

I don't know what you mean by wanting to pass the variable to both
forms? Do you want to use Perl to create a connection to the webserver
the reside on and submit the form as a normal person would do? If so,
look at the LWP module.

- Ron


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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