AW: Subroutine

2010-10-11 Thread Thomas Bätzler
Jyoti asked: > Can anyone help me out to call all subroutines from different .pm files > in a specific directory please? Maybe if you were a bit more specific about what you're tyring to do. Maybe you want to start out by looking at http://search.cpan.org/~adamk/Class-Inspector-1.24/lib/Class/I

AW: testing tcp connection

2010-08-31 Thread Thomas Bätzler
Kammen van, Marco, Springer SBM NL asked: > I have an issue when something goes wrong with the client that's trying > to connect. > > 9 out of 10 times this works fine, but there are odd situations where > $clientip doesn't get filled in, which leaves me with a connection I > can't do anything wi

AW: Data migration

2010-07-26 Thread Thomas Bätzler
Shlomi Fish wrote: > My suggestion is to simply copy the appropriate lines from the > /etc/passwd to > the new /etc/passwd. ... and of course not to forget about /etc/shadow because otherwise you won't be able to login. HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

AW: hash arrays

2010-07-26 Thread Thomas Bätzler
Hi, Sharan Basappa asked: > I am reusing a code for some enhancements. According to my > understanding, it is a record with > some unique string as key and then hash array as the value. > > I iterate through the array and print as follows: > > foreach my $key (keys %{$abc}) > { > print "$key

AW: array to hash array

2010-07-26 Thread Thomas Bätzler
Sharan Basappa asked: > Can someone tell me how to convert an array to hash. > > Each array entry has a row of values > e.g. a(0) = ab cd ef; a(1) = mn de fg > > The hash array needs to be constructed with one of the element in the > array row as the key. > e.g. hash{ab} = cd ef - ab is a s

AW: Compare file/dir size

2010-07-23 Thread Thomas Bätzler
e to get the stat > would not be overly elegant!? I'll stand corrected... You could run sha1sum (or md5sum or whatever you have) on the list of files you transferred, then comparte the output of both runs. MfG, Thomas Bätzler -- BRINGE Informationstechnik GmbH Zur Seeplatte 12 D-76228 Ka

AW: Query on Qunatifiers

2010-07-15 Thread Thomas Bätzler
Chandan Kumar asked: > I have query over quantifiers. > > Could you please explain the combination of operators Question mark > (?),dot(.),star(*),plus(+). > > Say this is my string: > > $_ = " this is my first pattern ,quite confused with quantifiers" > > ex: (thi.*?) or (thi.+?) etc > >

AW: question abt array

2010-06-29 Thread Thomas Bätzler
Chaitanya Yanamadala asked: > i am in a situation like i have a scalar $value = 5 > now i need to create an array with the number i mean $value > how can i do it?? Don't even think about messing with the symbol table, use a hash variable instead: my %hash; my @array = qw(foo baz

AW: Multi page form - cgi

2010-06-28 Thread Thomas Bätzler
Herb asked: > I've been working on putting together a multi-page form in a single > perl script. I have everything working as a single page form (writing > to mysql database and emailing the output upon submit) but have not > had any luck breaking the form into multiple pages. As mentioned > bef

AW: Multiple background processes

2010-06-24 Thread Thomas Bätzler
HACKER Nora asked: > I am currently having an issue with background processes. I already > searched the web and found a way how to principally send a process into > background, wait for the execution to finish and then go on with the > main program: > > my $pid = fork; > if ( $pid ) { > wait;

AW: A subroutine to find every occurrence of a substring in a string?

2010-06-09 Thread Thomas Bätzler
Peng Yu asked: > I can't find an existing perl subroutine (in the library) to find > every occurrence of a substring in a string. The following webpage > "Example 3b. How to find every occurrence" uses a loop to do so. But > I'd prefer a subroutine. Could you let me know if such a subroutine is >

AW: an odd conditional statement

2010-06-09 Thread Thomas Bätzler
sillymonkeysoftw...@gmail.com asked: > I'm working with some customizable data from a config file, and can't > for the life of me figure out how to test conditionals from an > external source. > Does anyone have an idea how to accomplish something like: > > my $statement = "1 < 10 and 2 > 1

AW: Perl file with arguments

2010-06-09 Thread Thomas Bätzler
Gopal Karunakar asked: > How can i declare a simple perl script file which will take > arguments from the user? an example will be take two numbers and > give the sum as output. Do you want to pass the arguments on the command line or prompt for them after starting your script? In the firs

AW: Value betwwen quotes

2010-06-04 Thread Thomas Bätzler
Chaitanya Yanamadala asked: > i have a string like this > HPOS="573" VPOS="3003"> > > i need to get the values between the " " after the ID= . So how can i > do it, Can any one help me?? Assuming the string is on a single line: #!/usr/bin/perl -w use strict; use warnings; my $line = ''; if

AW: Find duplicates in an array

2010-06-02 Thread Thomas Bätzler
Gopal Karunakar asked: > I needed to find all the duplicate values in an array and their count > of occurences. Any help would be appreciated . #!/usr/bin/perl -w use strict; my @array=qw(foo baz bar foo baz foo); my %seen; foreach my $item (@array){ $seen{$item}++ } foreach my $item (keys

AW: Developer docs

2010-05-28 Thread Thomas Bätzler
Hi, Steve Bertrand asked: > Is there a POD system that can be used exclusively for 'developer' > documentation? Can I make devel docs 'hidden' from the rest of the POD? > > If not, can you recommend a decent practice that I can weave into my > current documentation methodology so that people can

AW: Using Arrays and if loops together

2010-05-27 Thread Thomas Bätzler
Hello Niall, niallheavey wrote: > I'm very new to perl but I will try to explain where I am at the > moment. Providing sample input and output is fine. However, if you need help with your code people here have to be able to look at it. Try and post a minimal example for the problem you're havi

AW: print sub code

2010-05-20 Thread Thomas Bätzler
Tech list asked: > Let's say I have a module XYZ with a sub in it call ABC. I'd like to > print the source code of XYZ::ABC. > > My reason for this is I accidentally overwrote a module with an older > version, but I still have httpd running which has it loaded in memory. You can't print the "so

AW: Good/best practice - pre-declare variables

2010-05-20 Thread Thomas Bätzler
HACKER Nora wrote: > Obviously, my point wasn't clear enough, I'm sorry for that. The > variable in the code extract that I'm really bothering about is the > $sdb: It is needed in the SWITCH of a sub-function, but this construct > only works if I pre-declare the $sdb in the calling function backup

AW: data dumper

2010-05-17 Thread Thomas Bätzler
d in a Perl source file. OTOH, it's easier to shoot yourself in the foot that way. MfG, Thomas Bätzler -- BRINGE Informationstechnik GmbH Zur Seeplatte 12 D-76228 Karlsruhe Germany Fon: +49 721 94246-0 Fon: +49 171 5438457 Fax: +49 721 94246-66 Web: http://www.bringe.de/ Geschäftsführer: D

AW: Hash with variable name

2010-05-12 Thread Thomas Bätzler
HACKER Nora asked: > Thanks for your explanation and the reference to perldoc, I understand > now. But it doesn't work yet, I still get the same error. I have > altered my source now as follows: > > my %stp_dirs = ( "mvb" => "\%mvb_dirs", > "pkv" => "\%pkv_di

AW: Hash with variable name

2010-05-12 Thread Thomas Bätzler
HACKER Nora asked: > > Try: > > > > my %stp_dirs = ('mvb' => \%mvb_dirs, > > 'pkv' => \%pkv_dirs, > > 'av' => \%av_dirs, > > 'be' => \%be_dirs, > > 'vvw' => \%vvw_dirs ); > > > > while ( my($sdir,$tdir) = each %{$s

AW: Hash with variable name

2010-05-12 Thread Thomas Bätzler
HACKER Nora wrote: > The script is being started with a parameter $stp (among others) that > can be one of mvb/pkv/av/be/vvw. This parameter is used as a key for a > master hash the values of which are names of other hashes themselves. > > # Master-Hash > my %stp_dirs = ( "mvb" => "mvb_dirs", >

AW: sort hash with an array as the value

2010-05-11 Thread Thomas Bätzler
Owen asked: > I have this statement; > > foreach my $key ( keys %filehash ) { > print "$key $filehash{$key}->[0]\t\t\t$filehash{$key}->[3]\t > $filehash{$key}->[2]\t $filehash{$key}->[1]\n"; > } > > but wish to sort the output by $filehash{$key}->[0]. Is it possible? > How do I do this? for

AW: fork, read from child process and timeout

2010-05-11 Thread Thomas Bätzler
Weizhong Dai asked: > - > $pid = open(README, "program arguments |") or die "Couldn't fork: > $!\n"; > while () { > # ... > } > close(README) > -- > > my problem is: I read from README, but if waiting for next input is > timeou

AW: AW: Remove and substitute character in a string with a regex

2010-05-10 Thread Thomas Bätzler
Hi Shlomi, > use warnings is preferable to the -w flag. Not in my book. The command line switch turns on warnings globally, whereas the "use warnings;" pragma only enables them in the current lexical scope. So by using the command line switch, I get warnings about crappy third-party code, too.

AW: Remove and substitute character in a string with a regex

2010-05-10 Thread Thomas Bätzler
Finalfire asked: > Hello guys! I'm skilling regex using Perl and i've some trouble about > a simple try: > i've a string like: > > $string = "HELLAAABB"; > > and i want to manipulate in that way: HELL4O3ABB4C;You can simply > notice that when i have 3 or more occurrences of a character,

AW: IMAP email client: style & security

2010-05-10 Thread Thomas Bätzler
Eitan Adler wrote: > I wrote a program to fetch email from a IMAP account, look to see if I > sent it, if yes execute any commands in the email and email the results > back to via a SMTP server. [...] > 2) Secondly since this program executes commands from a potentially > insecure source I'd like

AW: about dispatch tables

2010-05-05 Thread Thomas Bätzler
Harry Putnam asked: > But even though I can work with that... I'm still not seeing why the > values in @_ are not available at the call to N() inside like this: > (incomplete code) > > func($val1,$val2); > > sub func { %h = ( N => sub { print N(@_) . "\n"; } ); } If you call the sub like this,

AW: about dispatch tables

2010-05-05 Thread Thomas Bätzler
Harry Putnam asked: [...] > which is also inside sub dispt {the sub function}. Where does global > come in? Hint: $code->(@_); HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

AW: Array, foreach problem

2010-05-05 Thread Thomas Bätzler
Brian asked: > >> foreach $line () { > > > > while (my $line = <$logfile>) would be a better idea than > > foreach $line. > > Just curious for an explanation to this. I tend to use foreach too. > Don't they both accomplish the same thing? :) "foreach ()" means that the whole file will

AW: How to Decode UDP packets got from libpcap using Net::Pcap

2010-05-05 Thread Thomas Bätzler
perl asked: > > I have used libpcap to capture data using Net::Pcap module [...] > This is an UDP DNS Query How can i Decode them ... Any one Please > help me http://www.net-dns.org/docs/Net/DNS/Packet.html HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additiona

AW: Directory sizes

2010-05-04 Thread Thomas Bätzler
" and "alias") on the remote machine to see wether you're getting additional options that way. MfG, Thomas Bätzler -- BRINGE Informationstechnik GmbH Zur Seeplatte 12 D-76228 Karlsruhe Germany Fon: +49 721 94246-0 Fon: +49 171 5438457 Fax: +49 721 94246-66 Web: http://www.brin

AW: sendmail arguments

2010-04-28 Thread Thomas Bätzler
John Bruin asked: > I have inherited a Perl script which sends and parses email. I > am having trouble trying to figure out what the "-oi" and > "-oem" arguments do in the sub below. Can anyone help? "-oe" sets the ErrorMode. >From http://www.sendmail.org/~ca/email/man/sendmail.html: ErrorMod

AW: Interactive shell in Perl

2010-04-27 Thread Thomas Bätzler
Parag Kalra asked: > Wanted to know if Perl has any interactive shell (just like Python, > Bash, Ruby etc have) by any chance. And if yes how do we invoke > that. Since you mentioned bash, the zoidberg shell might be an option: http://search.cpan.org/~pardus/Zoidberg-0.96/man1/zoid.pod HTH, Thom

AW: get path to linked directory

2010-04-27 Thread Thomas Bätzler
Andreas Moroder asked: > I have a entry in my directory that is a soft-link to another > directory. > Is there a way in perl to get, starting from the link, the path of the > real directory ? http://perldoc.perl.org/Cwd.html#abs_path-and-friends HTH, Thomas -- To unsubscribe, e-mail: beginners-

AW: Perl rounding errors?

2010-04-26 Thread Thomas Bätzler
Rob Coops asked: > I am just wondering if I sumbled upon an error in perl an error in my > logic or somehtign else see the below perl one liners > > $ perl -e '$n = 0.945; $r = sprintf("%.2f", $n); print "$r\n";' > 0.94 Short answer: You shouldn't use floating point numbers for financial calcul

AW: AW: why does this code fail with stat?

2010-04-22 Thread Thomas Bätzler
Harry Putnam asked: > I pointed to that exact piece of code then asked how to make that > kind of options setting when using this format of find() > > find( >sub { > if(bla){ >blabla > } >}, > @dir > ); That's not possible, since there is neither an option parameter

AW: Meta: "Nice" Perl?

2010-04-22 Thread Thomas Bätzler
HACKER Nora asked: > I wonder if some of you are in the same situation like me: I am the > only Perl programmer in the company, at least trying hard to get > along :-), but I have nobody to ask for help. So I spend hours and > hours with my book and the internet when I'm stuck. Luckily, so far > I

AW: Newbie stuck at the first hurdle

2010-04-22 Thread Thomas Bätzler
Kryten asked: > This is embarrassing. > > All I want to do is read the content of a simple 10 line .txt file > into an array > and print out the lines, and I just can't seem to get it to work! > /* > $target = "D:\testfile.txt"; > open NEWBIE, "<"$target"; > @arr = ; > foreach $line (@arr) { > pr

AW: why does this code fail with stat?

2010-04-21 Thread Thomas Bätzler
Harry Putnam wrote: > I'm not finding a reference in perldoc File::Find showing how to set > that flag when using the popular notation like the script involved > here. Probably a case of not seeing the woods because of the trees ;-) To quote: NAME File::Find - Traverse a directory tree.

AW: How to manage large Conditional Statement

2010-04-20 Thread Thomas Bätzler
Mimi Cafe asked: > I need to evaluate a statement in an if, elsif, else block, and the > statement to evaluate in the elsif is too large as I need to run a SQL > query and act on the return value. > What would be a better way to achieve this? Putting the SQL statement > elsewhere outside the block

AW: Problems with "show tech" using the Net::Telnet Module

2010-04-20 Thread Thomas Bätzler
Asterix asked: > I've made a little script to capture the output of networking > devices. > Everything works fine, until I use the "show tech" command in an Cisco > device. Have you considered using the cmd() method of Net::Telnet? It has the option to individually set a reply timeout for each c

AW: Is there any method to tell different between warning and errors?

2010-04-19 Thread Thomas Bätzler
Jeff Pang wrote: > On Tue, Apr 20, 2010 at 1:28 PM, Weizhong Dai > wrote: > > Hi all, > > In my script, I have a system call, and redirect the stderr to a > file. > >        # > >        # open STDERR, ">$workpath\\error_log.txt"; > >        # system "..."; > >        # > > but I only want the E

AW: Writing Perl scripts to run on any OS'es

2010-04-19 Thread Thomas Bätzler
newbie01 perl asked: > Am wanting to change my Perl scripts to get it to run on several UNIX > flavours and Windows. At the moment, the only way I can think of how to > accomplish that is always having the following checks on each and every > sub that I have. > > Can anyone please suggest if ther

AW: Can't locate object method "TIEHASH" via package " Apache::Session::MySQL

2010-04-19 Thread Thomas Bätzler
> LockHandle => $dbh > }; > > So did you try just the single quotes? @Owen: If you "really don't know" then your suggestions are cargo cult programming. Please don't do that. As a rule of thumb, use single quotes if you're dealing with a literal stri

AW: Problem in installing ActivePerl 5.10 on Windows 7 with x64 chipset

2010-04-15 Thread Thomas Bätzler
Hi, Rene Schickbauer wrote: > For me, the msi packages worked quite well for the last few years. > Altough i'm currently using the x86 versions due to some trouble with a > few packages - mostly the ones that link to an external closed-source > library, but i also had troubles with DBD::Pg. As f

AW: Perl get host's IP

2010-04-14 Thread Thomas Bätzler
asked: > Is there a general way to get linux OS's bound ip addresses? for > example, the IP on eth0, eth1 etc. Thanks. http://search.cpan.org/~lds/IO-Interface-1.05/Interface.pm could be a "good enough" solution for you. I say "good enough" since it gives you all of the info that you'll get fr

AW: Copy file from one server to another

2010-04-14 Thread Thomas Bätzler
Chris Coggins asked: > I need to copy a small config file from one server to another. I'm > generating the file on one server with a pretty complex script. I need > to put that file on another server for immediate user access via html. > I've tried just writing the file straight to the new server

AW: html print

2010-04-12 Thread Thomas Bätzler
Chris Coggins asked: > I'm having trouble getting a piece of data from a form input to print > in html. Here's the relevant portion of my code > > sub subroutine { > my($hash) = shift; > my($data) = "$hash->{'expl'}"; > > print "Content-type: text/html\n\n"; > print < This employee has $data > S

AW: about beginner perl site and developing skill

2010-04-08 Thread Thomas Bätzler
> What is a CMS? http://en.wikipedia.org/wiki/Content_management_system > What is meant by chipcards? http://en.wikipedia.org/wiki/Chip_card HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

AW: String length limits?

2010-04-08 Thread Thomas Bätzler
Hi, Chris Coggins asked: > Is there a limit to the length of a string in perl? I'm combining about > 200 pieces of data into a single string and writing the string to a > file and am getting some weird behaviors every once in a while. Does perl > have a limit on the length of a string it writes t

AW: Date calculation help/suggestion please ... when there is no Date or Time module available

2010-04-07 Thread Thomas Bätzler
newbie01 perl wrote: > Problem 1: > - Is there a function to compare the two (2) dates so ensure that I > will always be doing -? At the moment, the > workaround that am doing is if I get a negative value, then that > means, I've done a - and need to change > the way I print the output. If you fa

AW: Converting 12 hour time format to 24 hour format ... a bit urgent

2010-04-07 Thread Thomas Bätzler
newbie01 perl asked: > Unfortunately, I suddenly have to to deal with an input file where the > datetime format is 02-Apr-2010 3:41:23 p.m., i.e. DD-MON- HH:MI:SS > a.m./p.m., so now my Delta_YMDHMS does not work as expected. You can convert from a.m./p.m. to standard 24 hours using a simple

AW: Perl: Subroutines and use of the "GD::Graph::bars;" Module

2010-04-06 Thread Thomas Bätzler
alekto asked: > I manage to generate the array from the input file, but it seems like > there is something wrong with my subroutine at the end, I have been > using the examples at cpan.org as an templat for this subroutine. > Following is the error msg, as well as the complete script. > hostname$

AW: Working with files of different character encodings

2010-04-06 Thread Thomas Bätzler
Doug Cacialli asked: > Does anyone have any ideas how I can make the second block of code > work? Or otherwise accomplish the task without opening the .txt file > twice? How large are your data files? If your available memory is much larger than your maximum file size, you might get away with s

AW: about the various styles of `open'

2010-04-06 Thread Thomas Bätzler
Harry Putnam asked: > I see advanced users here using various styles of open(). [three argument open] > Is there something beyond style that makes those methods better than > what appears to be a simpler format: [two argument open] Allow me to quote "perldoc -f open": The filena

AW: Perl appears to be introducing whitespace when reading .txt files

2010-04-01 Thread Thomas Bätzler
modify your program to handle Unicode input. In any case you could try this snipped in your code: print "NUL character found in string - input might be UTF-16\n" if $line =~ m/\x00/; MfG, Thomas Bätzler -- BRINGE Informationstechnik GmbH Zur Seeplatte 12 D-76228 Karlsruhe

AW: Perl appears to be introducing whitespace when reading .txt files

2010-03-31 Thread Thomas Bätzler
Doug Cacialli wrote: > I'm completely baffled by this and not entirely sure where to start. > > I have a plain text file, testfile.txt, which contains a single line: Could this be an encoding issue? How big is that file? Larger than 18 or 19 bytes? If yes, http://perldoc.perl.org/perlunicode

AW: AW: Syntax of Foreach loop

2010-03-31 Thread Thomas Bätzler
Uri Guttman wrote: > >>>>> "TB" == Thomas Bätzler writes: > TB> with the -w switch or the "use warnings;" pragma which requires > TB> variables to be declared before their first use. > > that is the use strict pragma, not the

AW: Syntax of Foreach loop

2010-03-30 Thread Thomas Bätzler
Jon Forsyth asked: > I am truly a beginner. Could someone help me understand this syntax > out of a code example from "Learning Perl"? On line 5 I'm confused > as to why "my $number" is between "foreach" and the ()? is "my > $number part of the loop? "my" declares a variable for the lexical sc

AW: Storing a Hash Inside An Array

2010-03-26 Thread Thomas Bätzler
Pry, Jeffrey asked: > Now, I was wondering if it would be possible to store a hash inside of > an array. Sure, just use the anonymous hash constructor {}, i.e. like $settings[$i] = { 'ftpserver' => localhost, 'password' => 'p...@$$word' }; Or add/change individual keys in the hash $setting

AW: Regex question

2010-03-24 Thread Thomas Bätzler
Bruce Ferrell wrote: > if ( ! defined $username || ! $username =~ /[0-9]{10,11}/ ) { > > do something; > > } else { > > do something else; > > } > > what that's supposed to do is this: > if it's blank or not 10 or 11 digits... > > The question is where is my understanding faulty or did I me

AW: Deleting last 10 lines of a file

2010-03-23 Thread Thomas Bätzler
sheela b asked: > How to delete last 10 lines of a file using Perl one liner? > > I used the following one liner to delete first 10 lines of a file, > > perl -i.bak -ne 'print unless 1..10' test.txt OTTOH: perl -i.bak -ne 'BEGIN { $b[9]="" } print shift @b; push @b, $_' test.txt @b i

AW: CGI-BIN Help/Advise - editing a file - HOW ?

2010-03-15 Thread Thomas Bätzler
newbie01 perl asked: > At the moment, I have some sort of INI/config file that I edit manually > via vi. These config files are "simple" delimited file that are used by > some of the scripts running on the server. > > I want to be able to the same thing via cgi-bin, can anyone advise where > to s

AW: Please excuse the NOOB question - but I guess since this is a perl.beginners group

2010-02-26 Thread Thomas Bätzler
Hi, GlenM wrote: > I am sure that someone out there has done this before - I *think* I am > on the right track. > > I have a directory full of emails. What I would like to do is read > each file in, then parse them into a CSV style file. Quick aside: you can use the $. builtin variable to get t

AW: newline problem

2010-02-01 Thread Thomas Bätzler
Michom asked: > I am new to perl and I have written a smal script to grab data from > one file, and put them into another file. The problem is new lines, > which are printing nice under a linux environment, but it is all > messed up if I open it with notepad. I am running Perl 5 under cygwin. Thi

AW: Warning: Use of uninitialized value

2010-01-28 Thread Thomas Bätzler
Bob Williams asked: > I am trying to split the lines in a file into two halves (at the first > space) each half going into an array. The code I have written is below. > ---Code--- > #!/usr/bin/perl > use warnings; > #use strict; use strict; # unless you know what you're doing. > #use diagnostic

AW: passing a hash via cookie and dereferencing it

2010-01-19 Thread Thomas Bätzler
mike asked: > I am trying to pass a hash of hashes from one script to another via a > cookie. I can get the cookie to pass, but when I try to get the inner > hash keys and values using what I think is the correct method, I > cannot get them. Here are two scripts which should do it, but don't: A

AW: chroot as non-root?

2010-01-04 Thread Thomas Bätzler
Trevor Vallender asked: > I am designing a system in which scripts are installed into their own > directory, by a non-root user, under their home directory. > > It is very important they not be allowed to write anywhere outside the > directory they are installed in. There are two ways I thought o

AW: :POP3 -- download only x number of mails

2009-12-13 Thread Thomas Bätzler
Agnello George asked: > I am planning to use the Net::POP3 module to downald a mail box and then > pass the mails via a parser . I would like to know if the there is a > option to downlod only a certin number ( 100 ) of mails [unread] > and then mark the mails as read . The mail box sie is 40

AW: how to automate yum installation

2009-12-07 Thread Thomas Bätzler
t using "yum -y" instead. MfG, Thomas Bätzler -- BRINGE Informationstechnik GmbH Zur Seeplatte 12 D-76228 Karlsruhe Germany Fon: +49 721 94246-0 Fon: +49 171 5438457 Fax: +49 721 94246-66 Web: http://www.bringe.de/ Geschäftsführer: Dipl.-Ing. (FH) Martin Bringe Ust.Id: DE812936645, HRB 1089

AW: Regular expressions question

2009-11-18 Thread Thomas Bätzler
Hi, Dermot suggested: > 2009/11/17 mangled...@yahoo.com : > > Can anyone tell me hoq to write a regular expression which matches > > anything _except_ a litteral string ? > > > > For instance, I want to match any line which does not begin with > > Nomatch.  So in the following : > You would ne

AW: Perl CGI Incremental find

2009-11-17 Thread Thomas Bätzler
Hi, Jeff Pang wrote: > On Nov 17, 2009, Dave Tang wrote: > > Is it possible to implement an incremental find* feature on a Perl CGI > > page? I'm running Apache2 with mod_perl on linux. > > > > For example, if I have a list of stuff (A, Aa, B, Bb, C, CA, etc. stored > > in a file or database)

AW: How to catch the DBI module error message

2009-11-09 Thread Thomas Bätzler
Parag Kalra asked: [DBI] > However I just wanted to know if there is a way to catch this error > message through some standard DBI variable so that I can print it in a log > file You can use the errstr() class and instance methods to access the last error message. In order to stop DBI from pri

AW: AW: How do I pick one random element from an array?

2009-11-02 Thread Thomas Bätzler
Dave Tang asked: > Just a quick question, how does Perl interpret something like > $array[0.7995038473872]? Just like $array[ int(0.7995038473872) ], i.e. the floating point number is coerced into an integer value by cutting off the decimal places. HTH, Thomas -- To unsubscribe, e-mail: beginn

AW: How do I pick one random element from an array?

2009-11-02 Thread Thomas Bätzler
Majian asked: [...] > print "Array of random: $array[rand @array]\n"; > > > I thoght it might work but it doesnt. I hope someone could give me an > idea to work this out... TIMTOWTDY: a) print "Array of random: $array[rand( @array ) ] \n"; b) print "Array of random: " . $array[rand @array] .

AW: foreach loop

2009-11-02 Thread Thomas Bätzler
Philip Potter asked: > Won't this loop terminate early if there is a blank line or a line > containing only '0'? If I do a readline loop I always do: > while (defined ($line = <$file>)) > > Is there something magical happening here I don't know about? I know > about the magical: > > while (<$fil

AW: foreach loop

2009-11-02 Thread Thomas Bätzler
Anant Gupta asked: > In the foreach loop, without going to the beginning of the loop, i want > to get the next iteration of data. How do i get it. You should probably not "slurp" (read in all at once) the file unless you need to. In your particular case reading i

AW: About the hash case insensitive ~~~

2009-10-27 Thread Thomas Bätzler
Majian asked: > %courses = ( > "2CPR2B"=> "C Language", > "1UNX1B"=> "Intro to Unix", > "3SH414"=> "Shell Programming", > "4PL400"=> "Perl Programming", > ); > > print "\n\"EDP\" NUMBERS AND ELECTIVES:\n"; > while (($n

AW: AW: compact my wordlist generator

2009-10-26 Thread Thomas Bätzler
Michael Alipio wrote: > I knew I needed a recursive function, I just didn't know how to start. That is usually the easy part - you start out by solving the problem for a base case, and then you embellish. With regard to your problem of generating all combinations of a set of elements, the base

AW: compact my wordlist generator

2009-10-26 Thread Thomas Bätzler
Michael Alipio wrote: > Can anyone tell me how the code above works? My original program must > deal with arbitrary length and generate all the possible combinations > (even repeating) of a particular set. What could take me gazillions of > for loops for that, somebody just came up with less than

AW: perl document

2009-10-26 Thread Thomas Bätzler
mahesh bhasme asked: > I am new to perl. From where I get the basic perl document Depends on your distribution, really. If you're on Windows and using the ActiveState Perl distribution, look for the html folder in your Perl installation directory. On Unix, you might want to try perldoc or man

AW: Building a fmt line for printf with a carriage return

2009-10-26 Thread Thomas Bätzler
Hi, Wagner, David --- Senior Programmer Analyst --- CFS wrote: > Here is the sample script I was playing with: > #!/usr/bin/perl > > use strict; > use warnings; > > my $MyLine1 = q[%2d %5s %6s]; > my $MyLine2 = q[%2d %5s \n%6s]; The q// operator is equivalent to single quotes, so esc

AW: Url written in txtfile

2009-10-05 Thread Thomas Bätzler
Hi, Ruprecht Helms asked: > actually I have written the following line: "Currently". "actually" is actually a false friend. > print STATISTIKDATA > CGI->a({href=>'http://www.b-net- > c.de/adressbuch/$Vorname_$Name_$id.html'},'Link > zum Profil'); You are using the wrong quote marks. Use double

AW: Url written in txtfile

2009-10-02 Thread Thomas Bätzler
Ruprecht Helms asked: > how have I to write the printstatement to write a URL like > http://www.example.com within the htmltag ( href="http://www.example.com";>Linktext) into a textfile. Hm, for example #!/usr/bin/perl -w use strict; my $file = '/some/path.txt'; my $text = 'http://www.example

AW: Hash of Hashes

2009-09-29 Thread Thomas Bätzler
Soham Das asked: > How can I create a Hash of Hashes from two lists. Is it possible? > > I want the effective functionality to be served like this > > $ChildHash["Joe"]["21A"]="Sally" > > i.e Joe at 21A has a child called Sally. List1 here will be the name of > Parents, List2 here will contain

AW: Burnt Camel Club

2009-09-22 Thread Thomas Bätzler
Ian wrote: > Keep it up and the hollier-than-though's will have the list to themselves > eventually. What's holly got to do with it, though? ;-) SCNR, Thomas ;-) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.

AW: CGI and persistent data (without Storable)

2009-08-28 Thread Thomas Bätzler
Steve Bertrand asked: > I'm writing a web interface using CGI::Application for a project that > houses numerous methods within a dozen modules. > > One particular process displays a template to the user with passed in > data, and then has four more steps before completing. The result of this > pr

AW: Trying to remove text in inverted commas.

2009-08-24 Thread Thomas Bätzler
Hello Gregory, Gregory Machin asked: > I'm writing a script to import logs into a Mysql .. My Perl is rusty > and I'm battling with a convention on the one column. I need to > remove the text in inverted commas "Prashil" 106 so that just the > number 106 remains.. I have been trying the followi

AW: How to pass info to a CGI program without using a form?

2009-08-24 Thread Thomas Bätzler
Disclaimer: I haven't written Perl or a major book on it so this answer is strictly IMHO, OTTOH and of course YMMV ;-P boll asked: > I would like to use this program in several places to display images > from other directories, so that one URL might display a random image > from the 'vegetables'

AW: WELCOME to beginners@perl.org

2009-08-21 Thread Thomas Bätzler
Ajay Kumar asked: > Gesendet: Freitag, 21. August 2009 12:23 > An: beginners@perl.org > Betreff: RE: WELCOME to beginners@perl.org > > Hi All > > I have great issues > > 1) perl -e '$a=0.123451005;$a=sprintf("%.8f",$a);print"=$a\n";' > Output=0.12345101 > 2) perl -e '$a=5.123451005;$a=sprintf(

AW: fast installing modules

2009-08-18 Thread Thomas Bätzler
Jenn G. asked: > We have a project which has 30+ perl/modperl modules. > Installing those modules by hand on each host is wasting time. > So can we just copy the directory "/usr/lib/perl5/" from the already > installed host to any other not installed hosts? > > We use Linux OS, perl version is 5.

AW: delete 20 000 records in oracle from perl

2009-08-17 Thread Thomas Bätzler
luke devon asked: > Since i have more binary data to be deleted in the requested query , i > have to use a external script/program to satisfy the deletion. So thats > why i wanted to know , how can we implement multi threading for the > situation. You said that CPU load is high when deleting the

AW: How to implement ping script to monitor server up/down state in perl ?

2009-07-21 Thread Thomas Bätzler
Amit Saxena wrote: > Hi Thomas, > > Thanks for the response. > > The client for which I am working will not allow any external utility / > modules to be installed on their development / production environments. > Moreover they want the solution implemented using Perl only. Actually, mon ist pure

AW: How to implement ping script to monitor server up/down state in perl ?

2009-07-21 Thread Thomas Bätzler
Amit Saxena asked: > I want a perl ping script (console based) to monitor server up/down > state. Why re-invent the wheel when there's already stuff like mon (http://mon.wiki.kernel.org/index.php/Main_Page) or nagios (http://www.nagios.org/)? HTH, Thomas -- To unsubscribe, e-mail: beginners-

AW: Having problems getting data back to STDOUT once I assign it to a file

2009-07-21 Thread Thomas Bätzler
Wagner, David --- Senior Programmer Analyst --- CFS asked: > I have looked at perldoc -f open and tried a number of things. The > line "should be last line" is appearing in my audittrail file, but I > never see the EndOfProg or Error in the auditrrail or on the screen. Try "perldoc -f sele

AW: bug in perl?

2009-07-17 Thread Thomas Bätzler
Paul Johnson wrote: > On Fri, Jul 17, 2009 at 12:26:58PM +0200, Thomas Bätzler wrote: > > Octavian Rasnita asked: > > > I have tried the following calculation with ActivePerl 5.10.0 build > > > 1004 under Windows XP Pro: > > > > > > print 0.79 -

AW: bug in perl?

2009-07-17 Thread Thomas Bätzler
Octavian Rasnita asked: > I have tried the following calculation with ActivePerl 5.10.0 build 1004 > under Windows XP Pro: > > print 0.79 - 0.798; > > And it gave the following result: > -0.00801 > > which is obviously wrong. No, it isn't. Welcome to the wonderful world of machine

AW: Time stamp in file name.

2009-07-08 Thread Thomas Bätzler
Meghanand Acharekar asked: > I am writing a perl script which creates a file (on Linux/UNIX) using > system's date. > e.g. log_2009-07-07.gz > > Here is the code I wrote. > > #!/usr/bin/perl -w use strict; > # Prog for demostrating file name concatenations. > $prefix="log"; > $suffix=".gz";

  1   2   3   4   >