Re: Edit large data file

2010-06-28 Thread Robert Citek
2010/6/26 Jenda Krynicky : > From: mrwawa >> That is correct.  I decided to just write the output to a separate >> file and then delete the original file.  Thanks for all your help. >> >> Wade > > That's all you can do. If you just wanted to change a few characters > you could open the file for re

Re: Edit large data file

2010-06-16 Thread Robert Citek
On Tue, Jun 15, 2010 at 1:50 PM, mrwawa wrote: > Is this possible, and if so how can I do it? Can you give an example? For example, using colons instead of tabs, if the input looks like this: A:BC:D then you want it to look like this: A:B:C:D Is that right? Regards, - Robert -- To unsubsc

Re: Any Good SCM tool to manage Perl Code locally

2010-03-16 Thread Robert Citek
On Sun, Mar 14, 2010 at 4:43 PM, David Christensen wrote: > Parag Kalra wrote: >> >> So wanted to know if it is a possible to use any free opensource tool to >> manage code (only locally) where actual and current code resides in >> different local directory and I can checkout code locally in some

Re: how do I replace all the spaces in a string with +

2010-02-20 Thread Robert Citek
On Fri, Feb 19, 2010 at 3:23 PM, John W. Krahn wrote: > Sergey Matveev wrote: >> >> Greetings, >> >> On Fri, Feb 19, 2010 at 03:54:27PM -0500, Erik Lewis wrote: >> >>> I have to changes all the spaces in a string to +'s.  Is there an >>> easy way to do this.  The length of the string and the numbe

Re: Change tag case

2009-11-07 Thread Robert Citek
On Sat, Nov 7, 2009 at 4:45 AM, Ramesh, Marimuthu wrote: > I have some 3000 sgml files, where I need to change the tag case from > upper case to lower case. > > Example: Change This is an image to id="IMG1">This is an image. > > Note that the tag name and the attribute name should only change and

Re: printf with currency symbols

2009-10-26 Thread Robert Citek
I see. You want the output to look something like this: $ perl -e 'for(my $total = 24.15; $total <3; $total *= 10) { printf("Total:%10s\n", "\$" . sprintf("%.2f",$total)) ;} ' Total:$24.15 Total: $241.50 Total: $2415.00 Total: $24150.00 Not sure if there is a better way. My guess is

Re: printf with currency symbols

2009-10-26 Thread Robert Citek
Is this what you are looking for: $ perl -e '$total = 24.15 ; printf "Total: \$%.2f\n", $total; ' Regards, - Robert On Mon, Oct 26, 2009 at 11:57 AM, Bryan R Harris wrote: > Is there a good way to do printf's with currency symbols? > > I've tried this: > >  printf "Total: \$%10.2f\n", $total; >

Re: Filesize limit for Perl on UNIX

2009-10-20 Thread Robert Citek
On Mon, Oct 19, 2009 at 9:12 AM, Shawn H Corey wrote: > Taylor, Andrew (ASPIRE) wrote: >> Is there a 2GB filesize limit for perl? - we're running on verion 5.6. > > There is no file limit in Perl.  There is no memory limit in Perl.  Such > limits are because of: > > * the hardware, > * the OS, > *

Re: transliterate the negative character class in perl

2009-09-25 Thread Robert Citek
On Fri, Sep 25, 2009 at 5:46 AM, Shawn H Corey wrote: > Robert Citek wrote: >> >> How does one transliterate in perl using a negated character class? > > echo "abcxyz" | perl -ple '$_ =~ tr/abz/N/c' > > See `perldoc perlop` and search for /tr\/SEARC

transliterate the negative character class in perl

2009-09-25 Thread Robert Citek
How does one transliterate in perl using a negated character class? For example, I have a string abcxyz and I would like to turn it into abNNNz. I've been able to do the following: $ echo "abcxyz" | perl -plane '$_ =~ y/[abz]/N/ ' NNcxyN so I figured negating would give me the negated set, but

swapping values in an array

2009-07-18 Thread Robert Citek
Is there an easier way to swap two values in an array? This works: $ perl -le '@a=(1,2,3,4) ; ($a[0],$a[1])=($a[1],$a[0]) ; print join("\t", @a) ; ' 2 1 3 4 This doesn't: $ perl -le '@a=(1,2,3,4) ; $a[0,1]=$a[1,0] ; print join("\t", @a) ; ' 1 1 3 4 Regar

Re: swapping values in an array

2009-07-18 Thread Robert Citek
Nevermind, I knew I was overlooking something simple: use @ symbol. $ perl -le '@a=(1,2,3,4) ; @a[0,1...@a[1,0] ; print join("\t", @a) ; ' 2 1 3 4 Regards, - Robert On Fri, Jul 17, 2009 at 2:03 PM, Robert Citek wrote: > Is there an easier way to swap

Re: Help needed with '-e' operator

2009-07-09 Thread Robert Citek
On Wed, Jul 8, 2009 at 6:57 PM, John Refior wrote: > On Wed, Jul 8, 2009 at 7:34 AM, Anu P wrote: > >> I am trying to use the '-e' filetest operator and encountered some wired >> behavior. >> I have a tar.gz file which is around 2.6 G and this is the code...Tar.gz >> file is in the same directory

Re: Help needed with '-e' operator

2009-07-08 Thread Robert Citek
The code you wrote should work as it worked for me when I tested it on a 3 GB sized file: $ ls -sh 3gb-file 3.0G 3gb-file $ perl -le '$file="3gb-file" ; unless (-e $file) { print ("nope") ; } else { print ("yup") ; } ' yup I tested it with files as large as 10 GB and it worked. Could it be that

An image of a swiss-army chainsaw

2009-04-21 Thread Robert Citek
Hello all, I am giving a presentation soon and will be talking a bit about perl. I'd like to include an image about perl that describes it as the Swiss army chainsaw. Ideally, I'd like to have a red chainsaw with the white Swiss cross. Unfortunately, my Googling for images hasn't turn anything u

Re: if statement being ignored

2009-04-15 Thread Robert Citek
On Wed, Apr 15, 2009 at 6:33 AM, John W. Krahn wrote: > Robert Citek wrote: >> >> You probably want ($Lang == "fr") > > Probably not. You are using a numerical comparison on a string which will > convert the string to a number so that is the same as saying: ($La

Re: if statement being ignored

2009-04-15 Thread Robert Citek
You probably want ($Lang == "fr") Regards, - Robert On Wed, Apr 15, 2009 at 12:08 AM, 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

Re: condition in a single line

2008-08-22 Thread Robert Citek
An alternate version: my $value = ( $t1lsq{$interfaceName} >= 4) ? 4 : $t1lsq{$interfaceName}; and a test: $ perl -le ' $t1lsq{$interfaceName}=2 ; my $value = ( $t1lsq{$interfaceName} >= 4) ? 4 : $t1lsq{$interfaceName}; print $value ' 2 $ perl -le ' $t1lsq{$interfaceName}=5 ; my $value = ( $t1l

Fwd: avoid using a temporary variable

2008-01-08 Thread Robert Citek
-- Forwarded message -- From: Robert Citek <[EMAIL PROTECTED]> Date: Jan 8, 2008 3:39 PM Subject: Re: avoid using a temporary variable To: "John W. Krahn" <[EMAIL PROTECTED]> On Jan 8, 2008 3:09 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > Joh

Re: avoid using a temporary variable

2008-01-08 Thread Robert Citek
On Jan 8, 2008 2:33 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > Robert Citek wrote: > > $ ls | perl -e 'print "('\''" . join("'\'','\''", map { chomp; $_ } > > (<>) ) . "'\'')

Re: avoid using a temporary variable

2008-01-08 Thread Robert Citek
On Jan 8, 2008 11:14 AM, Tom Phoenix <[EMAIL PROTECTED]> wrote: > On Jan 8, 2008 7:38 AM, Robert Citek <[EMAIL PROTECTED]> wrote: > > What I really want to know is if there's a way to eliminate the > > temporary variable. > > Are temporary variables quite

Re: avoid using a temporary variable

2008-01-08 Thread Robert Citek
On Jan 8, 2008 9:40 AM, Robert Citek <[EMAIL PROTECTED]> wrote: > On Jan 8, 2008 9:24 AM, Robert Citek <[EMAIL PROTECTED]> wrote: > > What I really want to know is if there's a way to eliminate the > > temporary variable. If not, that's fine. I was just w

Re: avoid using a temporary variable

2008-01-08 Thread Robert Citek
On Jan 8, 2008 9:24 AM, Robert Citek <[EMAIL PROTECTED]> wrote: > On Jan 8, 2008 8:59 AM, Chas. Owens <[EMAIL PROTECTED]> wrote: > > On Jan 7, 2008 6:59 PM, Robert Citek <[EMAIL PROTECTED]> wrote: > > > How can I get rid of the @foo? > > > > &g

Fwd: avoid using a temporary variable

2008-01-08 Thread Robert Citek
-- Forwarded message -- From: Robert Citek <[EMAIL PROTECTED]> Date: Jan 8, 2008 9:24 AM Subject: Re: avoid using a temporary variable To: "Chas. Owens" <[EMAIL PROTECTED]> On Jan 8, 2008 8:59 AM, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Ja

avoid using a temporary variable

2008-01-08 Thread Robert Citek
How can I get rid of the @foo? This does what I want, but uses the "temporary" variable @foo: $ ls | perl -e '@foo=<>; chomp @foo ; print join(" ", @foo)' This eliminates the temporary variable but doesn't work: $ ls | perl -e 'print join(" ", chomp(<>))' Thanks in advance. Regards, - Robert

Re: -F vs split

2006-08-25 Thread Robert Citek
On Aug 25, 2006, at 3:30 PM, John W. Krahn wrote: This is a "feature" :-) This thread may help explain: http://groups.google.com/group/perl.perl5.porters/browse_frm/thread/ 2eca0c52a1b299c4/f655bddfdbf2d0d6? lnk=st&q=&rnum=1&hl=en#f655bddfdbf2d0d6 One way to do what you want: $ echo 'a:

Re: -F vs split

2006-08-25 Thread Robert Citek
On Aug 25, 2006, at 2:43 PM, Robert Citek wrote: Why do these two commands not produce the same output? $ perl -le 'print join("--", split(/: /, "a: b"))' a--b $ echo 'a: b' | perl -F'/: /' -lane 'print join("--", @F)'

-F vs split

2006-08-25 Thread Robert Citek
Why do these two commands not produce the same output? $ perl -le 'print join("--", split(/: /, "a: b"))' a--b $ echo 'a: b' | perl -F'/: /' -lane 'print join("--", @F)' a: b From reading 'perldoc perlrun' the -F option should behave just like the pattern to split. What am I missing? Rega

Re: How to split a file on the CR carriage Return and/or replace the \r with \n ??

2006-07-26 Thread Robert Citek
On Jul 26, 2006, at 2:59 PM, Steve Pittman wrote: I am using activestate on a windows box ...the files I am parsing are Unix files...I tried this so far... open ( IN, "<$_[0]" )||die "Can't open DAT source file: $tempFile $!\n"; while (){s/\r/\n/g;@lines = ;}# close (IN);

Re: DBD::Oracle installation script assumes oracle is installed local ly?

2005-09-04 Thread Robert Citek
On Aug 31, 2005, at 9:55 AM, Scott Taylor wrote: [EMAIL PROTECTED] said: Hi all. I am attempting to install DBD::Oracle from the perl CPAN shell. The installation script seems to assume that oracle is installed locally. It asks me to set ORACLE_HOME to the path the oracle is installed and

Re: parsing columns

2005-08-17 Thread Robert Citek
On Aug 13, 2005, at 8:22 AM, Offer Kaye wrote: I have a text file with columns, where the columns may not be aligned, and not all lines may have data in all columns: header1 header2 header3header4 l1dat1l1dat2

Re: convert array pair to hash

2005-07-20 Thread Robert Citek
On Jul 20, 2005, at 6:01 AM, Jeff 'japhy' Pinyan wrote: Will need to digest the above a bit more. For more, please read perldoc perldata to learn about slices, and perldoc perlreftut to be introduced to references. Further reading is: perldoc perlref perldoc perllol perldoc pe

Re: convert array pair to hash

2005-07-19 Thread Robert Citek
On Jul 19, 2005, at 5:19 PM, Wiggins d'Anconia wrote: Close. You want a hash slice. @[EMAIL PROTECTED] = @vals; A marvelously Perlish construct. http://danconia.org Swet! Thanks a bunch. Do you have a good reference which explains this? I've looked in both the Camel and Llama books

convert array pair to hash

2005-07-19 Thread Robert Citek
Is there an easier, more compact way to convert two arrays, on with keys and the other with values, into a hash? I have this sample code: 1 #!/usr/local/bin/perl -w 2 3 my $hash ; 4 my @keys =qw(col1 col2 col3); 5 @vals=qw(a b c); 6 for ($i=0; $i<=2 ; $i++)

Re: :FTP works someplaces

2005-06-18 Thread Robert Citek
On Jun 17, 2005, at 2:11 AM, Thomas Bätzler wrote: Robert Citek <[EMAIL PROTECTED]> Anyone have any ideas why code using Net::FTP on one machine won't work on another? However, the most common cause of problems with Net::FTP is not a Perl but a networking problem - namely firewa

Net::FTP works someplaces

2005-06-16 Thread Robert Citek
Anyone have any ideas why code using Net::FTP on one machine won't work on another? I have this piece of code that runs on a Red Hat 9 linux machine and on one Mac OS/X 10.4.1. But this same code does not run on a second OS/X 10.4.1 machine. By not run I mean it waits a long time on the

while loop -> map

2005-05-24 Thread Robert Citek
I found a variation of this in the Perl Nutshell book: $ perl -le ' $foo="fee fie foe foo" ; while ($foo =~ m/e/g ) { push @bar, pos $foo ; } print join(":", @bar); ' 2:3:7:11 Is there an equivalent way to do the same using map instead of an explicit while loop? I'm guessing not, sinc

Re: remove me from the list

2005-01-28 Thread Robert Citek
On Friday, Jan 28, 2005, at 11:52 US/Central, Richard Wood wrote: How do I go about removing my email address from this list? If you send a blank message to e-mail [EMAIL PROTECTED], you'll get a help file. Within that helpfile will be a line like so: "To stop subscription for this address, mail

Re: Need help with regex

2004-11-04 Thread Robert Citek
On Thursday, Nov 4, 2004, at 10:49 US/Central, Scott Pham wrote: Why don't you just split the line and use the whitespace as separator? $line =~ s/\s+/ /; my ($record,$date,$cust,$temp1,$temp2,$temp3,$temp4,$temp5,$shipping,$paid ) = split (/ /,$line); As I was reminded the other day, split work

Re: Need help with regex

2004-11-04 Thread Robert Citek
On Thursday, Nov 4, 2004, at 09:38 US/Central, Kevin Old wrote: my $line = "31232000 07/28/04 DUC000 NET 60 DAYS RD64 UPSGNDSVR PREPAID"; What I'm looking for in lines like this are the customer number (DUC000) and a "code" that starts with UPS, or if the code doesn't start with U

Re: pattern matching

2004-11-01 Thread Robert Citek
On Sunday, Oct 31, 2004, at 21:11 US/Central, John W. Krahn wrote: Robert Citek wrote: On Saturday, Oct 30, 2004, at 20:52 US/Central, John W. Krahn wrote: [EMAIL PROTECTED] wrote: I have to match patterns of the format string1>string2 where the strings 1 & 2 can contain alphabets,numb

Re: pattern matching

2004-10-31 Thread Robert Citek
On Saturday, Oct 30, 2004, at 20:52 US/Central, John W. Krahn wrote: [EMAIL PROTECTED] wrote: I have to match patterns of the format string1>string2 where the strings 1 & 2 can contain alphabets,numbers and spaces. The string are separated by '>' sign. I wrote the following code for this. if(/([a-z

Re: substr

2004-10-31 Thread Robert Citek
On Saturday, Oct 30, 2004, at 21:46 US/Central, [EMAIL PROTECTED] wrote: My earlier post was not quite clear. I will explain my problem in detail here. I have a string whose length is say 5. I need to copy another string into this string but from an offset of 10. I tried using substr but this is a

Re: starting position of RE match

2004-09-23 Thread Robert Citek
On Wednesday, Sep 22, 2004, at 08:05 US/Central, Jenda Krynicky wrote: Which means it's actually much easier than I had you believe: $s = "sasas dfgfgh asasas asedsase"; while ($s =~ /(?=sas)/g) { print "pos=",pos($s), " = '",substr($s,pos($s),3),"'\n"; } Bas

Re: starting position of RE match

2004-09-21 Thread Robert Citek
On Tuesday, Sep 21, 2004, at 17:17 US/Central, Jenda Krynicky wrote: How about this: $s = "sasas dfgfgh asasas asedsase"; while ($s =~ /\G.*?(?=sas)./g) { print "pos=",pos($s)-1, " = '",substr($s,pos($s)-1,3),"'\n"; } Thanks. Seems to work, although I'm stil

starting position of RE match

2004-09-21 Thread Robert Citek
Is there an equivalent for "index" that uses regular expressions instead of exact string? I've been looking at index, pos, m//, and the corresponding "$" variables but nothing I've found so far does what I'm looking for. Specifically, what I'm trying to do is find all the starting locations o

Re: Request Tracker and HTML::FormatText

2004-06-01 Thread Robert Citek
On Saturday, May 29, 2004, at 11:04 US/Central, Roberto Etcheverry wrote: I tried at first with cpan and got the same result as you, don't know why. But if you go to CPAN search (seach.cpan.org) and look for HTML::FormatText in 'modules' you can find it. Try http://search.cpan.org/search?query=HT

Re: Request Tracker and HTML::FormatText

2004-05-29 Thread Robert Citek
On Saturday, May 29, 2004, at 09:03 US/Central, Roberto Etcheverry wrote: The usual way to install modules is to run 'cpan': Here's a transcript of my cpan search: # perl -MCPAN -e 'shell;' Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.7601) Rea

Re: Request Tracker and HTML::FormatText

2004-05-28 Thread Robert Citek
On Friday, May 28, 2004, at 16:29 US/Central, Roberto Etcheverry wrote: http://search.cpan.org/src/GAAS/HTML-Format-1.23/lib/HTML/FormatText.pm Thanks. I looked for that tar file and couldn't find one. So, I used a wget to download the module: wget -m -nH -np http://search.cpan.org/src/GAAS/

Request Tracker and HTML::FormatText

2004-05-28 Thread Robert Citek
Hello all, We are in the process of installing Request Tracker ( http://www.bestpractical.com/rt/ -- rt.3.0.11 ) on a Fedora box and are running into an issue with installing the CPAN module HTML::FormatText. RT requires it, yet CPAN no longer has it. A google search find some in cache, but th

Re: making Digest::MD5

2004-04-19 Thread Robert Citek
On Monday, April 19, 2004, at 01:40 PM, Robert Citek wrote: I'm trying to compile the Digest::MD5 module. I tried to do it directly via "perl -MCPAN -e 'install Digest::MD5' and got an error: "Makefile:85: *** missing separator. Stop." So, I decided to do it b

making Digest::MD5

2004-04-19 Thread Robert Citek
Hello all, I'm trying to compile the Digest::MD5 module. I tried to do it directly via "perl -MCPAN -e 'install Digest::MD5' and got an error: "Makefile:85: *** missing separator. Stop." So, I decided to do it by hand. Below is a transcript of what I tried. Has anyone else experienced a s

solved - OS X, cpan, libnet

2004-01-09 Thread Robert Citek
On Thursday, January 8, 2004, at 08:22 AM, Daniel Staal wrote: 1. Upgrade to Panther. ;-) It includes Perl 5.8, and plenty more. In the queue to do. Also, want to dual boot with Linux, but that's for an other discussion forum. :) 2. Upgrade Perl following the directions at: http://developer.ap

OS X, cpan, libnet

2004-01-08 Thread Robert Citek
Hello all, I have perl 5.6.0 on my Mac OS X. I'd like to install libnet. However, when I try to use cpan, it wants to automagically upgrade my perl to 5.8.2. All I really want is Net::FTP. What is my best course of action: - upgrade to perl 5.8.2 and then libnet-1.17 - upgrade to some othe

Re: script to test a file.

2003-10-29 Thread Robert Citek
At 11:43 AM 10/29/2003 -0600, Andrew Gaffney wrote: Rick Bragg wrote: Hi, I want to write a script that will test the contents of a file. The file being tested will pass only if it contains nothing more than an ip address on one line. Does anyone have a sample of a simple regex to accomplish thi

Re: CPAN, perl, dependencies, apt-get?

2003-10-20 Thread Robert Citek
At 04:56 PM 10/20/2003 -0500, Robert Citek wrote: ... How do I correct this? Should I just create the file (e.g using touch)? Doing a touch seemed to work. Any caveates to doing this? Regards, - Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: CPAN, perl, dependencies, apt-get?

2003-10-20 Thread Robert Citek
At 04:40 PM 10/20/2003 -0500, Robert Citek wrote: ... However, when I exited the CPAN shell, these two tests worked just fine: # perl -MXML::Simple -e ';' # perl -MXML::SAX -e ';' I guess it worked afterall. Now on to testing real code. I spoke too soon. I am trying the

Re: CPAN, perl, dependencies, apt-get?

2003-10-20 Thread Robert Citek
At 01:12 PM 10/20/2003 -0700, LoneWolf wrote: root>perl -MCPAN -e shell when it comes up to the shell put this in: o conf prerequisites_policy follow At 01:45 PM 10/20/2003 -0600, Wiggins d Anconia wrote: Are you getting an error from CPAN?? Eventually, yes but I guess the error messages did not ma

CPAN, perl, dependencies, apt-get?

2003-10-20 Thread Robert Citek
Hello all, What is the easiest way to install a module from CPAN that has several dependencies? Specifically, I want to install XML::Simple. However, that module depends on a few other perl modules. For now, I'm downloading the modules individually and installing them. But this seems to be

Re: REPOST - print ;

2003-09-05 Thread Robert Citek
Hello Edward, At 05:07 PM 9/5/2003 +0800, Edward Yang wrote: >The problem is I do not get correct result from the following code: >print ; >or >print ; I don't use perl in Windows, but I can simulate a similar result on Linux or Mac OS X: mkdir "foo bar" cd "foo bar" touch a b c cd ..

list of child pids

2003-08-21 Thread Robert Citek
Hello all, getppid returns the parent process ID given a processes ID. Is there a corresponding function which returns a list of child processes IDs? I could do an external system call to ps or pstree, but thought perhaps something internal to perl might already exist. I've Googled, but haven'

closure (was Re: memoizing a variable)

2003-08-18 Thread Robert Citek
At 04:18 PM 8/18/2003 -0700, John W. Krahn wrote: > ... it looks like you want a closure instead. > >{ # limit scope of $bar >my $bar = 100; >sub foo { ++$bar } >} Thanks for the example. I quess I do want closure. I'm not clear on how closure differs from memoizing. Regardless, this worked e

memoizing a variable

2003-08-18 Thread Robert Citek
Hello all, I want a variable to be memoized, that is, keep the variable available only to the function and the value remembered across invocations. So far, I have created two versions listed below, both of which "work." The first version prints a warning message 'Variable "$bar" will not stay s

formatting a number

2003-07-03 Thread Robert Citek
Hello all, I want to format a number so that it has commas as a separator. Here's the code I came up with: my $num=12345678; print scalar reverse( join(",", grep( /./ ,split (/(...)/,reverse($num), "\n"; This works but was wondering if anyone might suggest a better method. Regards, - Robe

compiling DBD::Oracle

2003-06-16 Thread Robert Citek
Hello all, What would I need in order to write a perl script to query an Oracle database? I have written perl scripts to connect to MySQL and PostgreSQL databases. In those cases, both the databases and the scripts were run on Red Hat Linux v7.1/2. This time, I am trying to write a perl script

system info: cpu, ram, disk

2003-02-24 Thread Robert Citek
Hello all, How can I find out information about a system in a system-independent manner? I wrote a perl script that nicely displays information about a Linux system: # of cpus, cpu speed, size of RAM, # of disks, size of disks, IP address. The code uses the system() command and relies on the /p

Re: slicing array with range operator

2003-02-20 Thread Robert Citek
At 06:53 AM 2/20/2003 -0800, Paul wrote: >the range op is short-circuiting on the negative. >try > > @f[1..$#f-1] Worked like a charm. Thaks, Paul. - Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

slicing array with range operator

2003-02-20 Thread Robert Citek
Is there a short-cut way in perl to slice an array with the range (..) operator? I am trying to get a slice of an array from the second element to the second to last element. This would be equivalent to a shift and a pop, except that I do not want to modify the array itself. This is the closest

Re: A very annoying regex question.

2003-01-29 Thread Robert Citek
Hello Zeus, At 11:55 AM 1/29/2003 -0500, Zeus Odin wrote: >An even shorter version of yours is: >- >my @a; >while(){ > next unless /=/ && chomp; > push @a, split /=/, $_, 2; >} >print "$_\n" for @a; >- This is even shorter, eliminates all uses

Re: A very annoying regex question.

2003-01-29 Thread Robert Citek
Hello Zeus, At 09:49 AM 1/29/2003 -0500, Zeus Odin wrote: >I have spent a very LONG time trying to determine why this script is not >splitting properly only on lines that have equals marks and only on the >first equals. I'm not quite sure what you are trying to do. So below is a modified versio

RE: linux pearl??

2002-11-06 Thread Robert Citek
At 01:43 PM 11/6/2002 -0500, Charlotte Oliver wrote: >You could also try "locate perl" or "whereis perl" on the command line. >Usually it's someplace like \usr\bin\perl, though. > >I don't run Redhat though, so your mileage may vary. 'locate' and 'whereis' work only if perl is already installed.

Re: linux pearl??

2002-11-06 Thread Robert Citek
Hello Stacy, At 07:56 PM 11/5/2002 -0800, stacy wilmshurst wrote: >hey can someone give me a tip to where i can find the pearl >packages on redhat8? >i'm getting real confused trying to set them up >but i know they're there... > >help please Since this is a perl list, I am assuming you meant "pe

Re: Split a file

2002-11-06 Thread Robert Citek
y to your needs. Regards, - Robert - #!/usr/bin/perl -w # (c) 2002 - Robert Citek # released under the GPL (http://www.gnu.org/licenses/gpl.txt) use strict; use English; # I prefer $NR over $. my $num=4; my @fh; # create an array of filehandles for (my $i=0; $i<$num ; $i++) {

Re: Help on -w

2002-11-05 Thread Robert Citek
Hello LRMK, At 11:51 PM 11/5/2002 +0600, LRMK wrote: >#!/usr/bin/perl -w >my $a; >if ($a eq 'fff'){ >} >above line gives the error Use of uninitialized value in string eq >at t.pl line 6. > >but when -w not used in top line it works perfect >what the -w really does You've created $a but not se

Re: The basics of SWITCH

2002-11-04 Thread Robert Citek
Hello Gajo, A different approach to your problem is to use a data structure, e.g. an array or hash. Your script rewritten using an array, #!/usr/bin/perl -w my @option = ("one","two","three","four","five","six","maybe seven?"); print "Type in a number 1-", $#option+1, ": "; $s = ; chomp $s ; i

Re: skip the first line

2002-11-01 Thread Robert Citek
Hello Charles, At 12:22 PM 10/31/2002 -0500, [EMAIL PROTECTED] wrote: > >I have a file that looks like >0 >232,32387,2323 > >I am only interested in the last set of digits on the second line. My plan >was to split on coma and take the 3 element of the array. I am having >problems skipping the fi

Re: locale question (was Re: Stupid doubt!)

2002-10-31 Thread Robert Citek
At 12:04 AM 10/26/2002 +0200, Jenda Krynicky wrote: >From: Robert Citek <[EMAIL PROTECTED]> >> This sounds like something that perl should be able to handle by >> changing the locale so that you do not have to alter the source file. > >I hope NOT! This would break tons

Re: ms access & perl

2002-10-30 Thread Robert Citek
At 10:47 PM 10/30/2002 +0100, Jenda Krynicky wrote: >From: "Jerry Preston" <[EMAIL PROTECTED]> >> Is it possible to access MS access from Perl? If so, how? > >Sure. Use DBI and DBD::ODBC or Win32::ODBC or Win32::ADO or DBI with >DBD::ADO :-) Extending the question a bit, can I access an MS Acce

locale question (was Re: Stupid doubt!)

2002-10-25 Thread Robert Citek
Hello Cleiton, At 02:36 PM 10/25/2002 -0700, Cleiton L. Siqueira wrote: >Thanks for your help!!! No problem. >I was making a mistake with my source file. My file has numbers like >this 2,25. Perl uses "." and not "," to decimal numbers. >I changed the "." to "," in the file and now it's workin

Re: Time CHange Regulatr expression for 2am Crons ?

2002-10-25 Thread Robert Citek
Hello Scot, At 07:44 PM 10/25/2002 -0700, Scot wrote: > Anybody figured out a good regular expression to match all >2am crons ? match 0,10,20,30,40,50 2 * * * and 0 2 * * * You can use automatic splitting: echo '0,10,20,30,40,50 2 * * *' | perl -wane 'print if $F[1] == 2 ;' or use awk:

Re: Stupid doubt!

2002-10-25 Thread Robert Citek
Hello Cleiton, At 01:32 PM 10/25/2002 -0700, Cleiton L. Siqueira wrote: >I've tried to add two variables, but the result isn't right. >Because when Perl add the both it removes the decimal numbers from the each variable. >How can I add these variables in perl? Does this one-liner work on your sy

Re: Large numbers

2002-10-24 Thread Robert Citek
Hello Kristi, At 10:22 AM 10/24/2002 -0500, Goodman Kristi - kgoodm wrote: >Does anyone know why Perl has a hard time with large numbers and sometimes >turns them into negative numbers? Sorry if I am not being specific enough, >but really all I am doing is calculating the number of records in a

mixing long and short options

2002-10-09 Thread Robert Citek
Can someone show me an example of how I can mix long and short options with Getopt? I would like to pass options to a perl script that can take both short and long options. For example, all of these commands work (this is GNU tar): # tar -tzvf foo.tar.gz # tar --list zvf foo.tar.gz # tar

compression/seek/tell

2002-09-22 Thread Robert Citek
Hello all, Questions: How can I tell if a file is compressed (gzip or compress)? Can I use seek/tell on a pipe or fifo? If not, are there work-arounds? Background: I currently have a script that opens a file, seeks to a position, reads some data, and quits. I would like to expand the functiona

Re: Is there a way to do cron on windows?

2002-08-20 Thread Robert Citek
Hello Daryl, At 09:05 AM 8/20/2002 -0500, Daryl J. Hoyt wrote: > I am looking for a way to run something like a cron job on windows. I >would like to check every 10 minutes to see if an application is running. >If it is not running, I would then like to launch it. Is there a way to do >t

Re: Cygwining off Re: perlcc - newbie - cannot compile successfully - sample sessio n

2002-04-20 Thread Robert Citek
Hello Chris, At 10:23 PM 4/20/2002 +0100, Chris Ball wrote: >>>>>> "Robert" == Robert Citek <[EMAIL PROTECTED]> writes: > >Robert> Some CPAN modules/tarfiles have filenames that have two >Robert> colons in them, e.g. foo::bar. Wh

Re: Cygwining off Re: perlcc - newbie - cannot compile successfully - sample sessio n

2002-04-20 Thread Robert Citek
Some CPAN modules/tarfiles have filenames that have two colons in them, e.g. foo::bar. While this works fine under Unix/Linux, Windows complains. I believe MacOS 9 would balk about this, too. Not sure about darwin/MacOS X. Regards, - Robert At 01:43 PM 4/15/2002 -0700, A. Rivera wrote: >Fork

RE: Converting *nix file to dos

2001-09-26 Thread Robert Citek
Hello James, Here's a perl way that seems to work: perl -ne 's#\012#\015\012#g; print' filename Regards, - Robert -- At 03:02 PM 9/26/2001 -0500, Gibbs Tanton - tgibbs wrote: >Many unix systems have both a dos2unix and unix2dos command...you might try >that. > >-Original Message---

Re: how to open a .iso file

2001-09-19 Thread Robert Citek
Hello Ricardo, At 12:57 PM 9/19/2001 -0300, Ricardo Derbes wrote: >I dont think it can be opened, Not quite correct. Let's say the file is called cpan.iso. Here's how you can print the first "word characters" within the first 33000 bytes of the file: #!/usr/bin/perl -w use strict; my ($stri

Re: perl's system() function question.

2001-09-13 Thread Robert Citek
Hello Michael, I tried to duplicate your error, but was unable to. This is my test script which is modelled on your origninal script: #!/usr/bin/perl -w use strict; foreach my $foo qw(a b) { print "$foo\n"; system ("echo hi $foo"); print "hello $foo\n"; print "\n"; } Regardless of

Re:File & Array

2001-09-13 Thread Robert Citek
Hello Curtis, At 09:12 AM 9/13/2001 -0700, Curtis Poe wrote: >I would try to avoid using DATA as the filehandle as this >may cause confusion with the __DATA__ token. Excellent stylistic point. >Also, if you're going to read the entire file into an array, this >is faster and (IMHO) easier t

Re:File & Array

2001-09-13 Thread Robert Citek
At 05:27 PM 9/13/2001 +0200, Jorge Goncalvez wrote: >Hi, How in Perl you can store each line of a file in an array? >From section 4.1 in the Perl Cookbook (http://www.oreilly.com/catalog/cookbook/): @bigarray = (); open(DATA, "< mydatafile") or die "Couldn't read from datafile: $!\n"; whil

Re: Gathering output from a program

2001-09-13 Thread Robert Citek
Hello Sofia, What is happening is that only STDOUT is being saved in the @output array. STDERR is still going to the console (your screen). If on a UNIX/Linux system, try adding "2>&1" in front of your command like this: @output = `2>&1 infoerr_parse.pl`; The "2>&1" redirects any output to f

Re: "system" command failure

2001-09-12 Thread Robert Citek
Hello Tyler, A return value of 0 from a system call means that it ran successfully. Any other value means something went wrong. For example, this script: #!/usr/bin/perl -w use strict; my $system; $system = system("echo Hello, World"); print $system . "\n"; $system = system("grok

Re: Getting Month Day from `date`

2001-09-11 Thread Robert Citek
Hello Richard, At 09:14 AM 9/11/2001 -0400, Richard Brust wrote: >I am trying to print lines from an HTML page that have a certain >date(today). The following works: > >lynx -dump http://www.tbri.com/News/pgPubCal.asp | grep "Sep 11" This did not work for me. Changing "Sep 11" to "Sep" worked

Re: Perl and files bigger then 2GB

2001-09-11 Thread Robert Citek
Hello Alla, At 10:42 AM 9/11/2001 -0700, [EMAIL PROTECTED] wrote: >Hi, >Is perl has limitation of dealing with files bigger then 2 GBytes? Yes and no. For my boxes running RedHat linux 7.1, I rebuilt the RPM from the src.rpm file. Specifically, I changed one of the options in the perl.spec fi

Re: simple question

2001-09-07 Thread Robert Citek
Hello Ryan, Replace this line: $body=~[what goes here?] with this: $body=~ s/\n/\n/g; or this: $body=~ s/\n//g; Do either of these do what you intend? Regards, - Robert - At 04:44 PM 9/7/2001 -0700, Ryan Kane wrote: [...] >from the script: >-- >#!/usr/lo