[31358] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2610 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 24 09:14:28 2009

Date: Thu, 24 Sep 2009 06:14:20 -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           Thu, 24 Sep 2009     Volume: 11 Number: 2610

Today's topics:
        FAQ 8.23 How can I open a pipe both to and from a comma <brian@theperlreview.com>
    Re: FAQ 9.11 How do I redirect to another page? <jiangwei.wang@gmail.com>
        How to check if a module is installed in Strawberry? <WaterLin@ymail.invalid>
    Re: How to check if a module is installed in Strawberry <bart.lateur@pandora.be>
    Re: How to check if a module is installed in Strawberry <ben@morrow.me.uk>
        Information on latest mobile- Pass it on... <networkmodels82@gmail.com>
    Re: Log4perl -- how to copy FATALs to STDERR <bugbear@trim_papermule.co.uk_trim>
    Re: Log4perl -- how to copy FATALs to STDERR <brian.d.foy@gmail.com>
        Perl and SNMP => List All interface ? <mag@laposte.net>
        Reading binary files as numbers? <jomarbueyes@hotmail.com>
    Re: Reading binary files as numbers? <jurgenex@hotmail.com>
    Re: Reading binary files as numbers? <ben@morrow.me.uk>
    Re: Reading binary files as numbers? <uri@StemSystems.com>
    Re: Reading binary files as numbers? <jomarbueyes@hotmail.com>
        Regular expression help <jcombe@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 23 Sep 2009 22:00:06 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.23 How can I open a pipe both to and from a command?
Message-Id: <GTwum.244885$ZN.90096@newsfe23.iad>

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

8.23: How can I open a pipe both to and from a command?

    The IPC::Open2 module (part of the standard perl distribution) is an
    easy-to-use approach that internally uses pipe(), fork(), and exec() to
    do the job. Make sure you read the deadlock warnings in its
    documentation, though (see IPC::Open2). See "Bidirectional Communication
    with Another Process" in perlipc and "Bidirectional Communication with
    Yourself" in perlipc

    You may also use the IPC::Open3 module (part of the standard perl
    distribution), but be warned that it has a different order of arguments
    from IPC::Open2 (see IPC::Open3).



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Wed, 23 Sep 2009 18:51:51 -0700 (PDT)
From: guest <jiangwei.wang@gmail.com>
Subject: Re: FAQ 9.11 How do I redirect to another page?
Message-Id: <183aeee7-fd80-427a-9ba4-1c867bca2011@x25g2000prf.googlegroups.com>

On Sep 12, 3:00=A0pm, PerlFAQ Server <br...@theperlreview.com> wrote:
> This is an excerpt from the latest version perlfaq9.pod, which
> comes with the standard Perl distribution. These postings aim to
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is athttp://faq.perl.org.
>
> --------------------------------------------------------------------
>
> 9.11: How do I redirect to another page?
>
> =A0 =A0 Specify the completeURLof the destination (even if it is on the s=
ame
> =A0 =A0 server). This is one of the two different kinds of CGI "Location:=
"
> =A0 =A0 responses which are defined in the CGI specification for a Parsed
> =A0 =A0 Headers script. The other kind (an absolute URLpath) is resolved
> =A0 =A0 internally to the server without any HTTPredirection. The CGI
> =A0 =A0 specifications do not allow relative URLs in either case.
>
> =A0 =A0 Use of CGI.pm is strongly recommended. This example showsredirect=
ion
> =A0 =A0 with a completeURL. Thisredirectionis handled by the web browser.
>
> =A0 =A0 =A0 =A0 =A0 =A0 use CGI qw/:standard/;
>
> =A0 =A0 =A0 =A0 =A0 =A0 my $url=3D 'http://www.cpan.org/';
> =A0 =A0 =A0 =A0 =A0 =A0 print redirect($url);
>
> =A0 =A0 This example shows aredirectionwith an absolute URLpath. This
> =A0 =A0redirectionis handled by the local web server.
>
> =A0 =A0 =A0 =A0 =A0 =A0 my $url=3D '/CPAN/index.html';
> =A0 =A0 =A0 =A0 =A0 =A0 print redirect($url);
>
> =A0 =A0 But if coded directly, it could be as follows (the final "\n" is =
shown
> =A0 =A0 separately, for clarity), using either a completeURLor an absolut=
e
> =A0 =A0 URLpath.
>
> =A0 =A0 =A0 =A0 =A0 =A0 print "Location: $url\n"; =A0 # CGI response head=
er
> =A0 =A0 =A0 =A0 =A0 =A0 print "\n"; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 # end=
 of headers
>
> --------------------------------------------------------------------
>
> The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
> are not necessarily experts in every domain where Perl might show up,
> so please include as much information as possible and relevant in any
> corrections. The perlfaq-workers also don't have access to every
> operating system or platform, so please include relevant details for
> corrections to examples that do not work on particular platforms.
> Working code is greatly appreciated.
>
> If you'd like to help maintain the perlfaq, see the details in
> perlfaq.pod.

http://www.pangosoft.ca provides url redirection solution (high
performance, bulk loading, page to page ), especially good for large
scale site migration


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

Date: Thu, 24 Sep 2009 18:34:28 +0800
From: Water Lin <WaterLin@ymail.invalid>
Subject: How to check if a module is installed in Strawberry?
Message-Id: <83ab0kocln.fsf@ymail.invalid>


If I am using Strawberry in my Windows, I need to find out if a module
is already installed in Strawberry.

The command
$ perldoc perllocal
doesn't work under strawberry.
      
-- 
Water Lin's blog: http://blog.waterlin.org
Email: WaterLin@ymail.com


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

Date: Thu, 24 Sep 2009 13:44:03 +0200
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How to check if a module is installed in Strawberry?
Message-Id: <cqmmb5d54lj78lo61r376spmdf9qjjj6b4@4ax.com>

Water Lin wrote:

>If I am using Strawberry in my Windows, I need to find out if a module
>is already installed in Strawberry.

You can try this:

	perl -mFoo::Bar -e1

where Foo::Bar is the module you want to use.

If it complains, it is not installed. Otgherwise, it'll just do nothing.

-- 
	Bart.


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

Date: Thu, 24 Sep 2009 13:33:35 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to check if a module is installed in Strawberry?
Message-Id: <vh5so6-9kf2.ln1@osiris.mauzo.dyndns.org>


Quoth Water Lin <WaterLin@ymail.invalid>:
> 
> If I am using Strawberry in my Windows, I need to find out if a module
> is already installed in Strawberry.
> 
> The command
> $ perldoc perllocal
> doesn't work under strawberry.

You can use ExtUtils::Installed for this.

Ben



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

Date: Wed, 23 Sep 2009 05:02:03 -0700 (PDT)
From: mike <networkmodels82@gmail.com>
Subject: Information on latest mobile- Pass it on...
Message-Id: <2a974fbd-e120-40fb-b425-9bcc81e36d71@r24g2000prf.googlegroups.com>


Hey dude,

I have few information on lates mobiles just want to share about
todays trend with u guys....

http://latestmobilephonemodels4u.blogspot.com/


Also pass it to ur frenz....

http://swinefluanditsawarness.blogspot.com/
http://onlinejobathomeinfo.blogspot.com

Thanks


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

Date: Wed, 23 Sep 2009 10:55:36 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: Log4perl -- how to copy FATALs to STDERR
Message-Id: <tLidnSd2q-gFbSTXnZ2dnUVZ8jli4p2d@brightview.co.uk>

fishfry wrote:
> Apologies if this is simple, I've been looking at the docs and can't 
> figure it out. When I get a fatal error I want log4perl to log it to 
> STDERR as well as the logfile. How do I do this?

Create a "my_error" appender, pointed at STDERR.

Set the "threshold" of this appender to FATAL
Associate this appender with the loggers
you wish to have this behaviour for;
it is likely that most of you logger will then
have two appenders (the "normal" one and the my_error
one).

I'm assuming that the log4perl stuff works like
the log4j stuff, which is what I use.

   BugBear


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

Date: Wed, 23 Sep 2009 12:23:05 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: Log4perl -- how to copy FATALs to STDERR
Message-Id: <230920091223055125%brian.d.foy@gmail.com>

In article <rigjb51og4fuscdtu2tmjl5p2dh5ng1m09@4ax.com>, Bart Lateur
<bart.lateur@pandora.be> wrote:

> fishfry wrote:
> 
> >Apologies if this is simple, I've been looking at the docs and can't 
> >figure it out. When I get a fatal error I want log4perl to log it to 
> >STDERR as well as the logfile. How do I do this?


> On Unix shell, they usually use `tee` for that.
> 
> In Perl, are a couple of modules with the same functionality: IO::Tee,
> and File::Tee. You probably can use one of these.

You just configure Log4perl with another appender. You shouldn't be
getting into the weeds like that when you are using Log4perl.


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

Date: Wed, 23 Sep 2009 09:18:41 +0200
From: Mag <mag@laposte.net>
Subject: Perl and SNMP => List All interface ?
Message-Id: <4ab9cbcf$0$3589$426a74cc@news.free.fr>

Hi

anyone have a sample of perl script that list all
interface available on a cisco router in SNMP ?

because use .1.3.5.xxx it's not best ..

In sample:


 ./test.pl -H IP_Router -C sent :

Interface 1 :: Ethernet0/0
Interface 2 :: GigabitEthernet0/0
Interface 3 :: FastEthernet1/0
Interface 4 :: GigabitEthernet2/0
Interface 6 :: Null0
Interface 8 :: GigabitEthernet2/0.4
Interface 9 :: GigabitEthernet2/0.500
Interface 10 :: GigabitEthernet2/0.1051
Interface 18 :: Loopback1
Interface 19 :: GigabitEthernet0/0-mpls layer
Interface 20 :: GigabitEthernet2/0.1055
Interface 21 :: GigabitEthernet2/0.1056

and if i want know all information (in/out/packet), i can get
it in start with specify "Interface 20"

thanks for your help


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

Date: Wed, 23 Sep 2009 13:26:16 -0700 (PDT)
From: Jomar Bueyes <jomarbueyes@hotmail.com>
Subject: Reading binary files as numbers?
Message-Id: <c884fc3c-6e3d-45f9-a83e-263c4537d0f0@o21g2000vbl.googlegroups.com>

Hi,

I'm trying to read a binary file made of 4-byte integers. However,
Perl seems to be interpreting the the four bytes as four characters,
not one number.  I've unsuccessfully looked in perldoc -q binary,
perldoc -[fq] read, searched this newsgroup for "read binary", "read
binary number", ...

When I run the simplified program below, I get a warning that the
argument "$header[$k]" is not numeric.

Could you please let me know how can I make Perl interpret the four-
byte words as integers or how to convert the characters to their
equivalent signed integer? (later I'll also need floating point).
----
#!/usr/bin/perl
use strict;
use warnings;
my $filename = $ARGV[0];
my @header;

open(FH, '<:raw', $filename) || die("cound not open $filename: $!\n");
# I tried also w/o the ":raw", same results
for ( my $k = 0; $k<4; $k++){
   my $count = read(FH, $header[$k], 4) ||
            die("Could not read from $filename: $!\n");
   ### print "count = $count\n";
   printf "Header[%d] = %d\n", $k, $header[$k];
}
close(FH);
----
Thanks in advance


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

Date: Wed, 23 Sep 2009 13:50:34 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Reading binary files as numbers?
Message-Id: <bd2lb5hs92sunnm3iqu0sn1qojkejp9f06@4ax.com>

Jomar Bueyes <jomarbueyes@hotmail.com> wrote:
>I'm trying to read a binary file made of 4-byte integers. However,
>Perl seems to be interpreting the the four bytes as four characters,
>not one number.  [...]
>Could you please let me know how can I make Perl interpret the four-
>byte words as integers or how to convert the characters to their
>equivalent signed integer? (later I'll also need floating point).


perldoc -f pack
perldoc -f unpack

jue


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

Date: Wed, 23 Sep 2009 21:56:24 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Reading binary files as numbers?
Message-Id: <okeqo6-fe82.ln1@osiris.mauzo.dyndns.org>


Quoth Jomar Bueyes <jomarbueyes@hotmail.com>:
> 
> I'm trying to read a binary file made of 4-byte integers. However,
> Perl seems to be interpreting the the four bytes as four characters,
> not one number.  I've unsuccessfully looked in perldoc -q binary,
> perldoc -[fq] read, searched this newsgroup for "read binary", "read
> binary number", ...
> 
> When I run the simplified program below, I get a warning that the
> argument "$header[$k]" is not numeric.
> 
> Could you please let me know how can I make Perl interpret the four-
> byte words as integers or how to convert the characters to their
> equivalent signed integer? (later I'll also need floating point).

perldoc -f unpack

You'll also need to read perldoc -f pack for the format characters.

Ben



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

Date: Wed, 23 Sep 2009 17:16:34 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Reading binary files as numbers?
Message-Id: <87pr9hpdjh.fsf@quad.sysarch.com>

>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:

  BM> Quoth Jomar Bueyes <jomarbueyes@hotmail.com>:
  >> 
  >> I'm trying to read a binary file made of 4-byte integers. However,
  >> Perl seems to be interpreting the the four bytes as four characters,
  >> not one number.  I've unsuccessfully looked in perldoc -q binary,
  >> perldoc -[fq] read, searched this newsgroup for "read binary", "read
  >> binary number", ...
  >> 
  >> When I run the simplified program below, I get a warning that the
  >> argument "$header[$k]" is not numeric.
  >> 
  >> Could you please let me know how can I make Perl interpret the four-
  >> byte words as integers or how to convert the characters to their
  >> equivalent signed integer? (later I'll also need floating point).

  BM> perldoc -f unpack

  BM> You'll also need to read perldoc -f pack for the format characters.

and in recentish perls there is perlpacktut which is very helpful. the
pack docs are very terse and somewhat hard to understand if you don't
know c and machine level stuff.

uri


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

Date: Wed, 23 Sep 2009 14:47:06 -0700 (PDT)
From: Jomar Bueyes <jomarbueyes@hotmail.com>
Subject: Re: Reading binary files as numbers?
Message-Id: <006124fd-4c29-4f66-9cfc-3360d9d87fb9@33g2000vbe.googlegroups.com>

On Sep 23, 5:16=A0pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> >>>>> "BM" =3D=3D Ben Morrow <b...@morrow.me.uk> writes:
>
> =A0 BM> Quoth Jomar Bueyes <jomarbue...@hotmail.com>:
> =A0 >>
> =A0 >> I'm trying to read a binary file made of 4-byte integers. However,
> =A0 >> Perl seems to be interpreting the the four bytes as four character=
s,
> =A0 >> not one number. =A0I've unsuccessfully looked in perldoc -q binary=
,
> =A0 >> perldoc -[fq] read, searched this newsgroup for "read binary", "re=
ad
> =A0 >> binary number", ...
> =A0 >>
> =A0 >> When I run the simplified program below, I get a warning that the
> =A0 >> argument "$header[$k]" is not numeric.
> =A0 >>
> =A0 >> Could you please let me know how can I make Perl interpret the fou=
r-
> =A0 >> byte words as integers or how to convert the characters to their
> =A0 >> equivalent signed integer? (later I'll also need floating point).
>
> =A0 BM> perldoc -f unpack
>
> =A0 BM> You'll also need to read perldoc -f pack for the format character=
s.
>
> and in recentish perls there is perlpacktut which is very helpful. the
> pack docs are very terse and somewhat hard to understand if you don't
> know c and machine level stuff.
>
> uri

Thank you Uri, Ben, and J=FCrgen

Jomar


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

Date: Thu, 24 Sep 2009 05:52:45 -0700 (PDT)
From: Jon Combe <jcombe@gmail.com>
Subject: Regular expression help
Message-Id: <e060b911-ba1a-4748-aae4-39abc0ed1f0b@l31g2000vbp.googlegroups.com>

I realise this is not the ideal group, because there doesn't seem to
be a regular expressions group but since most Perl developers use
regular expressions I'm hoping someone will know! I use regular
expressions a lot but I have come accross a request that has me
stumped. The following needs to be done in a single regular
expression:-

Validate length to a minimum and maximum number of characters
Must contain at least one vowel
Must not contain any numbers
Must contain no more than 2 adjacent repeated characters (so aa is OK,
but aaa is not)

I can write a single regular expression to do 2 of those but I cannot
come up with a single regular expression to do all 4. Is it actually
possible? I realise it could easily be done with several expressions
and an "and" statement (and probably faster too), but this needs to be
plugged in to an application that accepts only a single regular
expression.

Thanks.
Jon.


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

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:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2610
***************************************


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