User Profile

Collapse

Profile Sidebar

Collapse
jkr
jkr
Last Activity: Aug 31 '07, 01:41 PM
Joined: Feb 2 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jkr
    replied to Passing parameters to a perl file from .sh file
    in Perl
    In the above sample it should read:
    perl perl.pl $VAR

    ---------

    you can do the following:

    $ export VAR='whatever'

    and run:
    myperl.pl
    [HTML]#!/usr/bin/perl -w

    defined($arg=sh ift(@ARGV)) && print "arg: $arg\n";
    print "var: $ENV{'VAR'}\n";[/HTML]
    will print:
    var: whatever

    ./myperl.pl argumen...
    See more | Go to post

    Leave a comment:


  • Depending on what unix you are using maybe the system call "tail -n 11" will do what you want.
    See more | Go to post

    Leave a comment:


  • jkr
    replied to Need help in Extracting multiple lines
    in Perl
    Depending on how you need to process the data this might be useful (I'm reading from STDIN):

    Code:
    #!/usr/bin/perl -w
    
    use strict;
    my $index1=0;
    my $index2=0;
    my %vals;
    
    while (<>) {
      chomp;
      if (/^p (\d+) (\d+)$/) {
        $index1=$1; $index2=$2;
      }
      if (/^(-?\d+) (-?\d+)$/) {
        push(@{$vals{$index1}{$index2}}, ($1.";".$2));
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...