Re: Closing File Handles

2010-04-30 Thread Shawn H Corey
Harry Putnam wrote: "Joseph L. Casale" writes: Is it required to manually close a file handle I used to write debugging info to when the Perl scripts exits? Seems like a waste of effort at the end of the script to test `if debug...` and close the fh after? Not required no... that is, it won

Re: Redirecting the Output and Error of Perl script

2010-04-30 Thread Harry Putnam
Parag Kalra writes: > Hey All, > > I am trying to execute a Perl via shell script. I want to redirect output of > Perl script to one file and error occured (if any) to other file. > > This is the snippet from my shell script: > > perl output_error.pl 1>> Report.log 2>>Error.log > > However even n

Re: Closing File Handles

2010-04-30 Thread Harry Putnam
"Joseph L. Casale" writes: > Is it required to manually close a file handle I used > to write debugging info to when the Perl scripts exits? > > Seems like a waste of effort at the end of the script to > test `if debug...` and close the fh after? Not required no... that is, it won't cause an err

Re: about dispatch tables

2010-04-30 Thread Harry Putnam
Steve Bertrand writes: > First note that this will run forever :) Yup... for a second there I thought I'd inadvertently pressed `y' at the linux prompt... > Also, there's no proper conditional logic involved here, the dispatch > table subs are just calling back to other subs from within the di

Re: Can we perform substitution to the matched pattern inside a regular expression so that the modified pattern gets returned instead of earlier matched one ?

2010-04-30 Thread C.DeRykus
On Apr 30, 3:55 am, learn.tech...@gmail.com (Amit Saxena) wrote: > Hello everybody, > > Can we perform substitution to the matched pattern inside a regular > expression so that the modified pattern gets returned instead of earlier > matched one ? > > As a reference, in the following code below, I w

Re: Creating groups of bat files from perl script

2010-04-30 Thread Paul
On Fri, April 30, 2010 1:07 pm, John W. Krahn wrote: > Paul wrote: >> OK, was kinda rust, been working on Solaris servers for year, but not >> been >> working solely with windows, but I sure do miss scripting, no matter how >> screwed up my programming skills are, it's fun! Here is what I have >>

Redirecting the Output and Error of Perl script

2010-04-30 Thread Parag Kalra
Hey All, I am trying to execute a Perl via shell script. I want to redirect output of Perl script to one file and error occured (if any) to other file. This is the snippet from my shell script: perl output_error.pl 1>> Report.log 2>>Error.log However even normal print messages are going to Erro

RE: Here Docs

2010-04-30 Thread Joseph L. Casale
>> You can use the trick mentioned in 'perldoc -q string' "How do I expand >> function calls in a string?" Funny that the perldoc uses the exact function I wanted to use:) >localtime is a Perl function, not an external command, so: Thanks guys! jlc -- To unsubscribe, e-mail: beginners-unsubscr.

Re: Creating groups of bat files from perl script

2010-04-30 Thread Jim Gibson
On 4/30/10 Fri Apr 30, 2010 9:55 AM, "Paul" scribbled: > On Fri, April 30, 2010 12:37 pm, Jim Gibson wrote: >> If you do need to change '/' to '\': >> >> $path =~ s{ / }{\\}gx; > > I'll have to remember that when tr///d doesn't work! Thanks. Why are you using the d modifier, which mea

Re: Creating groups of bat files from perl script

2010-04-30 Thread John W. Krahn
Paul wrote: OK, was kinda rust, been working on Solaris servers for year, but not been working solely with windows, but I sure do miss scripting, no matter how screwed up my programming skills are, it's fun! Here is what I have with "\" replacing "/" and better fixes with counting. Yes, I know

Re: Here Docs

2010-04-30 Thread John W. Krahn
Jim Gibson wrote: On 4/30/10 Fri Apr 30, 2010 9:27 AM, "Joseph L. Casale" scribbled: Inside a here doc, how can I force an expression to be evaluated such as localtime: print <<"END"; `localtime time` Foo Bar END I know I can simply create the var before, my $var = localtime time; Bu

Re: Creating groups of bat files from perl script

2010-04-30 Thread Paul
On Fri, April 30, 2010 12:37 pm, Jim Gibson wrote: > On 4/30/10 Fri Apr 30, 2010 9:24 AM, "Paul" > scribbled: > >> OK, it was late at night, and working 7 days/week doesn't help. Anyhow, >> after looking at my convoluted script, I have one that works now, but am >> now trying to figure out an e

Re: Creating groups of bat files from perl script

2010-04-30 Thread Paul
OK, was kinda rust, been working on Solaris servers for year, but not been working solely with windows, but I sure do miss scripting, no matter how screwed up my programming skills are, it's fun! Here is what I have with "\" replacing "/" and better fixes with counting. Yes, I know there is a bet

Re: Here Docs

2010-04-30 Thread Jim Gibson
On 4/30/10 Fri Apr 30, 2010 9:27 AM, "Joseph L. Casale" scribbled: > Inside a here doc, how can I force an expression to be evaluated > such as localtime: > > print <<"END"; > > `localtime time` > Foo > Bar > > END > > > I know I can simply create the var before, > my $var = localtime tim

Re: function return

2010-04-30 Thread Shawn H Corey
C.DeRykus wrote: Um, that won't do what you think. The () just tosses all the return arg's and $name remains undefined because of the list context. my($name) = () = Function1($arg); # $name stays undef If $name were in scalar context though, you'd get a count of the arg's returned and thrown

Re: Creating groups of bat files from perl script

2010-04-30 Thread Jim Gibson
On 4/30/10 Fri Apr 30, 2010 9:24 AM, "Paul" scribbled: > OK, it was late at night, and working 7 days/week doesn't help. Anyhow, > after looking at my convoluted script, I have one that works now, but am > now trying to figure out an easy way to change the "/" in the resultant > file to "\" to

RE: Creating groups of bat files from perl script

2010-04-30 Thread Bob McConnell
From: Paul > OK, it was late at night, and working 7 days/week doesn't help. Anyhow, > after looking at my convoluted script, I have one that works now, but am > now trying to figure out an easy way to change the "/" in the resultant > file to "\" to work in windows. Always something. Do you re

Closing File Handles

2010-04-30 Thread Joseph L. Casale
Is it required to manually close a file handle I used to write debugging info to when the Perl scripts exits? Seems like a waste of effort at the end of the script to test `if debug...` and close the fh after? Thanks! jlc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Here Docs

2010-04-30 Thread Joseph L. Casale
Inside a here doc, how can I force an expression to be evaluated such as localtime: print <<"END"; `localtime time` Foo Bar END I know I can simply create the var before, my $var = localtime time; But just curious how to evaluate expressions inside this... Thanks! jlc -- To unsubscribe, e-

Re: Creating groups of bat files from perl script

2010-04-30 Thread Paul
OK, it was late at night, and working 7 days/week doesn't help. Anyhow, after looking at my convoluted script, I have one that works now, but am now trying to figure out an easy way to change the "/" in the resultant file to "\" to work in windows. Always something. #user/bin/perl -w use File::

Re: function return

2010-04-30 Thread Akhthar Parvez K
On Thursday 29 Apr 2010, C.DeRykus wrote: > Um, that won't do what you think. The () just tosses all > the return arg's and $name remains undefined because > of the list context. > >   my($name) = () = Function1($arg);  # $name stays undef > > If $name were in scalar context though, you'd get a c

Re: XML Replace

2010-04-30 Thread Shlomi Fish
Hi, sorry for the late response. On Wednesday 28 Apr 2010 20:12:36 Trev wrote: > I'm trying to use Perl to replace a line in a few XML files I have. > > Example XML below, I'm wanting to change the Id= part from Id="/Local/ > App/App1" to Id=/App1". I know there's an easy way to do this with >

Re: [mongers-it] Is this a feature or a bug?

2010-04-30 Thread Emanuele Zeppieri
On 29/04/2010 17.56, marcos rebelo wrote: the code: use v5.10; use Modern::Perl; use List::MoreUtils qw(any); say( (any { $_ eq 7 } (0..10) ) or 'false' ); given (5) { when (5) { say( (any { $_ eq 7 } (0..10) ) or 'false' ); say( join(", ", map { $_ eq 7 } (0..10) ) );

Re: Need help to resove..... ExtUtils-Makemaker comilationS

2010-04-30 Thread Shlomi Fish
Hi Raheel, On Friday 30 Apr 2010 14:17:03 Raheel Hassan wrote: > Hi Shlomi, > > I am very thankful to you for helping me, yes i resolved the problem > actually perl-devel was missing. So when i executed 'urpmi perl-devel' i > got EXTERN.h. Now i am able to install all the required packages from >

Re: AW: Passing arguments @_

2010-04-30 Thread Shawn H Corey
HACKER Nora wrote: If you do: my ($var1) = @_; You're doing list assignment and, as a result, you assign $var1 to the $_[0] and don't make use of $_[1], $_[2], $_[3], etc., which may or may not exist. Thanks, perfectly clear now. In 'perldoc perlsub' I read that I only have to use parenthe

Can we perform substitution to the matched pattern inside a regular expression so that the modified pattern gets returned instead of earlier matched one ?

2010-04-30 Thread Amit Saxena
Hello everybody, Can we perform substitution to the matched pattern inside a regular expression so that the modified pattern gets returned instead of earlier matched one ? As a reference, in the following code below, I want to perform the substitution of "~" character with "_" character to the va

Re: function return

2010-04-30 Thread C.DeRykus
On Apr 29, 4:57 am, shawnhco...@gmail.com (Shawn H Corey) wrote: > Akhthar Parvez K wrote: > > Hi, > > > The following line stores the first return value by the function Function1 > > to the variable $name: > > > my ($name) = @_[0] = &Function1 ($arg); > > > but this one doesn't work: > > my ($nam

Re: How to make a hash in a subroutine accessible by all other subrountines?

2010-04-30 Thread Brad Baxter
Remy Guo wrote: hi all, I've got a problem in following script: sub A { our %a; $a{"fred"} = 1; $a{"bella"} = 2; ... } sub B { if ($fred != $a{"fred"}) { print "fred failed.\n"; } if ($bella != $a{"bella"} { print "bella failed.\n"; } } The problem

Re: XML Replace

2010-04-30 Thread Brad Baxter
Trev wrote: I'm trying to use Perl to replace a line in a few XML files I have. Example XML below, I'm wanting to change the Id= part from Id="/Local/ App/App1" to Id=/App1". I know there's an easy way to do this with perl alone however I'm trying to use XML::Simple or any XML plugin for perl.

Re: [Lisbon.pm] Is this a feature or a bug?

2010-04-30 Thread Paulo
I think it's a bug in "any" ... Try this: my $_ = 5; say( (any { $_ eq 7 } (0..10) ) or 'false' ); given (5) { when (5) { say( (any { our $_ eq 7 } (0..10) ) or 'false' ); say( join(", ", map { $_ eq 7 } (0..10) ) ); } } and it prints: false 1 , , , , , , , 1, , , B

AW: Passing arguments @_

2010-04-30 Thread HACKER Nora
Hi Shlomi, > Because the lack of parenthesis signifies that the right-hand-side will > be > done in scalar context. As a result it is equivalent to: > > my $var1 = scalar(@_); > > Which is the length of the @_ array (which sometimes have some valid > uses if > you're checking for optional argum

Re: Passing arguments @_

2010-04-30 Thread Shlomi Fish
Hi Nora, On Friday 30 Apr 2010 09:55:33 HACKER Nora wrote: > Hi, > > For calling subroutines and passing arguments on I use e.g. > > my ( $var1, $var2 ) = @_; > > If I have only one argument, this is also ok: > > my ( $var1) = @_; > > But why does > > my $var1 = @_; > > not work? Because