Re: Spliting and creating small files from a main files based on line number

2015-03-25 Thread Jim Gibson
; print "EL=[$el]\n"; > next if /^\s*$/; > print $WFH "$el\n"; > } > close($WFH); > $start_index = ($next_index+1); > $next_index = ($start_index+8); > $i = $start_index;

Re: Spliting and creating small files from a main files based on line number

2015-03-25 Thread Anirban Adhikary
Hi Sholmi I am using write mode for file writing because filename with counter value has assigned so there is no possibility of overwriting. What I would like to do i already said create some small file out of a main config file. IfI do not assign on $i then the for loop will not start from the n

Re: Spliting and creating small files from a main files based on line number

2015-03-25 Thread Shlomi Fish
Hi Anirban, On Wed, 25 Mar 2015 22:37:39 +0530 Anirban Adhikary wrote: > Hi List > I have a configuration file and I would like to split the main file into > multiple small files and push the small temp. files into an array. My > config file looks like this > > GRC01;8;8;1;1;323U6_SIU-8;2048;20

Spliting and creating small files from a main files based on line number

2015-03-25 Thread Anirban Adhikary
el\n"; } close($WFH); $start_index = ($next_index+1); $next_index = ($start_index+8); $i = $start_index; $counter++; # @tmp_line_content = undef; } while executing the code 4 tmp files are created but all of them are zero byte. Though in the print

Re: A newbie question - line number inside the script

2008-07-17 Thread Amit Koren
Amit, Thank you for the quick response. What i actually meant was the line number of the source-script file, that is now being read (executed). This is achieved (so i learned from the list) by the __LINE__ directive. Thanks again. Amit. On Wed, Jul 16, 2008 at 1:24 PM, Amit Saxena <[EM

Re: A newbie question - line number inside the script

2008-07-16 Thread Peter Aronoff
Hi Stewart, Is there *anything* that might convince you to stop top-posting? Let me put it another way: please stop top-posting. Thanks. signature.asc Description: Digital signature

Re: A newbie question - line number inside the script

2008-07-16 Thread Rob Dixon
NE__ is the source file line number where it is placed. For instance print __LINE__ ; will output '3'. The built-in function caller() will return a list of three values - the package name, file name, and file line number of the place where the current subroutine was called. So u

RE: A newbie question - line number inside the script

2008-07-16 Thread V.Ramkumar
Just use $. To print current line number. Regards, Ramkumar -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

RE: A newbie question - line number inside the script

2008-07-16 Thread Stewart Anderson
al Message- From: Amit Koren [mailto:[EMAIL PROTECTED] Sent: 16 July 2008 11:22 To: beginners@perl.org Subject: A newbie question - line number inside the script Hi list. I'm a newbie to Perl, (and to this mailing list) :) There's a task i was given, in which it is necessary to

RE: A newbie question - line number inside the script

2008-07-16 Thread Stewart Anderson
You could use the __LINE__ directive in your error handler. -Original Message- From: Amit Saxena [mailto:[EMAIL PROTECTED] Sent: 16 July 2008 11:25 To: Amit Koren Cc: beginners@perl.org Subject: Re: A newbie question - line number inside the script On Wed, Jul 16, 2008 at 3:52

Re: A newbie question - line number inside the script

2008-07-16 Thread Amit Saxena
On Wed, Jul 16, 2008 at 3:52 PM, Amit Koren <[EMAIL PROTECTED]> wrote: > Hi list. > > I'm a newbie to Perl, (and to this mailing list) :) > There's a task i was given, in which it is necessary to get the > number of the current executing line/command - inside the script itself. > > Can someone as

A newbie question - line number inside the script

2008-07-16 Thread Amit Koren
Hi list. I'm a newbie to Perl, (and to this mailing list) :) There's a task i was given, in which it is necessary to get the number of the current executing line/command - inside the script itself. Can someone assist please ? Thanks in advance, Amit.

Re: Expect.pm passing $exp to subroutine ** line number correction

2008-06-13 Thread Noah
Hi John and List members, Your advice has come in useful but still I am unable to keep the expect object variable $exp from one subroutine to another subroutine. sometihng gets broken and not sure what it is. still running in to problems at line 168 (formerly 167). Here is line 168: "$exp->

Re: Expect.pm passing $exp to subroutine ** line number correction

2008-06-12 Thread John W. Krahn
John W. Krahn wrote: Noah wrote: #delete saved configuraiton file unlink ($outputFilename); You should verify that unlink worked correctly: unlink $outputFilename or warn "Cannot unlink '$outputFilename' $!"; But you don't really need to unlink the file as you are opening it

Re: Expect.pm passing $exp to subroutine ** line number correction

2008-06-12 Thread John W. Krahn
Noah wrote: Hi, Hello, thank you again list members for the quick response to my last question. I am using the I am trying to figure out to pass my $exp to the subroutine "grabConfig". $exp is the variable of my expect object. line 167 is "$patidx = $exp->expect($timeout, [$prompt]); " he

Expect.pm passing $exp to subroutine ** line number correction

2008-06-12 Thread Noah
Hi, thank you again list members for the quick response to my last question. I am using the I am trying to figure out to pass my $exp to the subroutine "grabConfig". $exp is the variable of my expect object. line 167 is "$patidx = $exp->expect($timeout, [$prompt]); " here is the error message

Re: What is equivalent to awk's FNR (line number per crnt file)

2007-12-02 Thread Yitzchok Good
perldoc -> perlvar $. is reset when the filehandle is closed, but not when an open filehandle is reopened without an intervening close(). For more details, see "I/O Operators" in perlop. Because <> never does an explicit close, line numbers increase across ARGV files (but see examples in eof).

What is equivalent to awk's FNR (line number per crnt file)

2007-12-02 Thread reader
Seems that I recall perl having a built in like awk's FNR that keeps track of the current line number in each file. Zeros out on each new file. Like $. only goes to zero on each new file. I know how to do that with code but wondered if perl already does it thru some builtin. -

Re: regd . Line number printing...

2007-07-10 Thread mayank . ahuja
Hi Paul I don't think so.In my mail I was so much rude , but if you still feel so then I want to apologize. regards Mayank Paul Lalli <[EMAIL PROTECTED]> 07/10/2007 11:14 PM To beginners@perl.org cc Subject Re: regd . Line number printing... On Jul 10, 8:24

Re: regd . Line number printing...

2007-07-10 Thread Gowtham
H,$input_file or die "Can not open the file at $!" ; > my @lines = ; > while () > print $. ;} > > close(FH); > > But its neither printing line number nor giving any error. > > regards > Mayank > =-=-= > Notice: The information

Re: regd . Line number printing...

2007-07-10 Thread Gowtham
H,$input_file or die "Can not open the file at $!" ; > my @lines = ; > while () > print $. ;} > > close(FH); > > But its neither printing line number nor giving any error. > > regards > Mayank > =-=-= > Notice: The information

Re: regd . Line number printing...

2007-07-10 Thread Paul Lalli
ou want to start reading again, you have to seek() (see `perldoc -f seek`). Otherwise, this loop will never execute because returns undefined after FH has had all its data read. > print $. ;} > > close(FH); > > But its neither printing line number nor giving any error. Because there

Re: regd . Line number printing...

2007-07-10 Thread John W. Krahn
ll not run. print $. ; } close(FH); But its neither printing line number nor giving any error. It should report the syntax error. What you probably want is: my @lines = ; print $.; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at lo

Re: regd . Line number printing...

2007-07-10 Thread Mr. Shawn H. Corey
) print $. ; } close(FH); But its neither printing line number nor giving any error. The line: my @lines = ; slurps in the entire file. Thusly the while statement will exit immediately since there is nothing left in the file. Removing this line will print the line numbers. --- Shawn

regd . Line number printing...

2007-07-10 Thread mayank . ahuja
); But its neither printing line number nor giving any error. regards Mayank =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemi

Re: is there a simple way get the current line number of processed file?

2005-05-27 Thread luhao
On Fri, May 27, 2005 at 10:31:40AM +0800, bingfeng zhao wrote: > To parse a regular text file, I should report the line number of parsed file > when error occured. I want to know whether perl provide a shortcut way or > magic '$?' indicate this. I must counting myself if n

RE: is there a simple way get the current line number of processe d file?

2005-05-26 Thread Thomas Bätzler
smime.p7m Description: S/MIME encrypted message

Re: is there a simple way get the current line number of processed file?

2005-05-26 Thread Jeff 'japhy' Pinyan
On May 27, bingfeng zhao said: To parse a regular text file, I should report the line number of parsed file when error occured. I want to know whether perl provide a shortcut way or magic '$?' indicate this. I must counting myself if not. When reading from a filehandle, the $. vari

is there a simple way get the current line number of processed file?

2005-05-26 Thread bingfeng zhao
To parse a regular text file, I should report the line number of parsed file when error occured. I want to know whether perl provide a shortcut way or magic '$?' indicate this. I must counting myself if not.   Thanks in advance     smime.p7s Description: S/MIME cryptographic signature

Re: How can we get the Line Number

2005-03-01 Thread Owen Cook
On Wed, 2 Mar 2005, Suneel Kumar B wrote: > > May be my earlier mail is missed somewhere.. I wish you all a nice day.. > > While matching a string with each line of a file, if the string is > matched with any of those lines, How can we get the line number of the > line w

How can we get the Line Number

2005-03-01 Thread Suneel Kumar B
Hi all, May be my earlier mail is missed somewhere.. I wish you all a nice day.. While matching a string with each line of a file, if the string is matched with any of those lines, How can we get the line number of the line where it is matched..? Is there any built-in function for fetching the

Re: using $. line number special variable (followup)

2004-11-10 Thread Joseph Paish
> at the debugger prompt, it displays whatever line number the debugger > > just printed out. for example, if i have 17 debugger prompts before i > > issue the "p $." command, it will display 17 instead of the line number > > of the file i am reading at the tim

Re: using $. line number special variable (followup)

2004-11-09 Thread Paul Johnson
On Tue, Nov 09, 2004 at 11:40:30AM -0600, Joseph Paish wrote: > BTW, i think i may have found out what is giving me the strange line numbers > in the debugger under emacs. it seems that when i enter "p $." at the > debugger prompt, it displays whatever line number the de

Re: using $. line number special variable (followup)

2004-11-09 Thread Joseph Paish
On Tuesday 09 November 2004 10:20, Christopher Maujean wrote: > On Tue, 2004-11-09 at 07:24, Joseph Paish wrote: > > just a short followup to my earlier message about the $. line number > > variable. when i enter a print statement as shown below, it prints the > > correct lin

Re: using $. line number special variable (followup)

2004-11-09 Thread Joseph Paish
On Tuesday 09 November 2004 08:41, Bob Showalter wrote: > Joseph Paish wrote: > > just a short followup to my earlier message about the $. line number > > variable. when i enter a print statement as shown below, it prints > > the correct line number (starting at 1), but s

Re: using $. line number special variable (followup)

2004-11-09 Thread Christopher Maujean
On Tue, 2004-11-09 at 07:24, Joseph Paish wrote: > just a short followup to my earlier message about the $. line number > variable. when i enter a print statement as shown below, it prints the > correct line number (starting at 1), but still never enters the if() > structure.

RE: using $. line number special variable (followup)

2004-11-09 Thread Bob Showalter
Joseph Paish wrote: > just a short followup to my earlier message about the $. line number > variable. when i enter a print statement as shown below, it prints > the correct line number (starting at 1), but still never enters the > if() structure. > > for the sake of un

Re: using $. line number special variable (followup)

2004-11-09 Thread Joseph Paish
just a short followup to my earlier message about the $. line number variable. when i enter a print statement as shown below, it prints the correct line number (starting at 1), but still never enters the if() structure. for the sake of understanding how to correctly use this variable, i

Re: using $. line number special variable

2004-11-08 Thread Randy W. Sims
Joseph Paish wrote: how do you use the "line number" variable inside a while loop like i am trying to do below? i never get to process the first line of the file, and as a result, subsequent calculations are inaccurate. it always jumps to the second "if" statement. Like

Re: using $. line number special variable

2004-11-08 Thread William C. Bruce
Joe, If you are using fh1 more than 1x in the code, and it's not explicitly closed with each use, you will start at the last line number of the previous file or across files. I had a tendency to reuse file handles, relying on perl's implicit close, and ran into the above. The co

Re: using $. line number special variable

2004-11-08 Thread Joseph Paish
On Monday 08 November 2004 10:56, Bob Showalter wrote: > Joseph Paish wrote: > > how do you use the "line number" variable inside a while loop like i > > am trying to do below? > > > > i never get to process the first line of the file, and as a result, >

RE: using $. line number special variable

2004-11-08 Thread Bob Showalter
Joseph Paish wrote: > how do you use the "line number" variable inside a while loop like i > am trying to do below? > > i never get to process the first line of the file, and as a result, > subsequent calculations are inaccurate. it always jumps to the > second &qu

Re: using $. line number special variable

2004-11-08 Thread Chris Devers
On Mon, 8 Nov 2004, Joseph Paish wrote: > how do you use the "line number" variable inside a while loop like i am > trying to do below? Why not go about the problem like this? #!/usr/bin/perl use strict; use warnings; open (fh1, "/path/to/file") or

using $. line number special variable

2004-11-08 Thread Joseph Paish
how do you use the "line number" variable inside a while loop like i am trying to do below? i never get to process the first line of the file, and as a result, subsequent calculations are inaccurate. it always jumps to the second "if" statement. thanks joe =

Re: Line number

2004-05-27 Thread Jan Eden
xample >above? Please help. > >If you're using a Unix system, try the command "grep". I do believe >MS-DOS like systems include a "find" utility with the same purpose. > The original poster asked for the line number. The variable $. will do what he wants, i

Re: Line number

2004-05-27 Thread Jose Alves de Castro
On Thu, 2004-05-27 at 10:10, Jon Herbry wrote: > Hi, anybody have idea find the number in a file? Assume I create a file call "sample" > and have content below: > > Hi, Jame where are you? > How old are you? > when you free? > can you coming my home? > -

Line number

2004-05-27 Thread Jon Herbry
Hi, anybody have idea find the number in a file? Assume I create a file call "sample" and have content below: Hi, Jame where are you? How old are you? when you free? can you coming my home? - assume if i want know string w

RE: Line number variable....

2004-05-07 Thread Shaw, Matthew
> -Original Message- > >there a variable containing the actual > > source-line number during execution? > > > > Yes, the $. This is incorrect, $. actually contains the 'current line number' from the last accessed file handle. It will be undef if no

RE: Line number variable....

2004-05-07 Thread NYIMI Jose (BMB)
> -Original Message- > From: Paul Johnson [mailto:[EMAIL PROTECTED] On Behalf Of Paul Johnson > Sent: Friday, May 07, 2004 1:20 PM > To: NYIMI Jose (BMB) > Cc: Gabor Urban; [EMAIL PROTECTED] > Subject: Re: Line number variable > > > On Fri, May 07, 2004

Re: Line number variable....

2004-05-07 Thread Paul Johnson
On Fri, May 07, 2004 at 01:01:01PM +0200, NYIMI Jose (BMB) wrote: > > -Original Message- > > From: Gabor Urban [mailto:[EMAIL PROTECTED] > > > > I was going through the manuals some times, but could not > > find it. Is there a variable containing the

RE: Line number variable....

2004-05-07 Thread NYIMI Jose (BMB)
> -Original Message- > From: Gabor Urban [mailto:[EMAIL PROTECTED] > Sent: Friday, May 07, 2004 12:57 PM > To: [EMAIL PROTECTED] > Subject: Line number variable > > > Hi, > > I was going through the manuals some times, but could not > find it. I

Line number variable....

2004-05-07 Thread Gabor Urban
Hi, I was going through the manuals some times, but could not find it. Is there a variable containing the actual source-line number during execution? Gabaux Linux is like a wigwam: no gates, no windows, and an apache inside! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands

Re: Inserting Line Number

2003-11-09 Thread James Edward Gray II
On Nov 9, 2003, at 3:56 PM, Raghu Murthy wrote: I would like to insert line numbers for all the files in a directory. So if a directory contains files like foo.c, foo.c1, foo.c2, foo.c3, foo.c4, I am trying to see and choose one of the numbers to process it. 1. foo.c1 2. foo.c2 3. foo.c3 4. foo

Inserting Line Number

2003-11-09 Thread Raghu Murthy
I would like to insert line numbers for all the files in a directory. So if a directory contains files like foo.c, foo.c1, foo.c2, foo.c3, foo.c4, I am trying to see and choose one of the numbers to process it. 1. foo.c1 2. foo.c2 3. foo.c3 4. foo.c4 Can I use __LINE__ or $. to do that or am I

Re: How to get the script line number on demand

2003-02-16 Thread Harry Putnam
"John W. Krahn" <[EMAIL PROTECTED]> writes: > print 'Program name: ', __FILE__, "\n"; > print 'Current script line: ', __LINE__, "\n"; > print 'Current package: ', __PACKAGE__, "\n"; Thanks.. I'd seen those first too in a few places but blithely zipped over them not realizing what they were. Th

Re: How to get the script line number on demand

2003-02-15 Thread John W. Krahn
Harry Putnam wrote: > > How does one print the line number of the script as it executes. > > Something like what the PS4 shell var does if you set it to: > > PS4='$LINENO' > Then when running a shell script with -x flag you see script line > numbers as it runs.

How to get the script line number on demand

2003-02-15 Thread Harry Putnam
How does one print the line number of the script as it executes. Something like what the PS4 shell var does if you set it to: PS4='$LINENO' Then when running a shell script with -x flag you see script line numbers as it runs. I'd like to stick these into code at times to hel

RE: Getting a line number from a file.

2002-09-26 Thread Nikola Janceski
see perldoc perlvar $. # has the current line number of the last FILEHANDLE opened. > -Original Message- > From: Steve [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 26, 2002 9:18 AM > To: [EMAIL PROTECTED] > Subject: Getting a line number from a file. > >

RE: Getting a line number from a file.

2002-09-26 Thread Timothy Johnson
Check out the documentation on the $. variable. It does what you want. -Original Message- From: Steve [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 26, 2002 6:18 AM To: [EMAIL PROTECTED] Subject: Getting a line number from a file. Is there a way to, as a file is read to print

Getting a line number from a file.

2002-09-26 Thread Steve
Is there a way to, as a file is read to print the line number you are on? - The three most dangerous things are a programmer with a soldering iron, a manager who codes, and a user who gets ideas. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

RE: Line number of whence called

2002-04-23 Thread Timothy Johnson
] Sent: Tuesday, April 23, 2002 10:29 AM To: 'Jonathan E. Paton' Cc: Beginners (E-mail) Subject: RE: Line number of whence called I am atheist so I don't believe in the Religion Module. 8^P PS you're right... should have used Carp. > -Original Message- > From: J

RE: Line number of whence called

2002-04-23 Thread Nikola Janceski
I am atheist so I don't believe in the Religion Module. 8^P PS you're right... should have used Carp. > -Original Message- > From: Jonathan E. Paton [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, April 23, 2002 1:24 PM > To: [EMAIL PROTECTED] > Subject: Re: Lin

Re: Line number of whence called

2002-04-23 Thread Jonathan E. Paton
> Is there someway to get the line number of > whence a subroutine was called? Yes, but 9/10 ten people use Carp.pm, the other 1 respondant was an assembly language programmer. perldoc Carp Carp is implemented using 'caller', which you can find documentation about at: perld

Line number of whence called

2002-04-23 Thread Nikola Janceski
Is there someway to get the line number of whence a subroutine was called? i.e. #!perl use subs qw(die); sub die { ## do some special stuff here. CORE::die @_; } die "not here" if 0; die "I died here"; __END__ I want to see the line where die w

Re: line number

2001-09-07 Thread Michael Fowler
On Fri, Sep 07, 2001 at 02:58:30PM +0200, Roland Schoenbaechler wrote: > In some cases I want to write the line-number of the script to STDERR (In > analogy to the functions die or next). Does a variable exist indicating the > line number of the currently executed step (or the last step)

Re: line number

2001-09-07 Thread Kevin Meltzer
Hi Ronald, On Fri, Sep 07, 2001 at 02:58:30PM +0200, Roland Schoenbaechler ([EMAIL PROTECTED]) spew-ed forth: > analogy to the functions die or next). Does a variable exist indicating the > line number of the currently executed step (or the last step)? > Yes, you can use the __LIN

Re: line number

2001-09-07 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 7, Roland Schoenbaechler said: >In some cases I want to write the line-number of the script to STDERR (In >analogy to the functions die or next). Does a variable exist indicating the >line number of the currently executed step (or the last step)? The caller() function also gives

Re: line number

2001-09-07 Thread register
print "I stopped at line number ",__LINE__,"\n"; On Fri, Sep 07, 2001 at 02:58:30PM +0200, Roland Schoenbaechler shaped the electrons to read: > In some cases I want to write the line-number of the script to STDERR (In > analogy to the functions die or next). Does a

Re: line number

2001-09-07 Thread Robert Bunn
At 02:58 PM 9/7/01 +0200, you wrote: >In some cases I want to write the line-number of the script to STDERR (In >analogy to the functions die or next). Does a variable exist indicating the >line number of the currently executed step (or the last step)? The current line is __LINE__. It

line number

2001-09-07 Thread Roland Schoenbaechler
In some cases I want to write the line-number of the script to STDERR (In analogy to the functions die or next). Does a variable exist indicating the line number of the currently executed step (or the last step)? Thanks for your help Roland *** PLEASE NOTE