RE: Regular Expression Question

2008-09-22 Thread Thomas Bätzler
Raymond Wan <[EMAIL PROTECTED]> wrote: > I looked a bit for some etiquette list for this mailing list > and couldn't find out. Perhaps it's out there somewhere? You could argue that in absence of any other rules, RFC 1855 applies: "If you are sending a reply to a message or a posting be sure yo

Quoting Style meta-discussion & religious war (was RE: Regular Expression Question)

2008-09-22 Thread Thomas Bätzler
Mr. Shawn H. Corey <[EMAIL PROTECTED]> sniped with regard to top-posting: > Funny that blogs work that way. Do they now? The ones that I tend to read all show the comment section after the article body. Cheers, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

RE: Sending SMS

2008-09-22 Thread Thomas Bätzler
Pat Rice <[EMAIL PROTECTED]> asked: > I'm just wondering whats the best way to send an SMS thought perl ? > Has any one experience of doing such a task ? The easiest solution is to use somebody else's HTTP-to-SMS gateway, because then you can use LWP on your end. On the other hand trying to signa

RE: extracting multiple statements ...

2008-09-22 Thread Thomas Bätzler
Hi, Sharan Basappa <[EMAIL PROTECTED]> asked: > I have a code snippet as follows: > > keyword id1 = a x b x c; > keyword id2 = c x d x e; > > I would like to extract strings "a x b x c" and "c x d x e". > I know I can loop through the code and extract the strings, > but is there a RE that can

RE: How to create a timezone converter application in Perl !

2008-09-26 Thread Thomas Bätzler
Amit Saxena <[EMAIL PROTECTED]> asked: > Recently I came across a scenario where I need to convert the > time from one timezone to another. > > Though that time, I used few websites for the same but I want > to know how to do the same in Perl. See http://search.cpan.org/~drolsky/DateTime-0.4304

AW: Query : Exectuting flow in parllel dirs

2009-01-20 Thread Thomas Bätzler
Hi, vivekananda.moh...@wipro.com asked: > Any inputs? Lemme know if the Q is ambiguous? Go read the perlipc manual page ("perldoc perlipc") and come back if you have questions. HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...

AW: Request Tracker 3.8 on Ubuntu 8.04

2009-01-30 Thread Thomas Bätzler
Alf Stockton > I am attempting to install RT3.8 on Ubuntu Hardy 8.04 and am having no > end of trouble with perl as I do not understand the language or its > environment. Read the provided documentation, please. It clearly tells you to run "make fixdeps" to fix missing dependencies. HTH, Thoma

AW: Converting a string to a filehandle

2009-02-09 Thread Thomas Bätzler
Taylor, Andrew (ASPIRE) wrote: > I'm processing a file of test data that looks something like: > > FH1,data1,data2,data3,...etc > FH2,data1,data2,data3,...etc > FH1,data1,data2,data3,...etc > > Each line split into an array and processed. > > The first element (FH1, FH2, etc) is the name of the

AW: Bundle-Expect

2009-02-20 Thread Thomas Bätzler
Hi, ramesh.marimu...@wipro.com asked: > I'm totally new to Perl. I tried installing a module Bundle-Expect.pm. > Also I called inside my Perl script by "Use Bundle::Expect". While A bundle is not a module, it's a whole collection of related modules. In this case I suspect you'll probably want to

AW: Email Purge

2009-02-24 Thread Thomas Bätzler
perl wrote: > Cheers and thanks in advance for you help. I have a routine intended > to purge duplicate emails from a list. The code below is not working. > I remember seeing something like... foreach $email(@emails, @emails2)) > { etc ... but I'm lost. Any help is appreciated. This is discussed

AW: join and parenthesis. Is this a bug?

2009-03-03 Thread Thomas Bätzler
freefox asked: > As join is a build in I guess it should/could be called without > parenthesis. > However these two lines gives me two different answers. > > my @strings = ('foo', 'bar'); > > my $string1 = q{('} . join q{', '}, @strings . q{')}; > my $string2 = q{('} . join(q{', '}, @strings) .

AW: perl

2009-03-17 Thread Thomas Bätzler
Sharan Basappa wrote: > Clearly I did not communicate properly. So what I am looking is for > some support to do some GUI stuff. The idea is take information from > text and show it in the form a waveform. This will help a lot since > it is rather difficult to go through the text file. If you don

AW: Pattern matching question

2009-04-01 Thread Thomas Bätzler
Richard Hobson wrote: > Please be patient with this beginner. I have a subrouting as follows, > that prints out an ASCII representation of chess board > > sub display_board { > foreach (0..7) { > my $ref = @_[$_]; > foreach (0..7) { > my $pi

AW: Turn off $ anchor greedy behavior

2009-04-14 Thread Thomas Bätzler
Michael Alipio asked: > I have a $string that is separated by , and space; > > boy, pig, 123, 123:412adbd, d0g, lajdlf134><<_ lkadsf !234, > > > Now I want to capture the string(s) between last two commas. It consists > of anything upto 32 characters. that is, right after d0g,\s+ up to the > la

AW: AW: Turn off $ anchor greedy behavior

2009-04-14 Thread Thomas Bätzler
Michael Alipio asked: > > my $string = 'boy, pig, 123, 123:412adbd, d0g, > > lajdlf134><<_ lkadsf !234,'; > > > > if( $string =~ m/,\s*([^,]*),[^,]*$/ ){ > > print "$1\n"; > > } > > How could you guys write this so simple? My regexp was twice this long. Lots of practice? ;-) > the regexp af

AW: if statement being ignored

2009-04-14 Thread Thomas Bätzler
Brian wrote: > could someone please help me with this little problem? > I am trying to include an if statement part way through printing. > When the program reaches the line if ($Lang = fr ) { print " > that line gets ignored and the cgi keeps going to the end. > > thanks > Brian > > > > #!

AW: Easiest way to graph results

2009-05-06 Thread Thomas Bätzler
Steve Bertrand asked: > This is more of a request for recommendation than it is a 'howto' type > question. > > A couple of years ago, I wrote a Perl program to extract and format data > from one of my mail servers, and the results are emailed to me each day. > > Now I'm considering going back in

AW: Kindly explain special variable $|

2009-05-27 Thread Thomas Bätzler
sanket vaidya asked: > It would be great if some of you write a simple code which has two > different outputs for $| = 0 & $| = 1 to demonstrate the difference. Try this with different values for $| #!/usr/bin/perl -w use strict; $| = 1; for ( 1..20 ){ print "."; warn "!" unless $i % 5;

AW: CGI scripting

2009-06-08 Thread Thomas Bätzler
Irfan Sayed asked: > I need to configure Apache web server to execute the CGI scripts (in > perl). Servers has windows XP operating system. Did you try Google? The first hit for me on "apache windows cgi" was: http://www.thesitewizard.com/archive/addcgitoapache.shtml And please ask Apache quest

AW: Efficiently going through results

2009-06-09 Thread Thomas Bätzler
Dave Tang asked: > my %result = (); > foreach my $parent (keys %listOfParent){ > my $chocolate = ''; > foreach my $child (keys %{$listOfParent}{$parent}){ >foreach ($listOfParent{$parent}{$child}){ > $chocolate = $_; Why not "foreach my $chocolate ($listOfParent{$paren

AW: TCP/IP client

2009-06-09 Thread Thomas Bätzler
Octavian Rasnita wrote: > I was hoping that I could find a module that allows me to do something > like: > > use The::Module; > > my $client = The::Module->new(PeerAddr => 'localhost:9000'); [...] Use Net::Telnet. From ist description: "You're not familiar with sockets and you want a simple wa

AW: complex split (when delimiter appears in one of the fields)

2009-06-12 Thread Thomas Bätzler
Michael Alipio asked: > I have a string that looks like this: > > my $string = "1, 3, 0. 0. 0. 0, 22, Zak',adfk $&! mac., "; > > > Basically, there are seven fields. after the bird, everything up to the > last comma is the 5th field. 6th field is blank. > > Now my problem is splitting it and ex

AW: need help on perl codebeginn...@perl.org

2009-06-16 Thread Thomas Bätzler
Irfan Sayed asked: > I have perl script like this : [...] > open (VER1, "+>", [...] > while () { [...] > the issue is that , it is executing properly till while loop but it is > not going inside the while and executing while loop. > there is no any error and all the files are present in their l

AW: file handle in perl

2009-06-17 Thread Thomas Bätzler
Irfan Sayed asked: > i am still not able to modify existing lines in the existing file. > here is my code > plz help It doesn't work that way. Once you open the file for writing, it's truncated and you can't read the old contents from it anymore. Why don't you use a temporary new file for the o

AW: AW: file handle in perl

2009-06-17 Thread Thomas Bätzler
Irfan Sayed wrote: > OK. fine > now i am able to write in a temp. file > > after this now i want to overwrite the contents of original file with the > contents of temp. file. > why i want the original file because i want to use this original file > with changes in temp. file in my further build s

AW: perldoc perlboot

2009-06-18 Thread Thomas Bätzler
Dave Tang asked: > I've been going through perldoc perlboot and I have a question about > using the SUPER class. Here's the code in the documentation: > > #!/usr/bin/perl > > use strict; > use warnings; > > { > package Animal; > sub speak { >my $class = shift; >print "a

AW: about "\r\n" or "\n"

2009-06-22 Thread Thomas Bätzler
Tech W. asked: > I created a script for checking HTTP like below: > > use strict; > use IO::Socket; You should use libwww-perl (the LWP::* module family) instead. Not only does it save you from re-inventing the wheel, but it also helps you to avoid all of the pitfalls of lowlevel socket progra

AW: ref() or ! ref()

2009-06-23 Thread Thomas Bätzler
Steve Bertrand wrote: > I've got a relatively decent understanding of how references work in > Perl (syntax-wise, especially when/how to de-ref), but I'd now like to > ask when to use them. > > Obviously memory allocation isn't an issue anymore, so when exactly > should refs be used, and in what

AW: imap module

2009-06-24 Thread Thomas Bätzler
Andreas Moroder asked: > does a IMAP library exist that supports this functionality: > connect to the IMAP server as administrator and create a mail with a > attachment in the drafts folder of a specified user. > > I searched cpan, but from the documentation I dit not find out if the > libraries d

AW: friend class in perl

2009-06-25 Thread Thomas Bätzler
Roman Makurin asked: > I need create a friend class. Is there any special that I > need to know ? For now, I get object and work with it like > with ordinary reference with direct access to internal > fields. Perl OO doesn't have a notion of friend classes since there is no data hiding anyways,

AW: AW: friend class in perl

2009-06-26 Thread Thomas Bätzler
Dr.Ruud wrote: > Thomas Bätzler wrote: > > > Perl OO doesn't have a notion of friend classes since there is no data > hiding anyways > > Don't lie, of course Perl has data hiding. Yeah, and it's got ACME::Bleach, too, and people still write code using le

AW: Using common object, without passing it around

2009-06-29 Thread Thomas Bätzler
Steve Bertrand asked: > Can anyone suggest a perldoc or recommended practise that will help me > in regards to: > > I have numerous classes, all suited to a different object-type or > function. > > When I instantiate an object (all classes are under the same Module:: > umbrella), I *think* what

AW: exit status

2009-06-30 Thread Thomas Bätzler
Irfan Sayed asked: > call but in this case how shud i inform to windows batch script that the > perl script execution / exit status is non zero and stop execution > further Use exit() with a non-zero argument. Look at "HELP IF" for your windows batch programming question. HTH, Thomas -- To uns

AW: File::Find with chmod trouble debugging

2009-07-06 Thread Thomas Bätzler
Harry Putnam asked: > The script below is my first usage of perls `chmod', but it appears to > be in keeping with the info at perldoc -f chmod. > > But somehow in the print of $mode it turns into 493... even though it > is set to 755. Its just the print though... the actual chmod appears > to be

AW: Edit text file using perl script

2009-07-06 Thread Thomas Bätzler
Alpesh Naik asked: > I am trying to edit the text file using perl script. > i want to replace a particular text of file with new text. > > but the problem is that the new text appeared at end of file; > > How can i solve this problem, > pls. help We can help you much better if we can a

AW: Perl DBI error

2009-07-07 Thread Thomas Bätzler
Dave Tang asked: > I am having a problem with binding a variable when executing on a DBI > object. [...] "You can only reliably bind values, not field or table names. Database that plan query execution won't accept this, because they need table and field names to make their query execution p

AW: Edit text file using perl script

2009-07-07 Thread Thomas Bätzler
Alpesh Naik wrote: > Hi Thomas, > and thanks for the reply, > > Given below is my code, > > #!/usr/bin/perl #!/usr/bin/perl -w => You should always enable warnings. > use strict; > > print "Content-type:text/html\n\n"; > use CGI; > my $query = new CGI; => If you're using CGI, then you should

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";

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: :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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

<    1   2   3   4   >