[29168] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 412 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 7 21:11:05 2007

Date: Mon, 7 May 2007 18:09:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 7 May 2007     Volume: 11 Number: 412

Today's topics:
    Re: 2 array problem <abigail@abigail.be>
        [ANNOUNCE] Emacs modules for Perl programming (Jari Aalto+mail.perl)
        [ANNOUNCE] Text-CSV_XS 0.25 <h.m.brand@xs4all.nl>
        advice on matching nested pattern? <none@all.thanks>
    Re: advice on matching nested pattern? <spamtrap@dot-app.org>
    Re: advice on matching nested pattern? <rvtol+news@isolution.nl>
    Re: advice on matching nested pattern? <none@all.thanks>
    Re: advice on matching nested pattern? <none@all.thanks>
    Re: advice on matching nested pattern? <uri@stemsystems.com>
        Data Structure help (hash/array) <mislam@spam.uiuc.edu>
    Re: Data Structure help (hash/array) <xicheng@gmail.com>
    Re: Home-built Twirling Bar Between Multiple System Cal <joe@inwap.com>
    Re: How to time out a forked command but still see outp <hokkaidocrow@gmail.com>
    Re: Link Matching <xicheng@gmail.com>
    Re: Link Matching <xicheng@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 07 May 2007 10:28:30 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: 2 array problem
Message-Id: <slrnf3tvpm.hl5.abigail@alexandra.abigail.be>

anno4000@radom.zrz.tu-berlin.de (anno4000@radom.zrz.tu-berlin.de) wrote
on MMMMCMXCVI September MCMXCIII in <URL:news:5a6d36F2moh34U1@mid.dfncis.de>:
__  
__  The reason to avoid them would be that from "perldoc -f sort" one
__  would expect sort() to overwrite them randomly.  But that doesn't
__  happen:
__  
__      ( $a, $b) = ( 99, 100);
__      my @s = sort { $b <=> $a } 1 .. 4;
__      print "$a $b\n";
__  
__  still prints "99, 100".  The preserving behavior has been around for
__  a long time, but it isn't documented or I overlooked it more than once.
__  Apart from that, there doesn't seem to be much reason to avoid $::a
__  and $::b at all, except, of course, who wants them in the first place.


You have to work hard to construct code that gets bitten by $a and $b.
Here's an example:


    $::a = 1;

    sub f {$a % 2 ? $_ [0] : -$_ [0]}
    sub x {f ($a) <=> f ($b)}

    sort x @array;


To construct such an example, you have to consider:

  +  $a and $b are safe if you aren't sorting.
  +  Not using $a and $b in the sub or code block called from by sort
     is pointless - can't really be bitten here.
  +  So, only time to get bitten is in a sub that is called from a sub
     called by sort.


However, using *lexical* $a and $b might get you bitten easier!

    my $a = 1;
    sub x {$a <=> $b}
    my @c = sort x 0 .. 9;
    print "@c\n";
    __END__
    0 1 6 4 8 2 7 5 9 3


But:

    my $a = 1;
    my @c = sort {$a <=> $b} 0 .. 9;
    __END__
    Can't use "my $a" in sort comparison


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: 07 May 2007 04:28:43 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: [ANNOUNCE] Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1178512086@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: Mon, 7 May 2007 15:22:23 GMT
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Subject: [ANNOUNCE] Text-CSV_XS 0.25
Message-Id: <JHoH6w.LIy@zorch.sf-bay.org>


After several years of silence, I received maintainership on Text::CSV_XS
from Jochen Wiedman. Please enjoy the new features

  file: $CPAN/authors/id/H/HM/HMBRAND/Text-CSV_XS-0.25.tgz
  size: 22857 bytes
   md5: 1b57894ccdb711e76d368257757ce8ea

Request entered by: HMBRAND (H.Merijn Brand)
Request entered on: Mon, 07 May 2007 15:10:01 GMT

2007-05-07  H.Merijn Brand   <h.m.brand@xs4all.nl> (0.25)

        * Merijn got the maintainership
        - code reformat and code cleanup
        - renamed internal (Encode, Decode) to (Combine, Parse) to
          prevent misinterpretation with upcoming Unicode changes
          and possible name clashes
        - added pod check (and fixed pod)
        - added pod coverage and small additions to the pod.
          More to do in this area
        - renamed test to fixate the sequence
        - Added t/50_utf8.t
        - tests now use Test::More
          . Makefile.PL requires Test::More
        - checked proclaimed version compatibility
          . 5.9.x-64int     works @31159
          . 5.8.x-64int-dor works @31162
          . 5.8.0-dor       works
          . 5.6.2           works
          . 5.005.04        works
          . 5.004.05        fails
        - 5.005 is now prerequisite
        - Added missing info in docs for new ()
        - Added meta_info () method and docs
        - Added keep_meta_info in new ()
        - Added t/15_flags.t
        - Added test_cover make target
        - Added test for error_input ()
        - Added tests for fields () and meta_info () before parse ()
        - Added tests for ->types () as method
        - Added tests for deleting types (coverage now over 99%)
        - Added is_quoted (), is_binary () and tests
        - Added COPYRIGHT section to pod
        - Added the parse example from the pod to test.pl
        - Added accessor methods for internals: quote_char () et all
        - Added tests for the new accessor methods
        - Added always_quote to the missing places in the doc and in new ()
        - Changed the tests to use the accessors instead of the hash keys
          except for the ->{types} and ->{_types}
        - Moved test.pl to examples/speed.pl


           To sum it up,

            $csv = Text::CSV_XS$,1x2(B>new ();

           is equivalent to

            $csv = Text::CSV_XS$,1x2(B>new ({
                quote_char     => $,1ry(B"$,1ry(B,
                escape_char    => $,1ry(B"$,1ry(B,
                sep_char       => $,1ry(B,$,1ry(B,
                eol            => $,1ryry(B,
                always_quote   => 0,
                binary         => 0,
                keep_meta_info => 0,
                });

           For all of the above mentioned flags, there is an accessor  method
           available where you can inquire for the current value, or change
           the value

            my $quote = $csv$,1x2(B>quote_char;
            $csv$,1x2(B>binary (1);
       :
       :
       meta_info
            @flags = $csv$,1x2(B>meta_info ();

           This object function returns the flags of the input to "combine  ()"
           or the flags of the resultant decomposed fields of "parse ()",
           whichever was called more recently.

           For each field, a meta_info field will hold flags that tell
           something about the field returned by the "fields ()" method or
           passed to the "combine ()" method. The flags are bitwise$,1rp(Bor$,1ry(Bd  like:

           0x0001
               The field was quoted.

           0x0002
               The field was binary.

           See the "is_*** ()" methods below.

       is_quoted
             my $quoted = $csv$,1x2(B>is_quoted ($column_idx);

           Where $column_idx is the (zero$,1rp(Bbased) index of the column in the
           last result of "parse ()".

           This returns a true value if the data in the indicated column  was
           enclused in "quote_char" quotes. This might be important for  data
           where ",20070108," is to be treated as a numeric value, and  where
           ","20070108"," is explicitely marked as character string data.

       is_binary
             my $binary = $csv$,1x2(B>is_binary ($column_idx);

           Where $column_idx is the (zero$,1rp(Bbased) index of the column in the
           last result of "parse ()".

           This returns a true value if the data in the indicated column
           contained any byte in the range [\x00$,1x2(B\x08,\x10$,1x2(B\x1F,\x7F$,1x2(B\xFF]


       An example for parsing CSV lines:

         use Text::CSV_XS;

         my $csv = Text::CSV_XS$,1x2(B>new ({ keep_meta_info => 1, binary => 1  });

         my $sample_input_string =
             qq{"I said, ""Hi!""",Yes,"",2.34,,"1.09","\x{20ac}",};
         if ($csv$,1x2(B>parse ($sample_input_string)) {
             my @field = $csv$,1x2(B>fields;
             foreach my $col (0 .. $#field) {
                 my $quo = $csv$,1x2(B>is_quoted ($col) ? $csv$,1x2(B>{quote_char} :  "";
                 printf "%2d: %s%s%s\n", $col, $quo, $field[$col], $quo;
                 }
             }
         else {
             my $err = $csv$,1x2(B>error_input;
             print "parse () failed on argument: ", $err, "\n";
             }


-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.9.x   on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.0 & 10.2, AIX 4.3 & 5.2, and Cygwin. http://qa.perl.org
http://mirrors.develooper.com/hpux/            http://www.test-smoke.org
                        http://www.goldmark.org/jeff/stupid-disclaimers/




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

Date: Sun, 06 May 2007 23:07:11 -0500
From: sparkane <none@all.thanks>
Subject: advice on matching nested pattern?
Message-Id: <3I6dnQ5TeYiqOKPbnZ2dneKdnZydnZ2d@giganews.com>

Hi. Apologies in advance for the excessive English.  I'm trying to 
create a regex to be used as an interpolation symbol (hereafter referred 
to as Symbol) for building webpage views.  Here's the basic regex for 
the Symbol:

{{(/?)\w+(?: .+?)?(?(1)|/)}}

The idea is that a string is submitted with any number of Symbols in it. 
  When a Symbol is found by the regex, another string is fetched from 
storage and interpolated in place of the Symbol.  The interpolation is 
finished when there are no remaining Symbols, and the view is sent to 
the client.

The twist is that I want the regex to IGNORE Symbols which have Symbols 
inside them.  The inside-Symbols, not having Symbols inside _them_, are 
not ignored, are interpolated, and once all a Symbol's inside-Symbols 
are interpolated, then that Symbol can be interpolated (on a subsequent 
pass through the string).

The form of the Symbol within a Symbol, by the way, would always be:

{{\w+(?: .+?)?/}}

within the (?: .+?) of the first regex above.

The only real solution I've been able to come up with on my own uses a 
match-time pattern interpolation:

(??{ $& =~ @{{\w+(?: .+?)?/}}@ ? "\0" : '' })

or (I think)

(?(?{ $& =~ @{{\w+(?: .+?)?/}}@ })\0|)

placed thusly:

{{(/?)\w+(?: .+?)?(??{ $& =~ @{{\w+(?: .+?)?/}}@ ? "\0" : '' })(?(1)|/)}}

This approach basically has to use a little trick of inserting a null 
char symbol to be matched if an embedded Symbol is found; the intention 
is that the null char will not match and that entire Symbol will be 
Ignored.  I don't like this trick, however, because it's possible, 
however unlikely, for null chars to be inserted in the string submitted 
to be built into a webpage view.  Also, it uses $&, and this should slow 
down the code substantially, right?

I think I could make this work with a negative lookbehind assertion that 
  looked for the first Symbol close-tag - /}} - occurring _before_ the 
first Symbol open-tag - {{ - in other words, something like:

{{(/?)\w+(?: .+?)?(?<![first closing tag before first opening 
tag])(?(1)|/)}}

(or vice versa, a negative lookahead looking for the first Symbol 
open-tag before the first Symbol close-tag)

but I can't figure out how to do this without having to rely on an 
additional lookaround assertion (which might itself have to rely on 
another such assertion..).

Are there other ways to do what I want?  I want the app I'm using this 
in to be as simple and quick as possible.

Thanks in advance for any suggestions of approaches, etc

spark


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

Date: Mon, 07 May 2007 01:39:35 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: advice on matching nested pattern?
Message-Id: <m2mz0hw5t4.fsf@local.wv-www.com>

sparkane <none@all.thanks> writes:

> Hi. Apologies in advance for the excessive English.  I'm trying to
> create a regex to be used as an interpolation symbol (hereafter
> referred to as Symbol) for building webpage views.  Here's the basic
> regex for the Symbol:
>
> {{(/?)\w+(?: .+?)?(?(1)|/)}}
>
> The idea is that a string is submitted with any number of Symbols in
> it. When a Symbol is found by the regex, another string is fetched
> from storage and interpolated in place of the Symbol.  The
> interpolation is finished when there are no remaining Symbols, and the
> view is sent to the client.

My regex-fu isn't up to answering your actual question - sorry. :-(

Having said that, it sounds like you're describing a template system. There
are literally dozens of those on CPAN, from simple like Text::Template to
extensive like Template Toolkit or Mason. Are you *really* sure that this
particular wheel needs to be reinvented?

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Mon, 7 May 2007 10:39:26 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: advice on matching nested pattern?
Message-Id: <f1mvoc.1l0.1@news.isolution.nl>

sparkane schreef:


> a string is submitted with any number of Symbols in
>   it. When a Symbol is found by the regex, another string is fetched
> from storage and interpolated in place of the Symbol.  The
> interpolation is finished when there are no remaining Symbols

Maybe '1 while s///g' will do. 

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Mon, 07 May 2007 08:00:56 -0500
From: sparkane <none@all.thanks>
Subject: Re: advice on matching nested pattern?
Message-Id: <kvadndkUuJnTv6LbnZ2dnUVZ_s2vnZ2d@giganews.com>

Dr.Ruud wrote:
> sparkane schreef:
> 
> 
> 
>>a string is submitted with any number of Symbols in
>>  it. When a Symbol is found by the regex, another string is fetched
>>from storage and interpolated in place of the Symbol.  The
>>interpolation is finished when there are no remaining Symbols
> 
> 
> Maybe '1 while s///g' will do. 

If you're literally suggesting 's///g' as my pattern, then I'm afraid 
that no, it will not do.  If you are suggesting that I do a global 
search and replace within a while loop, my code already does that.  My 
question isn't in how to do the replacing, but how to find the text 
pattern I need to find.

Thanks, though.

spark


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

Date: Mon, 07 May 2007 08:22:49 -0500
From: sparkane <none@all.thanks>
Subject: Re: advice on matching nested pattern?
Message-Id: <ufudnYv8F9vyuqLbnZ2dnUVZ_o2vnZ2d@giganews.com>

Sherm Pendley wrote:
> My regex-fu isn't up to answering your actual question - sorry. :-(
> 
> Having said that, it sounds like you're describing a template system. There
> are literally dozens of those on CPAN, from simple like Text::Template to
> extensive like Template Toolkit or Mason. Are you *really* sure that this
> particular wheel needs to be reinvented?

You are exactly right, it is a templating system, and honestly no, I'm 
not sure it needs reinventing, actually, scratch that, I'm sure it does 
_not_ need reinventing.

However, my idea is a lot simpler than Mason, and probably simpler that 
Template Toolkit (I've used the former some but not the latter).  All 
there is to it is that "interpolation symbol" and related regex in the 
OP.  For a user to learn it, all he/she needs to learn is one 
interpolation symbol format.  Documentation is almost unnecessary.

On the practical side, I have a working version of my templating system 
created for a client; it's a mere function, just a few lines of code in 
all (like, less than 100), and very flexible.  I'm not a guru of other 
templating systems, and I'm sure I haven't explored the problem domain 
nearly to the extent the creators of those systems have, but for the 
actually-used business application I've made, the templating function 
succeeds in handling everything I've thrown at it.  To me at least, that 
suggests that it has some value. :)

sparkane


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

Date: Mon, 07 May 2007 10:42:12 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: advice on matching nested pattern?
Message-Id: <x7mz0g3dbv.fsf@mail.sysarch.com>

>>>>> "s" == sparkane  <none@all.thanks> writes:

  s> However, my idea is a lot simpler than Mason, and probably simpler that
  s> Template Toolkit (I've used the former some but not the latter).  All
  s> there is to it is that "interpolation symbol" and related regex in the
  s> OP.  For a user to learn it, all he/she needs to learn is one
  s> interpolation symbol format.  Documentation is almost unnecessary.

  s> On the practical side, I have a working version of my templating system
  s> created for a client; it's a mere function, just a few lines of code in
  s> all (like, less than 100), and very flexible.  I'm not a guru of other
  s> templating systems, and I'm sure I haven't explored the problem domain
  s> nearly to the extent the creators of those systems have, but for the
  s> actually-used business application I've made, the templating function
  s> succeeds in handling everything I've thrown at it.  To me at least, that
  s> suggests that it has some value. :)

sounds like you should check out Template::Simple. it has only 4 markups
to learn yet it can do most any templating task. it can handle loops,
conditionals, structures, include files and more. the whole module is
about 150 lines of code and is easy to learn and apply. it also isolates
code from template markup which makes it easier to have different people
working on those two aspects of templating.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 07 May 2007 13:23:17 -0500
From: Sharif Islam <mislam@spam.uiuc.edu>
Subject: Data Structure help (hash/array)
Message-Id: <f1nqqm$k4g$1@news.ks.uiuc.edu>

Hi,

I am comparing two different datasets and trying to come up with the 
best data structure.

Data Set 1:

For each record, I get a pair like this:

$VAR1 = {
          'TARGET' => '110974981305651',
          'INTERNAL_ID' => '1000000000000005'
        };
$VAR2 = {
          'TARGET' => '111053548637000',
          'INTERNAL_ID' => '111053624881107'
        };
$VAR3 = {
          'TARGET' => '111040401095000',
          'INTERNAL_ID' => '111040426288012'
        };

Data set 2:

For another record, I get a similar pair:

$VAR1 = {
          'Instanceid' => 58538,
          'Interfaceid' => 52
        };
$VAR2 = {
          'Instanceid' => 407401,
          'Interfaceid' => 55
        };
$VAR3 = {
          'Instanceid' => 58536,
          'Interfaceid' => 69
        };
$VAR4 = {
          'Instanceid' => 263954,
          'Interfaceid' => 692
        };

My goal is to connect this above two dataset based on another dataset 
(link table) that looks like this:

$VAR1 = {
          'Interfaceid' => '52',
          'TARGET' => '111053548637000'
        };
$VAR2 = {
          'Interfaceid' => '55',
          'TARGET' => '110974981305651'
        };
$VAR3 = {
          'Interfaceid' => '69',
          'TARGET' => '111040401095000'
  }

The final output is to connect the internal id with the instanceid. How 
should I approach it? I was thinking each dataset could of array of hash.

--sharif


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

Date: 7 May 2007 11:35:26 -0700
From: Xicheng Jia <xicheng@gmail.com>
Subject: Re: Data Structure help (hash/array)
Message-Id: <1178562926.687896.214100@w5g2000hsg.googlegroups.com>

On May 7, 2:23 pm, Sharif Islam <mis...@spam.uiuc.edu> wrote:
> Hi,
>
> I am comparing two different datasets and trying to come up with the
> best data structure.
>
> Data Set 1:
>
> For each record, I get a pair like this:
>
> $VAR1 = {
>           'TARGET' => '110974981305651',
>           'INTERNAL_ID' => '1000000000000005'
>         };
> $VAR2 = {
>           'TARGET' => '111053548637000',
>           'INTERNAL_ID' => '111053624881107'
>         };
> $VAR3 = {
>           'TARGET' => '111040401095000',
>           'INTERNAL_ID' => '111040426288012'
>         };
>
> Data set 2:
>
> For another record, I get a similar pair:
>
> $VAR1 = {
>           'Instanceid' => 58538,
>           'Interfaceid' => 52
>         };
> $VAR2 = {
>           'Instanceid' => 407401,
>           'Interfaceid' => 55
>         };
> $VAR3 = {
>           'Instanceid' => 58536,
>           'Interfaceid' => 69
>         };
> $VAR4 = {
>           'Instanceid' => 263954,
>           'Interfaceid' => 692
>         };
>
> My goal is to connect this above two dataset based on another dataset
> (link table) that looks like this:
>
> $VAR1 = {
>           'Interfaceid' => '52',
>           'TARGET' => '111053548637000'
>         };
> $VAR2 = {
>           'Interfaceid' => '55',
>           'TARGET' => '110974981305651'
>         };
> $VAR3 = {
>           'Interfaceid' => '69',
>           'TARGET' => '111040401095000'
>   }
>
> The final output is to connect the internal id with the instanceid. How
> should I approach it? I was thinking each dataset could of array of hash.
>
> --sharif

Why not just hash if your 'id' fields are uniquely defined, say:

my %internal_target = (
    1000000000000005 => '110974981305651',
    111053624881107  => '111053548637000',
    111040426288012 => '111040401095000',
);

my %interface_instance = (
    52 => '58538',
    55 => '407401',
    69 => '58536',
    692 => '263954',
);

combining these two dataset is much easier than using any more complex
data structure..

Regards,
Xicheng



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

Date: Sun, 06 May 2007 16:39:21 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Home-built Twirling Bar Between Multiple System Calls
Message-Id: <Rc-dnbNTh4W2-qPbnZ2dnUVZ_gWdnZ2d@comcast.com>

Martijn Lievaart wrote:
> On Sun, 06 May 2007 08:20:03 -0700, foolishbrat wrote:
>> #!/usr/bin/perl
>> system("code1.out param1 > output.txt");
>> system("code2.out param2 output.txt > output_final.txt");
>>
>> How can I show progress/twirling Bar between first (code1) system call
>> and the second (code2) system call? Especially we don't know how long
>> each system call will take.
> 
> Easy. Fork to do the system call. In the parent show the progress bar and 
> check with wait_pid if the  child is ready.
> 
> May or may not work on Windows, though, no idea really.

#!/usr/bin/perl
use strict; use warnings;
$|++;

our $child_pid;                         # Holds PID while child is running
$SIG{CHLD} = sub { $child_pid = 0; };   # When child has exited
# That works for POSIX-like systems (Linux, Cygwin), but not Windows-XP

my $cmd = 'sleep 12';			# Example for code1.out
if ($child_pid = fork) {
   print "Parent waiting for child $child_pid to finish: ";
   my $count;
   while ($child_pid) {
     printf "%s%4d\b\b\b\b\b", substr('-/|\\',++$count%4,1), $count;
     sleep 1;
   }
   print "Done!\n";
} else {
   print "Child $$ running `$cmd`\n";
   exec $cmd;				# code1.out runs here
}
system "echo code2.out runs here";
print "Finished\n";

	-Joe


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

Date: 7 May 2007 12:13:43 -0700
From: thecrow <hokkaidocrow@gmail.com>
Subject: Re: How to time out a forked command but still see output?
Message-Id: <1178565222.979937.308130@w5g2000hsg.googlegroups.com>

On Apr 22, 1:06 am, "comp.llang.perl.moderated" <c...@blv-
sam-01.ca.boeing.com> wrote:
> On Apr 21, 8:58 am, thecrow <hokkaidoc...@gmail.com> wrote:
>
>
>
> > On Apr 18, 8:19 am, "comp.llang.perl.moderated" <c...@blv-
>
> > sam-01.ca.boeing.com> wrote:
> > > Another way if redirecting all -- rather than just
> > > the ensuing output from the point of the interrupt --
> > > to a file is acceptable:
>
> > > open( my $fh, "$command  |") or  die "fork failed: $!" ;
>
> > > local $SIG{ ALRM } = sub { close $fh;
> > >      system("$command >save.txt &"); exit;};
>
> > > alarm $startupWait;
> > > ...
> > > print while <$fh>;   # eg.
>
> > I'm confused by this example, it seems that it would run the command
> > twice, discarding all the output the first time, and saving all the
> > output the second time.  Definitely that's not what I'm looking for.
>
> Did you try it...  No, it shouldn't.  The program will
> print all output to the screen in real time. If, however,
> your timeout occurs before  program completion, then
> the program is launched  in the background and output re-directed as
> you specified.

If the program output is not buffered, the effect of your code will
be:
1)  Launch program
2)  Program runs but no output is ever displayed.
3)  Timeout arrives.
4)  Second copy of the program is launched, which redirects to a file.
5)  Presumably the first program hangs

So there are 2 major issues here, first, it won't work with unbuffered
output.  Second, it only works if you assume a stateless program...
that nothing happened during the first launch, and running it a second
time is an equivalent operation.



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

Date: 7 May 2007 08:05:54 -0700
From: Xicheng Jia <xicheng@gmail.com>
Subject: Re: Link Matching
Message-Id: <1178550354.897413.141460@p77g2000hsh.googlegroups.com>

On May 4, 11:08 pm, Taras_96 <taras...@gmail.com> wrote:
> Hi everyone,
>
> I need to write a regex that parses some HTML text to output all links
> whose text (the text that appears on the screen) a given expression.
>
> eg: findLinks(html,'(.*)o(.*)') called on the html code
>
> <a>one</a>
> <a>three</a>
> <a>two</a>
>
> Should return two matches, <a>one</a> and <a>two</a>
>
> I'm a bit new with regexs. At the moment I have:
>
> '/<a[^><]*href\s*=\s*[^>]*>'.$regex.'<\/a>/'
>
> (I'm only interested with tags that have a href attribute)
>
> which greedily matches the entire input string.
>
> How do I make the </a> match non greedy? I've read that (.*?)<\/a>
> makes the match non greedy, but this doesn't account for the form of
> the link text.

Here is one regex way:

sub findlinks
{
    my ($html, $ptn) = @_;
    while($html =~ m{( <a (?=[^<>]*href) (.*?) </a> )}gsix) {
        my $ret = $1;
        (my $content = $2) =~ s/<.*?>//g; #remove embedded tags
        print $ret if $content =~ /\Q$ptn/;
        # if $ptn is plain text, switch to index()
        # print $ret if index($content, $ptn) > 0;
    }
}

$html = <<END_HTML;
    <a href="bbb">one</a> nnn
    sgfdh <a href="aa">three</a>
    dfgdg <a>two</a> 000
    dfgdg <a href="ttoo">two
    </a> ooo
END_HTML

findlinks($html, "o");

__END__

Regards,
Xicheng



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

Date: 7 May 2007 08:24:49 -0700
From: Xicheng Jia <xicheng@gmail.com>
Subject: Re: Link Matching
Message-Id: <1178551489.302803.60500@h2g2000hsg.googlegroups.com>

On May 7, 11:05 am, Xicheng Jia <xich...@gmail.com> wrote:
> On May 4, 11:08 pm, Taras_96 <taras...@gmail.com> wrote:
>
>
>
> > Hi everyone,
>
> > I need to write a regex that parses some HTML text to output all links
> > whose text (the text that appears on the screen) a given expression.
>
> > eg: findLinks(html,'(.*)o(.*)') called on the html code
>
> > <a>one</a>
> > <a>three</a>
> > <a>two</a>
>
> > Should return two matches, <a>one</a> and <a>two</a>
>
> > I'm a bit new with regexs. At the moment I have:
>
> > '/<a[^><]*href\s*=\s*[^>]*>'.$regex.'<\/a>/'
>
> > (I'm only interested with tags that have a href attribute)
>
> > which greedily matches the entire input string.
>
> > How do I make the </a> match non greedy? I've read that (.*?)<\/a>
> > makes the match non greedy, but this doesn't account for the form of
> > the link text.
>
> Here is one regex way:
>
> sub findlinks
> {
>     my ($html, $ptn) = @_;
change
     while($html =~ m{( <a (?=[^<>]*href) (.*?) </a> )}gsix) {
to:
     while($html =~ m{( <a (?=[^<>]*href) .*?> (.*?) </a> )}gsix) {

or change:
    (my $content = $2) =~ s/<.*?>//g;
to
    (my $content = $2) =~ s/^[^>]*>|<.*?>//g;

I forogt to close the opening link tag..
BTW, this may not work for some ill-formated XHTML documents although
they do exist widely on the web, and it might also improperly check
the contents in your commented elements..

Regards,
Xicheng

>         my $ret = $1;
>         (my $content = $2) =~ s/<.*?>//g; #remove embedded tags
>         print $ret if $content =~ /\Q$ptn/;
>         # if $ptn is plain text, switch to index()
>         # print $ret if index($content, $ptn) > 0;
>     }
>
> }
>
> $html = <<END_HTML;
>     <a href="bbb">one</a> nnn
>     sgfdh <a href="aa">three</a>
>     dfgdg <a>two</a> 000
>     dfgdg <a href="ttoo">two
>     </a> ooo
> END_HTML
>
> findlinks($html, "o");
>
> __END__
>
> Regards,
> Xicheng




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

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


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