; 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;
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
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
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
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
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
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
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/
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
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
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
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.
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->
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
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
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
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).
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.
-
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
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
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
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
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
)
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
);
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
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
smime.p7m
Description: S/MIME encrypted message
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
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
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
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
> 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
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
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
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
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.
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
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
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
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
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,
>
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
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
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
=
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
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?
> -
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
> -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
> -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
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
> -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
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
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
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
"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
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 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
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.
>
>
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
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
]
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
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
> 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
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
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)
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
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
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
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
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
70 matches
Mail list logo