User Profile

Collapse

Profile Sidebar

Collapse
docsnyder
docsnyder
Last Activity: Dec 28 '12, 11:24 AM
Joined: Dec 12 '06
Location: Darmstadt
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • docsnyder
    replied to Sliding window
    in Perl
    Code:
    foreach my $x (0..$#AoA-1) {
    should be

    Code:
    foreach my $x (0..$#AoA) {
    Greetz, Doc
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to calculator program in perl language
    in Perl
    @archulu

    - What is the input format?

    - Which operators should be supported?

    - Are you allowed to use eval()?

    Greetz, Doc
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Sorting Dates
    in Perl
    @archulu

    Try this:
    Code:
    @dates = (
      "12/01/2007",
      "23/05/1998",
      "15/12/2006",
      "05/12/2006",
      "21/08/1986",
    );
    
    @dates = map { $_->[0] } sort(map { [ $_, reverse(split('/', $_)) ] } @dates);
    
    map { print $_."\n" } @dates;
    Greetz, Doc
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Parsing Multiple Log Files
    in Perl
    @sunilmehta

    Just to give you an idea:
    Code:
    @arr = (
      "/this/is/one/path",
      "/this/is/another/path",
    );
    
    for $path ( @arr ) {
      # process the single file $path here !
    }
    Greetz, Doc
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Sourcing a Shell Script
    in Perl
    @rajataggarwal

    Yes, in principle, shell scripts can be sourced with "source <script>" (you also could use the dot-form ". <script>").

    But, since system() starts a subshell, your environment variables do not get passed to the shell your perl script is running in. Even though your shell script exports variables, it will export them to the subshell, not to your actual shell.

    ...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Sorting a list by Secondary Key
    in Perl
    @joeke3el

    If you want to read more about the backgrounds of Kevin's solution, it's called the "Schwarztia n Transform".

    Greetz, Doc
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Parsing Multiple Log Files
    in Perl
    @sunilmehta

    You know how to process a single log file. So, keep multiple log files in an array of file names (which you, e.g. retrieve from a file). The iterate the list and process each individual log file as you do already:

    Code:
    @logFiles = ...      # retrieve list of file names from a file or whatever
    
    for $file ( @logFiles  {
      doWhatYouDoForSingleLogFile($files);
    }
    Greetz, ...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Find Missing Column and Extra Column
    in Perl
    @Byomokesh

    Assuming @lines contains the lines of your xml file, you could do something like this:

    Code:
    for ( $i=0 ; $i<=$#lines ; $i++ ) {
      if ( $lines[$i] =~ m(<tgroup\s+cols="(\d+)") ) {
        $numCols = $1;
      }
      elsif ( $lines[$i] =~ m(<row>) ) {
        $colCnt = 0;
        $start  = $i + 1;
      }
      elsif ( $lines[$i] =~ m(</row>) ) {
    ...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to .pm file
    in Perl
    If the pm file does not reside within the same folder as your script, ensure that the path is contained in @INC.

    Greetz, Doc...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Chunk by Chunk processing of XML
    in Perl
    @rellaboyina

    Try something like this:

    Code:
    $tag = "tsip";
    
    @lines = (
      "<tsip:dataFeed=....>",
      "<tsip><invention>.....</invention></tsip>",
      "<tsip><invention>.....</invention></tsip>",
      "<tsip><invention>.....</invention></tsip>",
      "</tsip:dataFeed>",
    ...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Can any help in writing an email in perl
    in Perl
    @vasu1308

    Finding the size of a directory is answered, already.

    But, for your request on writing an email in PERL, still not yet answered, try MIME::Lite.

    Greetz, Doc
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Converting PDF files to XML (Urgent)
    in Perl
    @Mokita

    I do not know, which kind of transformation you intend to perform, but a three step conversion surely bears the problem of structural information getting lost.

    As Kevin has pointed out, there are, of course, solutions available, which could be appropriate for your needs.

    As XML is a derivative of SGML, and as PDF could of course be encoded in SGML (even if not very appropriate), the transformation...
    See more | Go to post

    Leave a comment:


  • @watcher00

    I closed "http://perldoc.perl.or g/perlfaq4.html#H ow-can-I-count-the-number-of-occurrences-of-a-substring-within-a-string%3f" very fast, because it's not quite a "quick" reference. You should study it, of course, but in order to get immediate help, take this as a hint on how to proceed:

    Code:
    $text  = "Hello! This is a sentence, and an example. Two commas, one exclamation mark and two dots.";
    ...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Processing a Data Structure
    in Perl
    @Iris83

    I'm not quite sure what you are intending to do.

    Code:
    $hash{ $elements[1] } = $elements[2];
    Do you really mean the second and the third element? Remember, the first array element has index 0.

    You are accessing $hash{1} and $hash{2}. Are 1 and 2 really the hash keys you mean?

    Code:
    if ($hash{2} eq 'B')
    print $data;
    else {print $data;
    }
    Why an...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Parsing a CSV file into a Hash
    in Perl
    @Iris83

    Just another possibility:

    Code:
    open(DATA, "<", "data.csv") or die $!;
    
    my %hash;
    
    %hash = ( %hash, (split(/,/, $_))[1,2] ) while ( <DATA> );
    Greetz, Doc
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Predicting space available for a ZIP file
    in Perl
    @Bir

    There is a difference, because a ZIP file does not consist of just a sequence of compressed files. Some additional administrative data is required as well (table of contents, offsets, sizes, ...). I do not know whether Archive::Zip provides a method to figure out the amount of administrative data within a ZIP file.

    The null-device is always of size null, that's why it is called null-device. Writing to such a device...
    See more | Go to post

    Leave a comment:


  • Did you remove the <CR> character?

    dos2unix may help, but there are other possibility, like vi, etc.

    Greetz, Doc...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Parsing an Error Log
    in Perl
    @ramyaamar

    Just to give you an idea:
    Code:
    @lines = (
      "[2/3/07 1:55:48:027 EST] 0000000a SystemErr R at com.ibm.ws.runtime.WsServerImpl.bootServerContaine r(WsServerImpl.java:182)",
      "[2/3/07 1:55:48:028 EST] 0000000a SystemErr R at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl .java:120)",
    );
    
    for ( @lines ) {
      ($date, $time, $errNo, $errStr, $location) = $_ =~ m(^\[(\d+/\d+/\d+)\s+(.*)\]\s+([\da-z]+)\s+(.*)\s+at\s+(.*)$);
    ...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Predicting space available for a ZIP file
    in Perl
    @bir

    I could not run your code, because I do not have Zip.pm installed. So, I can just give you guesses.

    It appears, that devnull() may not be a seekable device (like pipes). I assume, that writeToFileName d() is trying to seek to the beginning of the given file before starting to write.

    Have you read about the devnull() approach in the internet? Is there somebody out there, who can verify that it should...
    See more | Go to post

    Leave a comment:


  • docsnyder
    replied to Incrementing a Switch
    in Perl
    Oops!

    My considerations could not have been taken serious so far, because I have made a mistake!

    I would like to correct myself: The answer should clearly not be:
    Code:
      if ( $opt eq "-i" ) {
        $i = $opt;
      }
    but
    Code:
      if ( $opt eq "-i" ) {
        $i = shift;
      }
    But, I am happy so far that nobody has recognized it, yet.

    Greetz, Doc
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...