[28903] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 147 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 17 03:09:45 2007

Date: Sat, 17 Feb 2007 00:09:03 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 17 Feb 2007     Volume: 11 Number: 147

Today's topics:
        [ANNOUNCE] Emacs modules for Perl programming (Jari Aalto+mail.perl)
        convert string of keys to multidimensional hash <ppc@cheapbooks.com>
    Re: convert string of keys to multidimensional hash xhoster@gmail.com
    Re: convert string of keys to multidimensional hash <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: How to extract .tar files in different directory? <paduille.4060.mumia.w+nospam@earthlink.net>
        new CPAN modules on Sat Feb 17 2007 (Randal Schwartz)
    Re: New to Perl, OOP inheritance anno4000@radom.zrz.tu-berlin.de
    Re: New to Perl, OOP inheritance <petermichaux@gmail.com>
    Re: Perl:CGI - Creating a Please wait message <maustin@firstdbasource.com>
    Re: problem reading remote file. <noreply@invalid.net>
    Re: problem reading remote file. <nitte.sudhir@gmail.com>
    Re: Regex: Why is overreaching necessary? <shanen@cashette.com>
    Re: Regex: Why is overreaching necessary? anno4000@radom.zrz.tu-berlin.de
        test - disregard sl123@netherlands.area
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 17 Feb 2007 05:34:33 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: [ANNOUNCE] Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1171690431@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
Maintainer: Jari Aalto A T cante net

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Unix Windows port (for Unix die-hards):
            install http://www.cygwin.com/  which includes native Emacs 21.x.
            and XEmacs port

        o   Pure Native Windows port
            http://www.gnu.org/software/emacs/windows/ntemacs.html
            ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

        o   More Emacs resources at
            http://tiny-tools.sourceforge.net/  => Emacs resource page

Emacs Perl Modules

    Cperl -- Perl programming mode

        http://math.berkeley.edu/~ilya/software/emacs/
        by Ilya Zakharevich

        CPerl is major mode for editing perl files. Also included in
        latest Emacs, but newest version is at Ilya's site. Note that
        the directrory at CPAN is out of date:
        http://www.cpan.org/modules/by-authors/id/ILYAZ/cperl-mode/

        Compared to default `perl-mode' that comes with Emacs, this
        one has more features.

    TinyPerl -- Perl related utilities

        http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Grep through all Perl manpages (.pod)
        o   Follow POD references e.g. [perlre] to next pod with RETURN
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.

        o   Update `$VERSION' variable with YYYY.MMDD on save.
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Prepare script (version numbering) and Upload it to PAUSE
        o   Generate autoload STUBS (Devel::SelfStubber) for you
            Perl Module (.pm)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in Tiny Tools Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up dattabases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to to do the search, You can adjust
        recursive grep options, set search case sensitivity, add user grep
        options etc.

        You can find latest `igrep.el' module at
        <http://groups.google.com/groups?group=gnu.emacs.sources> The
        maintainer is Jefin Rodgers <kevinr@ihs.com>.

    TinyCompile -- To Browse grep results in Emacs *compile* buffer

        TinyCompile is a minor mode for *compile* buffer from where
        you can collapse unwanted lines or shorten file URLs:

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->

            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: 16 Feb 2007 15:56:07 -0800
From: "dt" <ppc@cheapbooks.com>
Subject: convert string of keys to multidimensional hash
Message-Id: <1171670166.997406.42140@l53g2000cwa.googlegroups.com>

how do I do this:

convert a string such as "dim1:dim2:dim3"
or array ("dim1", "dim2", "dim3")

to a hash like:
$hash{"dim1"}{"dim2"}{"dim3"}

any help is appreciated



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

Date: 17 Feb 2007 00:55:39 GMT
From: xhoster@gmail.com
Subject: Re: convert string of keys to multidimensional hash
Message-Id: <20070216195648.405$Yc@newsreader.com>

"dt" <ppc@cheapbooks.com> wrote:
> how do I do this:
>
> convert a string such as "dim1:dim2:dim3"
> or array ("dim1", "dim2", "dim3")
>
> to a hash like:
> $hash{"dim1"}{"dim2"}{"dim3"}
>
> any help is appreciated

You want to convert data into source-code?  Are you sure this is what
you really want to do?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Sat, 17 Feb 2007 09:08:01 +0100
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: convert string of keys to multidimensional hash
Message-Id: <45d6b7e1$0$25941$ba4acef3@news.orange.fr>

dt wrote:
> how do I do this:
> 
> convert a string such as "dim1:dim2:dim3"
> or array ("dim1", "dim2", "dim3")
> 
> to a hash like:
> $hash{"dim1"}{"dim2"}{"dim3"}
> 

I'm not entirely sure what you're after, but:

F:\Documents and Settings\Mark3>cat hash.pl
use strict;
use warnings;

use Data::Dumper;

my $string = "dim1:dim2:dim3";

my @items = split /:/,$string;

my %hash = ();

my $lastItem = \%hash;

foreach my $item(@items){
     my $newItem = {};
     $lastItem->{$item} = $newItem;
     $lastItem = $newItem;


}

print Dumper \%hash;


__END__

F:\Documents and Settings\Mark3>perl hash.pl
$VAR1 = {
           'dim1' => {
                       'dim2' => {
                                   'dim3' => {}
                                 }
                     }
         };

may get you started.

Mark


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

Date: Sat, 17 Feb 2007 03:30:34 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: How to extract .tar files in different directory?
Message-Id: <uFuBh.2984$tD2.2168@newsread1.news.pas.earthlink.net>

On 02/16/2007 03:40 PM, au.danji@gmail.com wrote:
> On Feb 16, 12:24 pm, "Mumia W." <paduille.4060.mumia.w
> +nos...@earthlink.net> wrote:
>> On 02/16/2007 08:42 AM, au.da...@gmail.com wrote:
>>
>>> On Feb 15, 4:29 pm, "mar...@gmail.com" <mar...@gmail.com> wrote:
>>>> [...]
>>>> From perl you can execute any unix command using system("cmd").
>>>> Regards,
>>>> Manish
>>> Thanks for all reply, actually, I am running my script in windows XP,
>>> so I can not use unix cmd.
>> You can install the Perl module Archive::Tarto help you with thetarfiles.
>>
>> --
>> Windows Vista and your freedom in conflict:http://www.regdeveloper.co.uk/2006/10/29/microsoft_vista_eula_analysis/
> 
> 
> 
> Thank for everyone's reply!!
> 
> Below is my perl code, which can unzip all .tar file from
> one directory, however, since I have around 20 .tar files
> in this directory(each one is 100MB), when the script running,
> my pc becomes really slow, I guess that because Perl put them
> into the memory, could anyone tell me if I can extract these big
> ..tar files without using large amount of my PC memory? Thanks!
> 
> This is my code:

Please read and follow the posting guidelines for this newsgroup:
http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

Please start your scripts with

use strict;
use warnings;

and write your program to work with them. They will catch many errors 
for you. Also read the documentation for Archive::Tar: 
http://search.cpan.org/dist/Archive-Tar/lib/Archive/Tar.pm


> =============================================================
> opendir(DIR,"$localpath") || die("cannot open $localpath");
> 
> foreach $direntry (readdir(DIR))
> {
>       if ($direntry =~ /tar/)
> 	  {
> 		  print "direntry tar is: $direntry\n";
> 		  if ($tar->read("$localpath/$direntry",1))
> 		  {
> 			  print "read $direntry successfully\n";
> 		  }
> 
> 		  if ($tar->extract())
> 		  {
> 			  print "extract $direntry successfully\n";
> 		  }
> 	  }
> 
> }
> 

I don't have Archive::Tar installed, but it sounds like you can enable 
the "extract" option to have it automatically extract files when "read" 
is called. Change into the desired directory and invoke "read" on the 
$tar object.

> 
> =================================================================
> 
> Also I try to put the unziped files into a different folder, but the
> $tar->extract_file is not working like below code, what is wrong with
> that?
> 
> $tar->extract_file("$localpath/1.tar","$localpath/extract/test");
> 
> 
> thanks a lot!
> 

If the above suggestion works, this should not be needed.


-- 
Windows Vista and your freedom in conflict:
http://techdirt.com/articles/20061019/102225.shtml


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

Date: Sat, 17 Feb 2007 05:42:12 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Feb 17 2007
Message-Id: <JDLEIC.1IGG@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Algorithm-CRF-0.03
http://search.cpan.org/~clsung/Algorithm-CRF-0.03/
Perl binding for CRF++
----
Algorithm-CRF-0.04
http://search.cpan.org/~clsung/Algorithm-CRF-0.04/
Perl binding for CRF++
----
Apache-HTTunnel-0.07
http://search.cpan.org/~patl/Apache-HTTunnel-0.07/
Universal HTTP tunnel using Apache + mod_perl
----
Apache-Logmonster-3.02
http://search.cpan.org/~msimerson/Apache-Logmonster-3.02/
log utility for merging, sorting, and processing web logs
----
Audio-Analyzer-0.01
http://search.cpan.org/~triddle/Audio-Analyzer-0.01/
----
Authen-PluggableCaptcha-0.04
http://search.cpan.org/~jvanasco/Authen-PluggableCaptcha-0.04/
A pluggable Captcha framework for Perl
----
Bio-DOOP-DOOP-0.1
http://search.cpan.org/~tibi/Bio-DOOP-DOOP-0.1/
DOOP API main module
----
Bio-Trace-ABIF-1.00
http://search.cpan.org/~vita/Bio-Trace-ABIF-1.00/
Perl extension for reading and parsing ABIF (Applied Biosystems, Inc. Format) files
----
Business-OnlinePayment-PayPal-0.11
http://search.cpan.org/~plobbes/Business-OnlinePayment-PayPal-0.11/
PayPal backend for Business::OnlinePayment
----
Compress-LZF-1.71
http://search.cpan.org/~mlehmann/Compress-LZF-1.71/
extremely light-weight Lempel-Ziv-Free compression
----
DBIx-Perlish-0.15
http://search.cpan.org/~gruber/DBIx-Perlish-0.15/
a perlish interface to SQL databases
----
DBIx-Perlish-0.16
http://search.cpan.org/~gruber/DBIx-Perlish-0.16/
a perlish interface to SQL databases
----
Daisy-Chain-v0.0.1
http://search.cpan.org/~dmuey/Daisy-Chain-v0.0.1/
[One line description of module's purpose here]
----
Daisy-Cocktail-v0.0.1
http://search.cpan.org/~dmuey/Daisy-Cocktail-v0.0.1/
[One line description of module's purpose here]
----
Daisy-Cutter-v0.0.1
http://search.cpan.org/~dmuey/Daisy-Cutter-v0.0.1/
[One line description of module's purpose here]
----
Daisy-Dukes-v0.0.1
http://search.cpan.org/~dmuey/Daisy-Dukes-v0.0.1/
[One line description of module's purpose here]
----
Daisy-Wheel-v0.0.1
http://search.cpan.org/~dmuey/Daisy-Wheel-v0.0.1/
[One line description of module's purpose here]
----
Daisy-v0.0.1
http://search.cpan.org/~dmuey/Daisy-v0.0.1/
[One line description of module's purpose here]
----
Data-Hierarchy-Traverser-0.01
http://search.cpan.org/~tigerperl/Data-Hierarchy-Traverser-0.01/
Perl extension for generic hierarchy structure traversal.
----
File-Wildcard-0.10
http://search.cpan.org/~ivorw/File-Wildcard-0.10/
Enhanced glob processing
----
HTML-TableParser-Grid-v0.0.2
http://search.cpan.org/~takeru/HTML-TableParser-Grid-v0.0.2/
Provide access methods to HTML tables by indicating row and column
----
Image-ExifTool-6.76
http://search.cpan.org/~exiftool/Image-ExifTool-6.76/
Read and write meta information
----
LaTeX-TOM-0.5_04
http://search.cpan.org/~schubiger/LaTeX-TOM-0.5_04/
A module for parsing, analyzing, and manipulating LaTeX documents.
----
Net-CUPS-0.50
http://search.cpan.org/~dhageman/Net-CUPS-0.50/
Common Unix Printing System Interface
----
Object-InsideOut-3.09
http://search.cpan.org/~jdhedden/Object-InsideOut-3.09/
Comprehensive inside-out object support module
----
POE-Component-Pluggable-0.05
http://search.cpan.org/~bingos/POE-Component-Pluggable-0.05/
a base class for creating plugin enabled POE Components.
----
POE-Component-Server-DNS-0.05
http://search.cpan.org/~bingos/POE-Component-Server-DNS-0.05/
non-blocking, concurrent DNS server component
----
Path-Resource-0.01_2
http://search.cpan.org/~rkrimen/Path-Resource-0.01_2/
URI/Path::Class combination.
----
Protocol-Modbus-0.04
http://search.cpan.org/~cosimo/Protocol-Modbus-0.04/
Implements Modbus protocol message generation and parsing
----
Test-Run-0.0103
http://search.cpan.org/~shlomif/Test-Run-0.0103/
----
Test-Run-CmdLine-0.0103
http://search.cpan.org/~shlomif/Test-Run-CmdLine-0.0103/
Analyze tests from the command line using Test::Run
----
WWW-TV-0.05
http://search.cpan.org/~tigris/WWW-TV-0.05/
Parse TV.com for information about TV shows.
----
Wordnet-SenseSearch-0.02
http://search.cpan.org/~dbrian/Wordnet-SenseSearch-0.02/
Just get a synset from a sense key
----
XML-Compile-0.15
http://search.cpan.org/~markov/XML-Compile-0.15/
Compilation based XML processing
----
onto-perl-0.27
http://search.cpan.org/~easr/onto-perl-0.27/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 17 Feb 2007 01:18:59 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: New to Perl, OOP inheritance
Message-Id: <53n3g3F1tam54U1@mid.dfncis.de>

Peter Michaux <petermichaux@gmail.com> wrote in comp.lang.perl.misc:
> On Feb 16, 1:06 am, anno4...@radom.zrz.tu-berlin.de wrote:
> > Peter Michaux <petermich...@gmail.com> wrote in comp.lang.perl.misc:
> >
> > > Hi,
> >
> > > I'm new to Perl (from C, JavaScript, Ruby) and going through the Camel
> > > book.

[...]

> > So if ->new is called as an object method it (re-)initializes the
> > object.  That's a reasonable approach, though it might be clearer
> > to have separate methods (object method ->init, class method ->new)
> > for that.

[...]

> > > Any suggestions to clean up the clunky parts of the new subroutines? I
> > > expect that some will say "this is not how you do OOP Inheritance in
> > > Perl." Other options?
> >
> > You can pack most of the "clunky part" in one statement:
> >
> >     sub new {
> >         my $invocant = shift;
> >         my $this = ref( $invocant) ? $invocant : bless {}, $invocant;
> >         my ($name) = @_;
> >         # ...
> >     }
> >
> > Anno
> 
> 
> Thanks for the reply. Good to know I wasn't way out in left field.

Let me take the occasion and add a few more general remarks.

It is a good thing for a class to have not only a creator but also
a separate initializer.  This aspect has been sadly neglected by
the Perl OO community.  If creation and initialization are coupled,
you're in trouble with multiple inheritance.  You can create an
object only once, but you must (potentially) initialize it for
every class it inherits from.  Perl classes traditionally come
with only a creator, neglecting that simple arithmetic.

Your approach to have ->new behave like an initializer if called
on an object is one way to provide separate initialization.  The
semantics could be expressed as "set this object up according to
the arguments as if it were new", which is reasonable enough.

Unfortunately, a large strain of Perl classes has emerged whose
->new methods show an entirely different behavior when called as
an object method.  The done thing is (was? it seems to be declining)
to derive a class from the object via the attractive idiom

    my $class = ref( $invocant) || $invocant;

 ...and plough ahead creating a new object, no matter what.  In
the rare situations where that behavior is useful, I find it
clearer to express it on the client level as

    my $like_the_other = ref( $obj)->new( ...);

I don't remember ever wanting that except in some cross-class
overloading situations.  The need for separate initialization
comes up regularly with multiple inheritance, so the behavior
you suggest is far more useful.  It is perhaps no coincidence
that you spontaneously came up with it.  It appears you are
familiar with OO in general, but not with the particular quirks
of Perl's OO culture.

Anno


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

Date: 16 Feb 2007 20:29:48 -0800
From: "Peter Michaux" <petermichaux@gmail.com>
Subject: Re: New to Perl, OOP inheritance
Message-Id: <1171686587.989863.114220@v33g2000cwv.googlegroups.com>

Hi Anno,

On Feb 16, 5:18 pm, anno4...@radom.zrz.tu-berlin.de wrote:

<snip>

> Unfortunately, a large strain of Perl classes has emerged whose
> ->new methods show an entirely different behavior when called as
> an object method.  The done thing is (was? it seems to be declining)
> to derive a class from the object via the attractive idiom
>
>     my $class = ref( $invocant) || $invocant;
>
> ...and plough ahead creating a new object, no matter what.

I read this style in the Camel book at did a complete double take. I
haven't encountered a situation where I'd want to do that. Then again
I haven't had that possibility available before so haven't thought
about what efficiency it allows.

> In
> the rare situations where that behavior is useful, I find it
> clearer to express it on the client level as
>
>     my $like_the_other = ref( $obj)->new( ...);

I think this is much nicer and makes the Perl OOP system more like
other OOP languages. Not that Perl should be written like other
languages but if developers like me are showing up into some Perl
scripts it will make more sense.

> I don't remember ever wanting that except in some cross-class
> overloading situations.  The need for separate initialization
> comes up regularly with multiple inheritance, so the behavior
> you suggest is far more useful.  It is perhaps no coincidence
> that you spontaneously came up with it.  It appears you are
> familiar with OO in general, but not with the particular quirks
> of Perl's OO culture.

I think I'm a little spoiled coming from Ruby which built on Perl's
successes. The Perl quirks I've read so far have been interesting :)

Thanks again,
Peter



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

Date: Fri, 16 Feb 2007 22:51:22 -0600
From: Michael Austin <maustin@firstdbasource.com>
Subject: Re: Perl:CGI - Creating a Please wait message
Message-Id: <ZPvBh.6446$o61.5118@newssvr19.news.prodigy.net>

Ice Man wrote:

> I have created a CGI program which dynamically creates an HTML FORM.
> This form upon submit, goes out and does some work that can take up
> to
> 10 minutes to complete.  Once done, the called CGI provides the user
> with logged results.
> My goal is to provide the user with an automated GIF and a message to
> please stand by while the program is out doing its work.
> 
> I have tried to first display this "Please wait ... processing your
> transaction" message at the beginning of the called CGI called
> program, before any work is done.  I have also tried to call an
> intermediary CGI program which displays the message and calls the
> working CGI in the background.
> 
> In all cases, the message is not displayed until after the CGI
> working
> program [which takes 10 minutes to complete] has actually completed!
> 
> I do not have a large javascript background and I would prefer to
> stay
> in Perl native.  Is there anything I can do here or is my only option
> to learn javascripting?
> 
> Thanks,
> -Bill
> 

10 minutes?  you might store the result set in a file and send it (or a link to 
it) via email to the user.  you also run the risk of timing-out your web-server 
as well as the browser...


-- 
Michael Austin
Database Consultant
Domain Registration and Linux/Windows Web Hosting Reseller
http://www.spacelots.com


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

Date: Sat, 17 Feb 2007 01:49:45 GMT
From: Ala Qumsieh <noreply@invalid.net>
Subject: Re: problem reading remote file.
Message-Id: <ZatBh.10918$gj4.3610@newssvr14.news.prodigy.net>

Tad McClellan wrote:

> Mirco Wahab <wahab-mail@gmx.de> wrote:
> 
>> Under Unix, you need to have access to the
>> windows box by smbclient and fiends.
>                                ^^^^^^
> 
> Did you do that on purpose, or is it an (entertaining) Freudian slip?

Very often I forget the 'f' in code like this:

  my $arg = shift;

fortunately, strict doesn't like filthy code.

--Ala



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

Date: 16 Feb 2007 18:59:28 -0800
From: "kath" <nitte.sudhir@gmail.com>
Subject: Re: problem reading remote file.
Message-Id: <1171681168.468849.282330@v33g2000cwv.googlegroups.com>

On Feb 16, 3:23 pm, Mirco Wahab <wahab-m...@gmx.de> wrote:
> kath wrote:
> > I have a script to read remote file. The script goes as follows,
> > #!C:\Perl\bin\perl.exe
> > $remote= '\\\remotehost\remotedir\remotefile.jml';
> > open(fp, $remote) or die ("could not open the file");
> > print while(<fp>);
> > close(fp);
> > This script runs fine on my windows machine. But the same script when
> > I run in UNIX, after changing the shebang line to /usr/bin/perl, I
> > get
> > could not open the file file_name.pl at 4
>
> > The remote host from which I am trying to read the file is also
> > Windows box.
> > 1. where am i making wrong?
> > 2. Why the script is not running on UNIX?
>
> Under Unix, you need to have access to the
> windows box by smbclient and fiends.
>
> Your code traanslated to the unix world
> could read like the following:
>
>     use strict;
>     use warnings;
>
>      # this is what you used to use
>      my $winrmt = '\\\remotehost\remotedir\remotefile.jml';
>
>      # make sure you get the access rights correct,
>      # maybe you can drop username/password completely
>      my $unxrmt = '-n --username=kath --password=kath01 smb:/'
>                 . join '/', split /\\+/, $winrmt;
>
>      # pull some adrenaline:
>      print "trying: $unxrmt \n";
>
>      my $pid =  open HANDLE, "smbget $unxrmt |" or die "fork error: $!";
>      close HANDLE;
>
>      # now your remote file should reside in your current
>      # directory. Please check out other options if the
>      # smbclient family e.g.: $> man smbget
>
> If it won't work, check out what $unxrmt looks like
> and pot it back here ...
>
> Regards
>
> M.

hi, I do not see the post I done before, so i am reposting,

Hi Wahab, thanks for the reply. I was not aware of the smb* commands.
You made me to learn this new command. The output of $unxrmt was
correct, and tried to run the same at console(command-prompt) but I
get,

You don't have enough permissions to access smb://remotehost/remotedir/remotefile.jml

but when use the same( open(filehandle, remotefile) ) function I do
not get message like, you don't have enough permission. Its expecting
the username and password.

Why that don't ask when I try access the same location on Windows,
though I was not using smbclient family commands on windows.

Do i need to download the file(s) first prior reading it(I do not do
that, as you can see in the above code )?



Thanks,
Regards,
kath.



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

Date: Sat, 17 Feb 2007 09:07:43 +0900
From: "Shannon Jacobs" <shanen@cashette.com>
Subject: Re: Regex: Why is overreaching necessary?
Message-Id: <45d6474f$0$210$44c9b20d@news3.asahi-net.or.jp>

General thanks to the people who provided hints, and now I can finally 
answer the original Subject: question. The fundamental problem I was 
wrestling with was between generalized grepping for existence of the search 
target and more selective grepping. The answer: <drum roll>

If you only want to deal with part of a string, then you *MUST* account for 
*ALL* of the string in your regex.

Now it seems obvious, but it took me a while to get the point. I think I was 
led astray by the convenience of using little regular expressions as the 
search target. Yes, it's convenient, but it's fundamentally sloppy. Anyway, 
now I have three working solutions, and I even sort of think I understand 
how they work (except for relative performance). The first one is mostly 
mine, and the other two are mostly from real Perlers.

@foo2 = grep(/^.{50}.*($form_values{'a_SEARCH_VALUE'}).*.{6}$/,@foo1);

@foo2 = grep substr( $_, 50, 12 ) =~ /$form_values{'a_SEARCH_VALUE'}/, 
@foo1;

@foo2 = grep(/^.{50,62}($form_values{'a_SEARCH_VALUE'}).{6,18}$/,@foo1);

There's still one more little wrinkle that's bugging me--but there always 
is. Trivial enough to ignore, but I'm wondering if there's an elegant 
solution... I'll try to restate that wrinkled problem in terms that are more 
consistent with the posting guidelines:

An example of the search target in $form_values.... could be 
1224|1357|2239|2243|2468 (intended to match anywhere in the 12 unmasked 
digits), which are actually (up to) three numbers. What I want to do is 
insert something like (.{4}){0,2} before and after the search target (where 
I currently have .* in my first version above) so that it only considers 4 
digits at a time. Here is some sample data from the file.

The Brethren                            20010210282239        Fa
Gorilla, My Love                        19810211042240        HF
KeitaiDenwaNoHimitsu                    200102110722412242    JaChCS
Harry Potter and the Philosopher's Stone199702111722362243    Fa

In this example the first and fourth lines are proper matches against 2239 
and 2243, respectively, but the third line is an undesired match against 
1224. The problem as I see it is that the two things I'm thinking about 
inserting should communicate with each other so that they always consume a 
total of 8 characters, thereby forcing the target to consider only four 
characters at a time.

Shannon Jacobs wrote:
>>> @foo2 = grep(/^.{50,62}($1121|1217|1256|2033).{6,18}$/,@foo1);
>
> Yes, the first $ there was a typo left over from the actual code
> sample that was included later in the OP (where that part of the
> search target was stored in a variable). My apologies for not
> including a sample of the data, but I had attempted to constrain the
> question in a way that I hoped limited the need for reference to the
> actual data. Here is a short sample from the file:
>
> Irrational Numbers                      1976770514 392   0   0SF
>
> Maske:  Thaery                          1976770514 393   0   0SF
>
> The Turning Place                       1976770515 394   0   0SF
>
> The October Circle                      1975770516 395   0   0Fi
>
> Our Invaded Universities                1974830410 671        EdPSHi
> Space Mail                              1980840607   8 564 565SF
>
> There are spaces at the ends of the apparently short lines, so all of
> them are actually of the same length. The embedded 0s are actually an
> anachronism of the source programs, but they 'seem' harmless, so I've
> always ignored them. I think it's irrelevant, but for the sake of
> sizing, this data file is only around 200 Kb in total.
>
> Since substring operations have come up again, let me clarify that in
> this part of the program it seemed easier and better to use a simple
> regex at each stage of refinement. I didn't want to break the lines
> apart and just put them together again (though later on I did break
> the final filtered results apart for output). (In addition, I know
> that the current approach allows me to usefully input search targets
> consisting of regular expressions, such as ^.{44}07 to pull the
> current year's entries.)
>
> At this point I am most interested in the operation and probable
> performance advantages of John Krahn's
>
> @foo2 = grep substr( $_, 50, 12 ) =~ /1121|1217|1256|2033/, @foo1;
>
> versus my (corrected) version of
>
> @foo2 = grep(/^.{50,62}(1121|1217|1256|2033).{6,18}$/,@foo1);
>
> . I have the (fuzzy) intuition that his code is more directly
> performing the operation that I described in the OP. If so, I'd like
> to share it with the Perler who led me to my probably awkward solution
> (but I'm not sure yet which is better nor why).
>
> I am also still interested in understanding why this version failed:
>
> @foo2 = grep(/^.{50}(1121|1217|1256|2033).{6}$/,@foo1);
>
> Minor point is wondering whether or not it is necessary to worry about
> the end of the string (as mentioned by Uri Guttman). It seems to me
> that there would still be a general risk of false positives in the
> tail of the string unless they are explicitly ignored. Or is he really
> saying that my version is still subject to that risk?
<older snip> 



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

Date: 17 Feb 2007 01:58:37 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Regex: Why is overreaching necessary?
Message-Id: <53n5qdF1t3p29U1@mid.dfncis.de>

Shannon Jacobs <shanen@cashette.com> wrote in comp.lang.perl.misc:

[...]

> @foo2 = grep substr( $_, 50, 12 ) =~ /$form_values{'a_SEARCH_VALUE'}/, 
> @foo1;

[...]

> There's still one more little wrinkle that's bugging me--but there always 
> is. Trivial enough to ignore, but I'm wondering if there's an elegant 
> solution... I'll try to restate that wrinkled problem in terms that are more 
> consistent with the posting guidelines:
> 
> An example of the search target in $form_values.... could be 
> 1224|1357|2239|2243|2468 (intended to match anywhere in the 12 unmasked 
> digits), which are actually (up to) three numbers. What I want to do is 
> insert something like (.{4}){0,2} before and after the search target (where 
> I currently have .* in my first version above) so that it only considers 4 
> digits at a time. Here is some sample data from the file.
> 
> The Brethren                            20010210282239        Fa
> Gorilla, My Love                        19810211042240        HF
> KeitaiDenwaNoHimitsu                    200102110722412242    JaChCS
> Harry Potter and the Philosopher's Stone199702111722362243    Fa
> 
> In this example the first and fourth lines are proper matches against 2239 
> and 2243, respectively, but the third line is an undesired match against 
> 1224. The problem as I see it is that the two things I'm thinking about 
> inserting should communicate with each other so that they always consume a 
> total of 8 characters, thereby forcing the target to consider only four 
> characters at a time.

Try this variant:

    @foo2 = grep substr( $_, 50, 12 ) =~
        /^(?:\d{4}){0,2}$form_values{'a_SEARCH_VALUE'}/, 
        @foo1;

Essentially that ties the pattern to the beginning of the substring,
then allows zero to two groups of four digits before a match.

Anno


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

Date: Fri, 16 Feb 2007 18:32:28 -0800
From: sl123@netherlands.area
Subject: test - disregard
Message-Id: <79qct2hfvjhee2034qqnedlqg9ucr7pal9@4ax.com>

asdfasdf


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

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

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 147
**************************************


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